@block52/poker-vm-sdk 1.2.16 → 1.2.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -57319,6 +57319,109 @@ Deck.SUIT_MAP = {
57319
57319
  [exports.SUIT.SPADES]: "S"
57320
57320
  };
57321
57321
 
57322
+ /**
57323
+ * The community board for a Texas Hold'em hand.
57324
+ *
57325
+ * Encapsulates the two community-card arrays the engine currently keeps — the
57326
+ * cards dealt street-by-street (`street`, persisted to the DTO) and the five
57327
+ * pre-dealt up front at `deal()` (`preDealt`) — behind one type. This is a pure
57328
+ * refactor: every accessor returns exactly what the inline engine logic did, so
57329
+ * behaviour is unchanged. Collapsing the two arrays into a single canonical
57330
+ * board is a separate, consensus-affecting change (issue #2299).
57331
+ */
57332
+ class Board {
57333
+ constructor() {
57334
+ // Dealt one street at a time via dealCommunityCards() (was `_communityCards`).
57335
+ // This is the board persisted to the game DTO and rehydrated from JSON.
57336
+ this.street = [];
57337
+ // All five dealt up front at deal() (was `_communityCards2`).
57338
+ this.preDealt = [];
57339
+ }
57340
+ /**
57341
+ * Append cards dealt for the current street (was `_communityCards.push`).
57342
+ */
57343
+ addStreet(cards) {
57344
+ this.street.push(...cards);
57345
+ }
57346
+ /**
57347
+ * Record the five cards pre-dealt at deal() (was `_communityCards2.push`).
57348
+ */
57349
+ setPreDealt(cards) {
57350
+ this.preDealt.push(...cards);
57351
+ }
57352
+ /**
57353
+ * Number of street-dealt cards (was `_communityCards.length`).
57354
+ */
57355
+ get streetLength() {
57356
+ return this.street.length;
57357
+ }
57358
+ /**
57359
+ * Number of pre-dealt cards (was `_communityCards2.length`).
57360
+ */
57361
+ get preDealtLength() {
57362
+ return this.preDealt.length;
57363
+ }
57364
+ /**
57365
+ * The street-dealt community cards (was `[...this._communityCards]`).
57366
+ */
57367
+ get cards() {
57368
+ return [...this.street];
57369
+ }
57370
+ /**
57371
+ * The community cards visible at a given round, taken from the pre-dealt
57372
+ * board — matching the previous `getCommunityCards()` exactly:
57373
+ * FLOP -> preDealt[0..3], TURN -> preDealt[0..4], RIVER -> preDealt[0..5].
57374
+ */
57375
+ forRound(round) {
57376
+ const cards = [];
57377
+ if (round === exports.TexasHoldemRound.FLOP) {
57378
+ cards.push(...this.preDealt.slice(0, 3));
57379
+ }
57380
+ if (round === exports.TexasHoldemRound.TURN) {
57381
+ cards.push(...this.preDealt.slice(0, 4));
57382
+ }
57383
+ if (round === exports.TexasHoldemRound.RIVER) {
57384
+ cards.push(...this.preDealt.slice(0, 5));
57385
+ }
57386
+ return cards;
57387
+ }
57388
+ /**
57389
+ * The board `findWinners` falls back to when `forRound` is short: the
57390
+ * pre-dealt board for live games, else the street board rehydrated from JSON.
57391
+ * Preserves the previous inline selection verbatim.
57392
+ */
57393
+ forEvaluation(count) {
57394
+ return this.preDealt.length >= count
57395
+ ? this.preDealt.slice(0, count)
57396
+ : this.street.slice(0, count);
57397
+ }
57398
+ /**
57399
+ * The board `calculateWinner` falls back to at an early showdown: the fully
57400
+ * dealt street board if available, else the pre-dealt board. Preserves the
57401
+ * previous inline selection verbatim.
57402
+ */
57403
+ forShowdown() {
57404
+ return this.street.length >= Board.MAX_COMMUNITY_CARDS
57405
+ ? this.street.slice(0, Board.MAX_COMMUNITY_CARDS)
57406
+ : this.preDealt.slice(0, Board.MAX_COMMUNITY_CARDS);
57407
+ }
57408
+ /**
57409
+ * Clear both boards for a new hand (was two `.length = 0` assignments).
57410
+ */
57411
+ clear() {
57412
+ this.street.length = 0;
57413
+ this.preDealt.length = 0;
57414
+ }
57415
+ /**
57416
+ * Serialize the street board to mnemonics, matching
57417
+ * `TexasHoldemStateDTO.communityCards` (was `_communityCards.map(...)`).
57418
+ */
57419
+ toJson() {
57420
+ return this.street.map(card => card.mnemonic);
57421
+ }
57422
+ }
57423
+ Board.MAX_COMMUNITY_CARDS = 5;
57424
+
57322
57425
  /**
57323
57426
  * Example integration of custom poker solver with game engine
57324
57427
  * Demonstrates how to replace pokersolver with our custom implementation
@@ -61865,6 +61968,7 @@ const registry = new protoSigning.Registry([
61865
61968
 
61866
61969
  exports.AllPlayerActions = AllPlayerActions;
61867
61970
  exports.BLOCK52_HD_PATH = BLOCK52_HD_PATH;
61971
+ exports.Board = Board;
61868
61972
  exports.COSMOS_CONSTANTS = COSMOS_CONSTANTS;
61869
61973
  exports.Client = Client;
61870
61974
  exports.CosmosClient = CosmosClient;