From 2a47ed50e144853f0f2d9e7f3b161482003abf0f Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Thu, 7 May 2020 17:53:52 -0400 Subject: [PATCH] Fix --- commands/games-mp/battle.js | 3 ++- structures/battle/Battle.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/commands/games-mp/battle.js b/commands/games-mp/battle.js index 85a2d01b..11a7364e 100644 --- a/commands/games-mp/battle.js +++ b/commands/games-mp/battle.js @@ -36,7 +36,7 @@ module.exports = class BattleCommand extends Command { return msg.say('Looks like they declined...'); } } - while (battle.winner === null || battle.winner !== 'time') { + while (!battle.winner) { const choice = await battle.attacker.chooseAction(msg); if (choice === 'attack') { const damage = randomRange(battle.defender.guard ? 5 : 20, battle.defender.guard ? 20 : 50); @@ -81,6 +81,7 @@ module.exports = class BattleCommand extends Command { await msg.say(`Time's up, ${battle.attacker}!`); battle.reset(); if (battle.lastTurnTimeout) { + battle.endedDueToInactivity = true; break; } else { battle.lastTurnTimeout = true; diff --git a/structures/battle/Battle.js b/structures/battle/Battle.js index 271de3a3..0828e1c8 100644 --- a/structures/battle/Battle.js +++ b/structures/battle/Battle.js @@ -7,6 +7,7 @@ module.exports = class Battle { this.userTurn = false; this.turn = 1; this.lastTurnTimeout = false; + this.endedDueToInactivity = false; } get attacker() { @@ -26,7 +27,7 @@ module.exports = class Battle { } get winner() { - if (this.lastTurnTimeout) return 'time'; + if (this.endedDueToInactivity) return 'time'; if (this.user.hp <= 0) return this.opponent; if (this.opponent.hp <= 0) return this.user; return null;