// Whether putting more in is called a bet or a raise. // // The arithmetic was always right — minRaiseTo returns two big blinds for the big // blind's option and one for an opening bet. This is only what it's called, which for // a tool a dealer announces the action from is not a small thing. const test = require("node:test"); const assert = require("node:assert"); const { Betting, makeTable } = require("./load"); // Walks the preflop action round to the big blind, who is owed nothing and gets to // choose between checking and putting more in. function toTheBigBlindsOption() { const state = makeTable({ seatCount: 6, seated: [0, 1, 2, 3], stack: 100, dealerSeatIndex: 0 }); Betting.beginHand(state); const bigBlind = state.seats.findIndex(player => Betting.committed(player) === state.bigBlind); while (state.actingSeatIndex !== null && state.actingSeatIndex !== bigBlind) { Betting.call(state, state.actingSeatIndex); } return { state, bigBlind }; } test("the big blind's option is a raise, not a bet", () => { const { state, bigBlind } = toTheBigBlindsOption(); assert.equal(state.actingSeatIndex, bigBlind); assert.equal(Betting.toCall(state, state.seats[bigBlind]), 0, "they owe nothing"); assert.equal(Betting.wagerVerb(state), "raise", "but their own blind is a live bet"); }); test("and the minimum there is a real raise, not a call of the blind", () => { const { state } = toTheBigBlindsOption(); assert.equal(Betting.minRaiseTo(state), state.bigBlind * 2); }); test("facing the blinds preflop is a raise", () => { const state = makeTable({ seatCount: 6, seated: [0, 1, 2, 3], stack: 100 }); Betting.beginHand(state); assert.equal(Betting.wagerVerb(state), "raise"); }); test("first in on the flop is a bet", () => { const { state, bigBlind } = toTheBigBlindsOption(); Betting.check(state, bigBlind); Betting.closeStreet(state); assert.equal(state.street, "flop"); assert.equal(Betting.wagerVerb(state), "bet"); assert.equal(Betting.minRaiseTo(state), state.bigBlind, "a first bet is one big blind"); }); test("after that bet it's a raise again", () => { const { state, bigBlind } = toTheBigBlindsOption(); Betting.check(state, bigBlind); Betting.closeStreet(state); Betting.raiseTo(state, state.actingSeatIndex, 10); assert.equal(Betting.wagerVerb(state), "raise"); }); test("and a bet again on the next street once it's checked around", () => { const { state, bigBlind } = toTheBigBlindsOption(); Betting.check(state, bigBlind); Betting.closeStreet(state); while (state.actingSeatIndex !== null) Betting.check(state, state.actingSeatIndex); Betting.closeStreet(state); assert.equal(state.street, "turn"); assert.equal(Betting.wagerVerb(state), "bet"); }); test("a table playing without blinds opens with a bet", () => { const state = makeTable({ seatCount: 6, seated: [0, 1, 2], stack: 100, smallBlind: 0, bigBlind: 0 }); Betting.beginHand(state); assert.equal(state.currentBet, 0); assert.equal(Betting.wagerVerb(state), "bet"); }); test("asking doesn't change anything", () => { const { state } = toTheBigBlindsOption(); const before = JSON.stringify(state); Betting.wagerVerb(state); assert.equal(JSON.stringify(state), before); });