mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-26 14:19:11 +02:00
Fix
This commit is contained in:
+26
-24
@@ -75,6 +75,7 @@ module.exports = class PokerCommand extends Command {
|
|||||||
smallBlind.currentBet += smallBlindAmount;
|
smallBlind.currentBet += smallBlindAmount;
|
||||||
rotation.push(rotation[0]);
|
rotation.push(rotation[0]);
|
||||||
rotation.shift();
|
rotation.shift();
|
||||||
|
const folded = [];
|
||||||
await msg.say('Dealing player hands...');
|
await msg.say('Dealing player hands...');
|
||||||
for (const player of players.values()) {
|
for (const player of players.values()) {
|
||||||
player.hand.push(...deck.draw(2));
|
player.hand.push(...deck.draw(2));
|
||||||
@@ -96,7 +97,7 @@ module.exports = class PokerCommand extends Command {
|
|||||||
turnData.highestBetter = bigBlind;
|
turnData.highestBetter = bigBlind;
|
||||||
let turnOver = false;
|
let turnOver = false;
|
||||||
let turnRotation = this.makeTurnRotation(players, bigBlind, smallBlind);
|
let turnRotation = this.makeTurnRotation(players, bigBlind, smallBlind);
|
||||||
while (!turnOver) turnOver = await this.bettingRound(msg, players, turnRotation, turnData);
|
while (!turnOver) turnOver = await this.bettingRound(msg, players, turnRotation, folded, turnData);
|
||||||
if (turnRotation.length === 1) {
|
if (turnRotation.length === 1) {
|
||||||
const remainer = players.get(turnRotation[0]);
|
const remainer = players.get(turnRotation[0]);
|
||||||
await msg.say(`${remainer.user} takes the pot.`);
|
await msg.say(`${remainer.user} takes the pot.`);
|
||||||
@@ -114,7 +115,25 @@ module.exports = class PokerCommand extends Command {
|
|||||||
await delay(5000);
|
await delay(5000);
|
||||||
turnOver = false;
|
turnOver = false;
|
||||||
turnRotation = this.makeTurnRotation(players, bigBlind, smallBlind);
|
turnRotation = this.makeTurnRotation(players, bigBlind, smallBlind);
|
||||||
while (!turnOver) turnOver = await this.bettingRound(msg, players, turnRotation, turnData);
|
while (!turnOver) turnOver = await this.bettingRound(msg, players, turnRotation, folded, turnData);
|
||||||
|
if (turnRotation.length === 1) {
|
||||||
|
const remainer = players.get(turnRotation[0]);
|
||||||
|
await msg.say(`${remainer.user} takes the pot.`);
|
||||||
|
remainer.money += turnData.pot;
|
||||||
|
await this.resetGame(msg, players);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
dealerHand.push(deck.draw());
|
||||||
|
await msg.say(stripIndents`
|
||||||
|
**Dealer Hand:**
|
||||||
|
${dealerHand.map(card => card.textDisplay).join('\n')}
|
||||||
|
|
||||||
|
_Next betting round begins in 5 seconds._
|
||||||
|
`);
|
||||||
|
await delay(5000);
|
||||||
|
turnOver = false;
|
||||||
|
turnRotation = this.makeTurnRotation(players, folded, bigBlind, smallBlind);
|
||||||
|
while (!turnOver) turnOver = await this.bettingRound(msg, players, turnRotation, folded, turnData);
|
||||||
if (turnRotation.length === 1) {
|
if (turnRotation.length === 1) {
|
||||||
const remainer = players.get(turnRotation[0]);
|
const remainer = players.get(turnRotation[0]);
|
||||||
await msg.say(`${remainer.user} takes the pot.`);
|
await msg.say(`${remainer.user} takes the pot.`);
|
||||||
@@ -132,25 +151,7 @@ module.exports = class PokerCommand extends Command {
|
|||||||
await delay(5000);
|
await delay(5000);
|
||||||
turnOver = false;
|
turnOver = false;
|
||||||
turnRotation = this.makeTurnRotation(players, bigBlind, smallBlind);
|
turnRotation = this.makeTurnRotation(players, bigBlind, smallBlind);
|
||||||
while (!turnOver) turnOver = await this.bettingRound(msg, players, turnRotation, turnData);
|
while (!turnOver) turnOver = await this.bettingRound(msg, players, turnRotation, folded, turnData);
|
||||||
if (turnRotation.length === 1) {
|
|
||||||
const remainer = players.get(turnRotation[0]);
|
|
||||||
await msg.say(`${remainer.user} takes the pot.`);
|
|
||||||
remainer.money += turnData.pot;
|
|
||||||
await this.resetGame(msg, players);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
dealerHand.push(deck.draw());
|
|
||||||
await msg.say(stripIndents`
|
|
||||||
**Dealer Hand:**
|
|
||||||
${dealerHand.map(card => card.textDisplay).join('\n')}
|
|
||||||
|
|
||||||
_Next betting round begins in 5 seconds._
|
|
||||||
`);
|
|
||||||
await delay(5000);
|
|
||||||
turnOver = false;
|
|
||||||
turnRotation = this.makeTurnRotation(players, bigBlind, smallBlind);
|
|
||||||
while (!turnOver) turnOver = await this.bettingRound(msg, players, turnRotation, turnData);
|
|
||||||
if (turnRotation.length === 1) {
|
if (turnRotation.length === 1) {
|
||||||
const remainer = players.get(turnRotation[0]);
|
const remainer = players.get(turnRotation[0]);
|
||||||
await msg.say(`${remainer.user} takes the pot.`);
|
await msg.say(`${remainer.user} takes the pot.`);
|
||||||
@@ -221,15 +222,15 @@ module.exports = class PokerCommand extends Command {
|
|||||||
return actions;
|
return actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
makeTurnRotation(players, bigBlind, smallBlind) {
|
makeTurnRotation(players, folded, bigBlind, smallBlind) {
|
||||||
return [
|
return [
|
||||||
smallBlind.id,
|
smallBlind.id,
|
||||||
...players.filter(p => bigBlind.id !== p.id && smallBlind.id !== p.id).map(p => p.id),
|
...players.filter(p => bigBlind.id !== p.id && smallBlind.id !== p.id).map(p => p.id),
|
||||||
bigBlind.id
|
bigBlind.id
|
||||||
];
|
].filter(player => !folded.includes(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
async bettingRound(msg, players, turnRotation, data) {
|
async bettingRound(msg, players, turnRotation, folded, data) {
|
||||||
const oldHighestBetter = data.highestBetter;
|
const oldHighestBetter = data.highestBetter;
|
||||||
const turnPlayer = players.get(turnRotation[0]);
|
const turnPlayer = players.get(turnRotation[0]);
|
||||||
const actions = this.determineActions(turnPlayer, data.currentBet);
|
const actions = this.determineActions(turnPlayer, data.currentBet);
|
||||||
@@ -281,6 +282,7 @@ module.exports = class PokerCommand extends Command {
|
|||||||
data.pot += amountChange;
|
data.pot += amountChange;
|
||||||
await msg.say(`${turnPlayer.user} **calls $${formatNumber(data.currentBet)}**.`);
|
await msg.say(`${turnPlayer.user} **calls $${formatNumber(data.currentBet)}**.`);
|
||||||
} else if (choiceAction === 'fold') {
|
} else if (choiceAction === 'fold') {
|
||||||
|
folded.push(turnPlayer.id);
|
||||||
await msg.say(`${turnPlayer.user} **folds**.`);
|
await msg.say(`${turnPlayer.user} **folds**.`);
|
||||||
} else if (choiceAction === 'check') {
|
} else if (choiceAction === 'check') {
|
||||||
await msg.say(`${turnPlayer.user} **checks**.`);
|
await msg.say(`${turnPlayer.user} **checks**.`);
|
||||||
|
|||||||
Reference in New Issue
Block a user