Better Russian Roulette message

This commit is contained in:
Dragon Fire
2019-12-08 23:08:28 -05:00
parent c1678dde76
commit 8bf6aa19c3
+6 -1
View File
@@ -39,6 +39,7 @@ module.exports = class RussianRouletteCommand extends Command {
const gun = shuffle([true, false, false, false, false, false, false, false]); const gun = shuffle([true, false, false, false, false, false, false, false]);
let round = 0; let round = 0;
let winner = null; let winner = null;
let quit = false;
while (!winner) { while (!winner) {
const player = userTurn ? msg.author : opponent; const player = userTurn ? msg.author : opponent;
const notPlayer = userTurn ? opponent : msg.author; const notPlayer = userTurn ? opponent : msg.author;
@@ -51,12 +52,16 @@ module.exports = class RussianRouletteCommand extends Command {
${opponent.bot ? 'Continue?' : `Will you take the gun, ${notPlayer}?`} (${8 - round - 1} shots left) ${opponent.bot ? 'Continue?' : `Will you take the gun, ${notPlayer}?`} (${8 - round - 1} shots left)
`); `);
const keepGoing = await verify(msg.channel, opponent.bot ? msg.author : notPlayer); const keepGoing = await verify(msg.channel, opponent.bot ? msg.author : notPlayer);
if (!keepGoing) winner = notPlayer; if (!keepGoing) {
winner = notPlayer;
quit = true;
}
round++; round++;
userTurn = !userTurn; userTurn = !userTurn;
} }
} }
this.client.games.delete(msg.channel.id); this.client.games.delete(msg.channel.id);
if (quit) return msg.say(`${winner} wins, because their opponent was a coward.`);
return msg.say(`The winner is ${winner}!`); return msg.say(`The winner is ${winner}!`);
} catch (err) { } catch (err) {
this.client.games.delete(msg.channel.id); this.client.games.delete(msg.channel.id);