Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
command: state => (args, player, arg0) => {
if (!args) {
return Broadcast.sayAt(player, '<b>Please describe the bug you have found.</b>');
}
// TODO: There's absolutely no reason for this to be an event, just move the event code into the command
player.emit('bugReport', {
description: args,
type: arg0
});
Broadcast.sayAt(player, `<b>Your ${arg0} report has been submitted as:</b>\n${args}`);
Broadcast.sayAt(player, '<b>Thanks!</b>');
}
};
}
let buf = '';
if (damage.source) {
buf = `Your <b>${damage.source.name}</b> hit`;
} else {
buf = "You hit";
}
buf += ` <b>${target.name}</b> for <b>${damage.finalAmount}</b> damage.`;
if (damage.critical) {
buf += ' <b>(Critical)</b>';
}
B.sayAt(this, buf);
if (this.equipment.has('wield')) {
this.equipment.get('wield').emit('hit', damage, target);
}
// show damage to party members
if (!this.party) {
return;
}
for (const member of this.party) {
if (member === this || member.room !== this.room) {
continue;
}
let buf = '';
command : (state) => (args, player) => {
if (!player.inventory || !player.inventory.size) {
return Broadcast.sayAt(player, "You aren't carrying anything.");
}
Broadcast.at(player, "You are carrying");
if (isFinite(player.inventory.getMax())) {
Broadcast.at(player, ` (${player.inventory.size}/${player.inventory.getMax()})`);
}
Broadcast.sayAt(player, ':');
// TODO: Implement grouping
for (const [, item ] of player.inventory) {
Broadcast.sayAt(player, ItemUtil.display(item));
}
}
};
buf = `<b>${damage.attacker.name}</b>`;
}
if (damage.source) {
buf += (damage.attacker ? "'s " : " ") + `<b>${damage.source.name}</b>`;
} else if (!damage.attacker) {
buf += "Something";
}
buf += ` hit <b>You</b> for <b>${damage.finalAmount}</b> damage.`;
if (damage.critical) {
buf += ' <b>(Critical)</b>';
}
B.sayAt(this, buf);
// show damage to party members
if (!this.party) {
return;
}
for (const member of this.party) {
if (member === this || member.room !== this.room) {
continue;
}
let buf = '';
if (damage.attacker) {
buf = `<b>${damage.attacker.name}</b>`;
}
} else {
throw e;
}
}
if (!hadActions) {
return;
}
const usingWebsockets = this.socket instanceof WebsocketStream;
// don't show the combat prompt to a websockets server
if (!this.hasPrompt('combat') && !usingWebsockets) {
this.addPrompt('combat', _ => promptBuilder(this));
}
B.sayAt(this, '');
if (!usingWebsockets) {
B.prompt(this);
}
},
run: state => function (args, player, target) {
const damage = new Damage({
attribute: 'health',
amount: getDamage(player),
attacker: player,
type: 'physical',
source: this
});
Broadcast.sayAt(player, 'With a wave of your hand, you unleash a fireball at your target!');
Broadcast.sayAtExcept(player.room, `With a wave of their hand, ${player.name} unleashes a fireball at ${target.name}!`, [player, target]);
if (!target.isNpc) {
Broadcast.sayAt(target, `With a wave of their hand, ${player.name} unleashes a fireball at you!`);
}
damage.commit(target);
},
run: state => function (args, player, target) {
const damage = new Damage({
attribute: 'health',
amount: getDamage(player),
attacker: player,
type: 'physical',
source: this
});
Broadcast.sayAt(player, 'You shift your feet and let loose a mighty attack!');
Broadcast.sayAtExcept(player.room, `${player.name} lets loose a lunging attack on ${target.name}!`, [player, target]);
if (!target.isNpc) {
Broadcast.sayAt(target, `${player.name} lunges at you with a fierce attack!`);
}
damage.commit(target);
},
player.save(() => {
Broadcast.sayAt(player, "Goodbye!");
Broadcast.sayAtExcept(player.room, `${player.name} disappears.`, player);
player.socket.emit('close');
});
}
target = [...this.combatants][0];
} else {
target = null;
}
} else {
try {
const targetSearch = args.split(' ').pop();
target = Combat.findCombatant(this, targetSearch);
} catch (e) {
if (
e instanceof CombatErrors.CombatSelfError ||
e instanceof CombatErrors.CombatNonPvpError ||
e instanceof CombatErrors.CombatInvalidTargetError ||
e instanceof CombatErrors.CombatPacifistError
) {
return B.sayAt(this, e.message);
}
Logger.error(e.message);
}
}
if (!target) {
return B.sayAt(this, `Use ${ability.name} on whom?`);
}
}
try {
ability.execute(args, this, target);
} catch (e) {
if (e instanceof SkillErrors.CooldownError) {
if (ability.cooldownGroup) {
effectRefreshed: function (newEffect) {
this.startedAt = Date.now();
Broadcast.sayAt(this.target, "You refresh the potion's magic.");
},