From 8ccdfa8e6ebd7574c1d9050db8a129f3c7ba51d2 Mon Sep 17 00:00:00 2001 From: claudijo Date: Sat, 4 May 2024 00:13:10 +0300 Subject: [PATCH] fixes #7; Handle case when big blind has just enough chips to cover the blind --- dist/lib/dealer.js | 25 +++++++++------- dist/lib/dealer.js.map | 2 +- src/lib/dealer.ts | 26 ++++++++++------- test/lib/dealer.spec.ts | 64 +++++++++++++++++++++++++++++++++++------ 4 files changed, 86 insertions(+), 31 deletions(-) diff --git a/dist/lib/dealer.js b/dist/lib/dealer.js index 894496f..f51d9e3 100644 --- a/dist/lib/dealer.js +++ b/dist/lib/dealer.js @@ -138,13 +138,17 @@ var Dealer = /** @class */ (function () { assert_1.default(player !== null); if (this._bettingRound.biggestBet() - player.betSize() === 0) { actionRange.action |= Action.CHECK; - assert_1.default(actions.canRaise); // If you can check, you can always bet or raise. - // If this guy can check, with his existing bet_size, he is the big blind. - if (player.betSize() > 0) { - actionRange.action |= Action.RAISE; - } - else { - actionRange.action |= Action.BET; + // Typically you can always bet or raise if you can check. Exception is if you are the big blind and have no + // chips left after the blind has been paid, in which case you should be allowed to check but not bet or + // raise. + if (actions.canRaise) { + // If this guy can check, with his existing bet_size, he is the big blind. + if (player.betSize() > 0) { + actionRange.action |= Action.RAISE; + } + else { + actionRange.action |= Action.BET; + } } } else { @@ -173,9 +177,10 @@ var Dealer = /** @class */ (function () { this._roundOfBetting = community_cards_1.RoundOfBetting.PREFLOP; this._winners = []; this.collectAnte(); - var firstAction = this.nextOrWrap(this.postBlinds()); + var bigBlindSeat = this.postBlinds(); + var firstAction = this.nextOrWrap(bigBlindSeat); this.dealHoleCards(); - if (this._players.filter(function (player) { return player !== null && player.stack() !== 0; }).length > 1) { + if (this._players.filter(function (player, seat) { return player !== null && (player.stack() !== 0 || seat === bigBlindSeat); }).length > 1) { this._bettingRound = new betting_round_1.default(__spreadArray([], this._players), firstAction, this._forcedBets.blinds.big, this._forcedBets.blinds.big); } this._handInProgress = true; @@ -223,7 +228,7 @@ var Dealer = /** @class */ (function () { this._players = (_d = (_c = this._bettingRound) === null || _c === void 0 ? void 0 : _c.players()) !== null && _d !== void 0 ? _d : []; this._bettingRound = new betting_round_1.default(__spreadArray([], this._players), this.nextOrWrap(this._button), this._forcedBets.blinds.big); this.dealCommunityCards(); - assert_1.default(this._bettingRoundsCompleted === false); + assert_1.default(!this._bettingRoundsCompleted); } else { assert_1.default(this._roundOfBetting === community_cards_1.RoundOfBetting.RIVER); diff --git a/dist/lib/dealer.js.map b/dist/lib/dealer.js.map index f617310..8a0a021 100644 --- a/dist/lib/dealer.js.map +++ b/dist/lib/dealer.js.map @@ -1 +1 @@ -{"version":3,"file":"dealer.js","sourceRoot":"","sources":["../../src/lib/dealer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,qDAAwE;AACxE,+DAA4E;AAE5E,8DAAsC;AACtC,kDAA2B;AAE3B,gDAA0C;AAC1C,uCAA6D;AAG7D;IAII,qBAAY,SAAqB;QAHjC,WAAM,GAAW,MAAM,CAAC,IAAI,CAAA,CAAC,sBAAsB;QAI/C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC9B,CAAC;IAED,8BAAQ,GAAR,UAAS,MAAc,EAAE,GAAc;;QAAd,oBAAA,EAAA,OAAc;QACnC,gBAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,yCAAyC,CAAC,CAAA;QACzE,OAAO,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC;YACxC,CAAC,CAAC,MAAA,MAAA,IAAI,CAAC,SAAS,0CAAE,QAAQ,CAAC,GAAG,CAAC,mCAAI,KAAK;YACxC,CAAC,CAAC,IAAI,CAAA;IACd,CAAC;IACL,kBAAC;AAAD,CAAC,AAdD,IAcC;AAdY,kCAAW;AAgBxB,IAAY,MAMX;AAND,WAAY,MAAM;IACd,mCAAa,CAAA;IACb,qCAAc,CAAA;IACd,mCAAa,CAAA;IACb,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AG,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC,CAAA;QAC1E,OAAO,IAAI,CAAA;IACf,CAAC;IAEO,8BAAa,GAArB;QAAA,iBAMC;QALG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAC,MAAM,EAAE,KAAK;YAChC,IAAI,MAAM,KAAK,IAAI,EAAE;gBACjB,KAAI,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,KAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,KAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAA;aAClE;QACL,CAAC,CAAC,CAAA;IACN,CAAC;IAED,+DAA+D;IACvD,mCAAkB,GAA1B;QACI,IAAM,KAAK,GAAW,EAAE,CAAA;QACxB,IAAM,cAAc,GAAG,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC,MAAM,CAAA;QACjF,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,cAAc,EAAE,KAAK,EAAE,EAAE;YACjD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAA;SAChC;QACD,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACpC,CAAC;IACL,aAAC;AAAD,CAAC,AAnUD,IAmUC"} \ No newline at end of file diff --git a/src/lib/dealer.ts b/src/lib/dealer.ts index fabb726..dad57a2 100644 --- a/src/lib/dealer.ts +++ b/src/lib/dealer.ts @@ -10,7 +10,7 @@ import { HoleCards } from 'types/hole-cards' import PotManager from './pot-manager' import assert from 'assert' import Pot from './pot' -import Hand, { HandRanking } from './hand' +import Hand from './hand' import { findIndexAdjacent, nextOrWrap } from '../util/array' import Card from './card' @@ -135,13 +135,16 @@ export default class Dealer { assert(player !== null) if (this._bettingRound.biggestBet() - player.betSize() === 0) { actionRange.action |= Action.CHECK - assert(actions.canRaise) // If you can check, you can always bet or raise. - - // If this guy can check, with his existing bet_size, he is the big blind. - if (player.betSize() > 0) { - actionRange.action |= Action.RAISE - } else { - actionRange.action |= Action.BET + // Typically you can always bet or raise if you can check. Exception is if you are the big blind and have no + // chips left after the blind has been paid, in which case you should be allowed to check but not bet or + // raise. + if (actions.canRaise) { + // If this guy can check, with his existing bet_size, he is the big blind. + if (player.betSize() > 0) { + actionRange.action |= Action.RAISE + } else { + actionRange.action |= Action.BET + } } } else { actionRange.action |= Action.CALL @@ -175,9 +178,10 @@ export default class Dealer { this._roundOfBetting = RoundOfBetting.PREFLOP this._winners = [] this.collectAnte() - const firstAction = this.nextOrWrap(this.postBlinds()) + const bigBlindSeat = this.postBlinds() + const firstAction = this.nextOrWrap(bigBlindSeat) this.dealHoleCards() - if (this._players.filter(player => player !== null && player.stack() !== 0).length > 1) { + if (this._players.filter((player, seat) => player !== null && (player.stack() !== 0 || seat === bigBlindSeat)).length > 1) { this._bettingRound = new BettingRound([...this._players], firstAction, this._forcedBets.blinds.big, this._forcedBets.blinds.big) } this._handInProgress = true @@ -224,7 +228,7 @@ export default class Dealer { this._players = this._bettingRound?.players() ?? [] this._bettingRound = new BettingRound([...this._players], this.nextOrWrap(this._button), this._forcedBets.blinds.big) this.dealCommunityCards() - assert(this._bettingRoundsCompleted === false) + assert(!this._bettingRoundsCompleted) } else { assert(this._roundOfBetting === RoundOfBetting.RIVER) this._bettingRoundsCompleted = true diff --git a/test/lib/dealer.spec.ts b/test/lib/dealer.spec.ts index 3a9ab7f..74f5bf6 100644 --- a/test/lib/dealer.spec.ts +++ b/test/lib/dealer.spec.ts @@ -1,16 +1,16 @@ -import Dealer, { Action } from '../../src/lib/dealer' -import { ForcedBets } from '../../src/types/forced-bets' +import Dealer, {Action} from '../../src/lib/dealer' +import {ForcedBets} from '../../src/types/forced-bets' import Deck from '../../src/lib/deck' -import CommunityCards, { RoundOfBetting } from '../../src/lib/community-cards' -import { SeatArray } from '../../src/types/seat-array' +import CommunityCards, {RoundOfBetting} from '../../src/lib/community-cards' +import {SeatArray} from '../../src/types/seat-array' import Player from '../../src/lib/player' -import Card, { CardRank, CardSuit } from '../../src/lib/card' +import Card, {CardRank, CardSuit} from '../../src/lib/card' import { shuffleForThreePlayersWithTwoWinners, - shuffleForTwoPlayersWithFullHouseWinner, shuffleForTwoPlayersDraw, + shuffleForTwoPlayersWithFullHouseWinner, } from '../helper/card' -import { HandRanking } from '../../src/lib/hand' +import {HandRanking} from '../../src/lib/hand' describe('Dealer', () => { describe('Starting the hand', () => { @@ -20,11 +20,57 @@ describe('Dealer', () => { beforeEach(() => { forcedBets = { blinds: { big: 50, small: 25 } } - deck = new Deck() + // tslint:disable-next-line:no-empty + deck = new Deck(() => {}) communityCards = new CommunityCards() }) - describe('Given: A hand with two players who can cover their blinds', () => { + describe('A hand with with two players where the big blind has just enough to cover the blind', () => { + let players: SeatArray + let dealer: Dealer + + beforeEach(() => { + players = new Array(9).fill(null) + players[0] = new Player(100) + players[1] = new Player(50) + dealer = new Dealer(players, 0, forcedBets, deck, communityCards) + + dealer.startHand() + }) + + test('Betting round should be in progress', () => { + expect(dealer.bettingRoundInProgress()).toBeTruthy() + }) + + test('Small blind should be allowed to fold, call, or raise', () => { + const { action } = dealer.legalActions() + expect(action & Action.FOLD).toBeTruthy() + expect(action & Action.CHECK).toBeFalsy() + expect(action & Action.CALL).toBeTruthy() + expect(action & Action.BET).toBeFalsy() + expect(action & Action.RAISE).toBeTruthy() + }) + + test('Betting round should still be in progress after small blind calls and big blind should be allowed to fold or check', () => { + dealer.actionTaken(Action.CALL) + + const { action } = dealer.legalActions() + expect(action & Action.FOLD).toBeTruthy() + expect(action & Action.CHECK).toBeTruthy() + expect(action & Action.CALL).toBeFalsy() + expect(action & Action.BET).toBeFalsy() + expect(action & Action.RAISE).toBeFalsy() + }) + + test('Betting round and should not be in progress after small blind calls and big blind checks', () => { + dealer.actionTaken(Action.CALL) + dealer.actionTaken(Action.CHECK) + + expect(dealer.bettingRoundInProgress()).toBeFalsy() + }) + }) + + describe('A hand with two players who can cover their blinds', () => { let players: SeatArray let dealer: Dealer beforeEach(() => {