From 368b4d3e4fdce2c961ea3f71d9e66b1df16bef0c Mon Sep 17 00:00:00 2001 From: JonnyBro Date: Wed, 19 Jan 2022 19:28:13 +0500 Subject: [PATCH] =?UTF-8?q?=D0=91=D0=BE=D0=BB=D1=8C=D1=88=D0=B5=20=D1=84?= =?UTF-8?q?=D0=B8=D0=BA=D1=81=D0=BE=D0=B2=20=D0=B8=20=D1=82=D1=80=D0=B0?= =?UTF-8?q?=D0=BD=D0=B7=D0=B0=D0=BA=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/Fun/horserace.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/commands/Fun/horserace.js b/commands/Fun/horserace.js index ac5c86bf..af398be1 100644 --- a/commands/Fun/horserace.js +++ b/commands/Fun/horserace.js @@ -71,10 +71,9 @@ class Horserace extends Command { horse: horse }; - data.memberData.money -= amount; message.sendT("fun/horserace:BET", { user: author.username, - amount: `**${amount}** ${message.getNoun(amount, message.translate("misc:NOUNS:CREDITS:1"), message.translate("misc:NOUNS:CREDITS:2"), message.translate("misc:NOUNS:CREDITS:5"))}`, + amount: `**${Math.floor(amount)}** ${message.getNoun(Math.floor(amount), message.translate("misc:NOUNS:CREDITS:1"), message.translate("misc:NOUNS:CREDITS:2"), message.translate("misc:NOUNS:CREDITS:5"))}`, horse: horse }); @@ -87,7 +86,7 @@ class Horserace extends Command { for (let i = 0; i < 5; i++) { if (thisGame.horseSpeeds[i] >= Math.random() * 15) { horsePositions[i] += 1; - if (horsePositions[i] == 3) { + if (horsePositions[i] === 3) { const winnings = []; const profit = Math.floor((((8.9 / 9) * (10 - thisGame.horseSpeeds[i])) + 1.1) * 10) / 10; @@ -99,6 +98,20 @@ class Horserace extends Command { } if (winnings.length === 0) { + for (let j = 0; j < Object.keys(thisGame.bets).length; j++) { + if (Object.values(thisGame.bets)[j].horse !== i + 1) { + const info = { + user: message.translate("economy/transactions:HORSERACE"), + amount: Object.values(thisGame.bets)[j].amount, + date: Date.now(), + type: "got" + }; + + data.memberData.transactions.push(info); + data.memberData.money -= Object.values(thisGame.bets)[j].amount; + } + } + message.sendT("fun/horserace:NO_WINNERS", { horse: i + 1 }); @@ -119,8 +132,7 @@ class Horserace extends Command { type: "got" }; - data.memberData.transactions.push(info); - + memberData.transactions.push(info); memberData.money += Math.floor(winnings[j][1]); memberData.save(); }