From 57b92cc1997f872019680cca72a006d93f1da0fa Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Mon, 18 Dec 2017 03:41:07 +0000 Subject: [PATCH] Fix --- commands/games/balloon-pop.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/commands/games/balloon-pop.js b/commands/games/balloon-pop.js index bc7c18d0..f81a5676 100644 --- a/commands/games/balloon-pop.js +++ b/commands/games/balloon-pop.js @@ -41,6 +41,12 @@ module.exports = class BalloonPopCommand extends Command { const user = userTurn ? msg.author : opponent; await msg.say(`${user} pumps the balloon!`); remains -= 50; + const popped = !Math.floor(Math.random() * (remains < 0 ? 2 : remains)); + if (popped) { + await msg.say('The balloon pops!'); + winner = userTurn ? opponent : msg.author; + break; + } let pump; if (!opponent.bot || (opponent.bot && userTurn)) { await msg.say(`${user}, do you pump the balloon again?`); @@ -52,15 +58,15 @@ module.exports = class BalloonPopCommand extends Command { if (pump) { await msg.say(`${user} pumps the balloon!`); remains -= 50; + const popped2 = !Math.floor(Math.random() * (remains < 0 ? 2 : remains)); + if (popped2) { + await msg.say('The balloon pops!'); + winner = userTurn ? opponent : msg.author; + } } else { await msg.say(`${user} steps back!`); userTurn = !userTurn; } - const popped = Boolean(Math.floor(Math.random() * (remains < 0 ? 2 : remains))); - if (popped) { - await msg.say('The balloon pops!'); - winner = userTurn ? opponent : msg.author; - } } this.playing.delete(msg.channel.id); return msg.say(`And the winner is... ${winner}! Great job!`);