mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-17 08:17:35 +02:00
Rework battle commands
This commit is contained in:
@@ -24,8 +24,8 @@ module.exports = class BattleCommand extends Command {
|
||||
}
|
||||
|
||||
async run(msg, { opponent }) {
|
||||
if (opponent.id === msg.author.id) return msg.reply('You may not fight yourself.');
|
||||
if (this.battles.has(msg.channel.id)) return msg.reply('Only one fight may be occurring per channel.');
|
||||
if (opponent.id === msg.author.id) return msg.reply('You may not battle yourself.');
|
||||
if (this.battles.has(msg.channel.id)) return msg.reply('Only one battle may be occurring per channel.');
|
||||
this.battles.set(msg.channel.id, new Battle(msg.author, opponent));
|
||||
const battle = this.battles.get(msg.channel.id);
|
||||
try {
|
||||
@@ -39,21 +39,21 @@ module.exports = class BattleCommand extends Command {
|
||||
}
|
||||
while (!battle.winner) {
|
||||
const choice = await battle.attacker.chooseAction(msg);
|
||||
if (choice === 'fight') {
|
||||
const damage = randomRange(battle.defender.guarding ? 5 : 20, battle.defender.guarding ? 20 : 50);
|
||||
if (choice === 'attack') {
|
||||
const damage = randomRange(battle.defender.guard ? 5 : 20, battle.defender.guard ? 20 : 50);
|
||||
await msg.say(`${battle.attacker} deals **${damage}** damage!`);
|
||||
battle.defender.dealDamage(damage);
|
||||
battle.reset();
|
||||
} else if (choice === 'guard') {
|
||||
await msg.say(`${battle.attacker} guards!`);
|
||||
} else if (choice === 'defend') {
|
||||
await msg.say(`${battle.attacker} defends!`);
|
||||
battle.attacker.changeGuard();
|
||||
battle.reset(false);
|
||||
} else if (choice === 'special') {
|
||||
const miss = Math.floor(Math.random() * 3);
|
||||
if (miss) {
|
||||
await msg.say(`${battle.attacker}'s attack missed!`);
|
||||
await msg.say(`${battle.attacker}'s special attack missed!`);
|
||||
} else {
|
||||
const damage = randomRange(battle.defender.guarding ? 50 : 100, battle.defender.guarding ? 100 : 200);
|
||||
const damage = randomRange(battle.defender.guard ? 50 : 100, battle.defender.guard ? 100 : 200);
|
||||
await msg.say(`${battle.attacker} deals **${damage}** damage!`);
|
||||
battle.defender.dealDamage(damage);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user