@block52/poker-vm-sdk 1.12.1 → 1.14.0

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
@@ -2850,6 +2850,7 @@ function createBaseMsgCreateGame() {
2850
2850
  bettingLimit: "",
2851
2851
  startTime: Long.ZERO,
2852
2852
  blindStructure: "",
2853
+ lateRegistrationLevels: 0,
2853
2854
  };
2854
2855
  }
2855
2856
  const MsgCreateGame = {
@@ -2917,6 +2918,9 @@ const MsgCreateGame = {
2917
2918
  if (message.blindStructure !== "") {
2918
2919
  writer.uint32(178).string(message.blindStructure);
2919
2920
  }
2921
+ if (message.lateRegistrationLevels !== 0) {
2922
+ writer.uint32(184).uint32(message.lateRegistrationLevels);
2923
+ }
2920
2924
  return writer;
2921
2925
  },
2922
2926
  decode(input, length) {
@@ -3073,6 +3077,13 @@ const MsgCreateGame = {
3073
3077
  message.blindStructure = reader.string();
3074
3078
  continue;
3075
3079
  }
3080
+ case 23: {
3081
+ if (tag !== 184) {
3082
+ break;
3083
+ }
3084
+ message.lateRegistrationLevels = reader.uint32();
3085
+ continue;
3086
+ }
3076
3087
  }
3077
3088
  if ((tag & 7) === 4 || tag === 0) {
3078
3089
  break;
@@ -3104,6 +3115,7 @@ const MsgCreateGame = {
3104
3115
  bettingLimit: isSet$2b(object.bettingLimit) ? globalThis.String(object.bettingLimit) : "",
3105
3116
  startTime: isSet$2b(object.startTime) ? Long.fromValue(object.startTime) : Long.ZERO,
3106
3117
  blindStructure: isSet$2b(object.blindStructure) ? globalThis.String(object.blindStructure) : "",
3118
+ lateRegistrationLevels: isSet$2b(object.lateRegistrationLevels) ? globalThis.Number(object.lateRegistrationLevels) : 0,
3107
3119
  };
3108
3120
  },
3109
3121
  toJSON(message) {
@@ -3171,6 +3183,9 @@ const MsgCreateGame = {
3171
3183
  if (message.blindStructure !== "") {
3172
3184
  obj.blindStructure = message.blindStructure;
3173
3185
  }
3186
+ if (message.lateRegistrationLevels !== 0) {
3187
+ obj.lateRegistrationLevels = Math.round(message.lateRegistrationLevels);
3188
+ }
3174
3189
  return obj;
3175
3190
  },
3176
3191
  create(base) {
@@ -3220,6 +3235,7 @@ const MsgCreateGame = {
3220
3235
  ? Long.fromValue(object.startTime)
3221
3236
  : Long.ZERO;
3222
3237
  message.blindStructure = object.blindStructure ?? "";
3238
+ message.lateRegistrationLevels = object.lateRegistrationLevels ?? 0;
3223
3239
  message.entryFee = (object.entryFee !== undefined && object.entryFee !== null)
3224
3240
  ? Long.fromValue(object.entryFee)
3225
3241
  : Long.UZERO;
@@ -56096,6 +56112,11 @@ exports.PlayerActionType = void 0;
56096
56112
  exports.NonPlayerActionType = void 0;
56097
56113
  (function (NonPlayerActionType) {
56098
56114
  NonPlayerActionType["DEAD_SMALL_BLIND"] = "dead-small-blind";
56115
+ // Big-blind ante on a tournament-directed table (poker-vm#2613 slice 7):
56116
+ // dead money the big blind posts for the table before the blind itself,
56117
+ // from the tournament clock. Engine-recorded, never submitted; in the pot
56118
+ // but not a bet the others must match.
56119
+ NonPlayerActionType["ANTE"] = "ante";
56099
56120
  NonPlayerActionType["DEAL"] = "deal";
56100
56121
  NonPlayerActionType["FORCE_CLOSE"] = "force-close";
56101
56122
  NonPlayerActionType["JOIN"] = "join";
@@ -57064,6 +57085,47 @@ function expandBlindLevel(structure, n) {
57064
57085
  return { level: n, smallBlind: sb.toString(), bigBlind: bb.toString(), ante: ante.toString(), durationMinutes: structure.durationMinutes, isBreak: false };
57065
57086
  }
57066
57087
 
57088
+ /**
57089
+ * Late registration for a scheduled sit-and-go (poker-vm#2731), read the way
57090
+ * the engine decides it: after the start, a join is accepted while the blind
57091
+ * level at block time is below `gameOptions.lateRegistrationLevels`, until
57092
+ * anyone has finished in the money. The blind clock — and so the window —
57093
+ * runs from the first deal (`sngStartTime`).
57094
+ */
57095
+ /** When late registration closes (epoch ms): the end of the last open level.
57096
+ * Undefined when the table has no late registration, or has not dealt yet
57097
+ * (the clock has not started, so the window has no end time). */
57098
+ function lateRegistrationClosesAt(options) {
57099
+ const levels = options.lateRegistrationLevels;
57100
+ if (!levels || options.scheduledStartTime === undefined || options.sngStartTime === undefined) {
57101
+ return undefined;
57102
+ }
57103
+ let minutes = 0;
57104
+ for (let n = 0; n < levels; n++) {
57105
+ minutes += options.blindStructure ? expandBlindLevel(options.blindStructure, n).durationMinutes : levelMinutes(options);
57106
+ }
57107
+ return options.sngStartTime + minutes * 60000;
57108
+ }
57109
+ /** Whether a join after the start would be accepted at nowMs. Before the
57110
+ * first deal the window is open (level 0); it shuts at
57111
+ * lateRegistrationClosesAt, or once any result carries a payout. */
57112
+ function isLateRegistrationOpen(options, results, nowMs) {
57113
+ if (!options.lateRegistrationLevels || options.scheduledStartTime === undefined) {
57114
+ return false;
57115
+ }
57116
+ if (results.some(r => BigInt(r.payout) > 0n)) {
57117
+ return false;
57118
+ }
57119
+ const closesAt = lateRegistrationClosesAt(options);
57120
+ return closesAt === undefined || nowMs < closesAt;
57121
+ }
57122
+ function levelMinutes(options) {
57123
+ if (!options.blindLevelDuration || options.blindLevelDuration <= 0) {
57124
+ throw new Error(`a sit-and-go needs a positive blindLevelDuration or a blindStructure; got ${options.blindLevelDuration}.`);
57125
+ }
57126
+ return options.blindLevelDuration;
57127
+ }
57128
+
57067
57129
  /**
57068
57130
  * Poker hand types in order of strength (weakest to strongest)
57069
57131
  */
@@ -71616,6 +71678,15 @@ function assertCreatableSngField(minPlayers, maxPlayers, sngConfig, nowSeconds =
71616
71678
  if (startTime !== undefined && startTime <= nowSeconds) {
71617
71679
  throw new Error(`sngConfig.startTime ${startTime} must be in the future (now ${nowSeconds}).`);
71618
71680
  }
71681
+ const levels = sngConfig?.lateRegistrationLevels;
71682
+ if (levels !== undefined) {
71683
+ if (!Number.isInteger(levels) || levels <= 0) {
71684
+ throw new Error(`sngConfig.lateRegistrationLevels must be a positive whole number of levels; got ${levels}.`);
71685
+ }
71686
+ if (!startTime) {
71687
+ throw new Error("sngConfig.lateRegistrationLevels needs sngConfig.startTime (late registration is for a scheduled sit-and-go).");
71688
+ }
71689
+ }
71619
71690
  }
71620
71691
  /**
71621
71692
  * Signing Cosmos Client that extends the read-only CosmosClient with transaction capabilities
@@ -71792,6 +71863,7 @@ class SigningCosmosClient extends CosmosClient {
71792
71863
  // Blind structure (block52/pokerchain#434) as JSON; "" = doubling, and
71793
71864
  // an empty proto3 string is not encoded at all.
71794
71865
  blindStructure: sngConfig?.blindStructure ? JSON.stringify(sngConfig.blindStructure) : "",
71866
+ lateRegistrationLevels: sngConfig?.lateRegistrationLevels ?? 0,
71795
71867
  });
71796
71868
  // Create the transaction message
71797
71869
  const msg = {
@@ -71822,7 +71894,8 @@ class SigningCosmosClient extends CosmosClient {
71822
71894
  startingStack: sngConfig.startingStack.toString(),
71823
71895
  blindLevelDuration: sngConfig.blindLevelDuration,
71824
71896
  entryFee: sngConfig.entryFee?.toString() ?? "0",
71825
- ...(sngConfig.blindStructure && { blindStructure: sngConfig.blindStructure })
71897
+ ...(sngConfig.blindStructure && { blindStructure: sngConfig.blindStructure }),
71898
+ ...(sngConfig.lateRegistrationLevels && { lateRegistrationLevels: sngConfig.lateRegistrationLevels })
71826
71899
  })
71827
71900
  });
71828
71901
  try {
@@ -72793,11 +72866,13 @@ exports.hasAction = hasAction;
72793
72866
  exports.holeCardsPerPlayer = holeCardsPerPlayer;
72794
72867
  exports.isCashFormat = isCashFormat;
72795
72868
  exports.isEmptyAddress = isEmptyAddress;
72869
+ exports.isLateRegistrationOpen = isLateRegistrationOpen;
72796
72870
  exports.isPotLimit = isPotLimit;
72797
72871
  exports.isSitAndGoFormat = isSitAndGoFormat;
72798
72872
  exports.isTournamentFormat = isTournamentFormat;
72799
72873
  exports.isValidMnemonic = isValidMnemonic;
72800
72874
  exports.isValidPlayerAddress = isValidPlayerAddress;
72875
+ exports.lateRegistrationClosesAt = lateRegistrationClosesAt;
72801
72876
  exports.parseBlindStructure = parseBlindStructure;
72802
72877
  exports.parseGameFormat = parseGameFormat;
72803
72878
  exports.parseGameVariant = parseGameVariant;