Fix/Testing

This commit is contained in:
Dragon Fire
2020-11-22 11:16:29 -05:00
parent 608195ab5d
commit 63192b4960
2 changed files with 13 additions and 3 deletions
+7 -3
View File
@@ -3,7 +3,7 @@ const Collection = require('@discordjs/collection');
const { Hand } = require('pokersolver'); const { Hand } = require('pokersolver');
const { stripIndents } = require('common-tags'); const { stripIndents } = require('common-tags');
const Deck = require('../../structures/cards/Deck'); const Deck = require('../../structures/cards/Deck');
const { formatNumber, list, delay, awaitPlayers } = require('../../util/Util'); const { formatNumber, list, delay, removeFromArray, awaitPlayers } = require('../../util/Util');
const max = 6; const max = 6;
const min = 2; const min = 2;
const bigBlindAmount = 100; const bigBlindAmount = 100;
@@ -65,7 +65,7 @@ module.exports = class PokerCommand extends Command {
}); });
} }
let winner = null; let winner = null;
const rotation = players.map(p => p.id); let rotation = players.map(p => p.id);
while (!winner) { while (!winner) {
const bigBlind = players.get(rotation[1]); const bigBlind = players.get(rotation[1]);
bigBlind.money -= bigBlindAmount; bigBlind.money -= bigBlindAmount;
@@ -165,7 +165,11 @@ module.exports = class PokerCommand extends Command {
winners[0].user.money += turnData.pot; winners[0].user.money += turnData.pot;
} }
await this.resetGame(msg, players, deck); await this.resetGame(msg, players, deck);
if (players.size <= 1) { for (const playerID of rotation) {
if (!players.has(playerID)) removeFromArray(rotation, playerID);
}
console.log(players.size);
if (players.size < 2) {
winner = players.first(); winner = players.first();
break; break;
} }
+6
View File
@@ -48,6 +48,12 @@ module.exports = class Util {
return arr; return arr;
} }
static removeFromArray(arr, value) {
const index = arr.indexOf(value);
if (index > -1) return arr.splice(index, 1);
return arr;
}
static removeDuplicates(arr) { static removeDuplicates(arr) {
if (arr.length === 0 || arr.length === 1) return arr; if (arr.length === 0 || arr.length === 1) return arr;
const newArr = []; const newArr = [];