@block52/poker-vm-sdk 1.23.0 → 1.24.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
@@ -56170,7 +56170,7 @@ exports.NonPlayerActionType = void 0;
56170
56170
  NonPlayerActionType["TIMEOUT"] = "timeout";
56171
56171
  // Time bank (ui#19/#20): the player to act extends their turn's action-clock
56172
56172
  // deadline by their whole bank, once per decision: gameOptions.timeBankMs
56173
- // the first time, 30s the second, then empty, refilling 5s per orbit up to
56173
+ // the first time, 30s the second, then 5s refilling 5s per orbit up to
56174
56174
  // gameOptions.timeBankCapMs. Records a no-chip turn that does NOT advance the
56175
56175
  // betting order or move the clock anchor; the deadline adds the user's
56176
56176
  // PlayerDTO.timeBankLastGrantMs for the current turn. Rejected off-turn,
@@ -71851,35 +71851,43 @@ function gaslessFee(gasLimit = DEFAULT_GAS_LIMIT) {
71851
71851
  };
71852
71852
  }
71853
71853
  /**
71854
- * Fail fast on a sit-and-go field the chain would refuse (poker-vm#2680):
71855
- * seats 2..9, min <= max, and a flexible field (min < max) needs a scheduled
71856
- * start in the future. Mirrors x/poker/keeper/msg_server_create_game.go.
71854
+ * Fail fast on a sit-and-go or tournament the chain would refuse. Both have seats
71855
+ * 2..9 and min <= max. A sit-and-go starts when the table fills, so its field is
71856
+ * fixed and it has no start time. A tournament needs a start time in the future
71857
+ * (poker-vm#2776). Mirrors x/poker/keeper/msg_server_create_game.go.
71857
71858
  */
71858
- function assertCreatableSngField(minPlayers, maxPlayers, sngConfig, nowSeconds = Math.floor(Date.now() / 1000)) {
71859
+ function assertCreatableSngField(gameFormat, minPlayers, maxPlayers, sngConfig, nowSeconds = Math.floor(Date.now() / 1000)) {
71859
71860
  if (maxPlayers < 2 || maxPlayers > 9) {
71860
- throw new Error(`sit-and-go maxPlayers must be 2..9; got ${maxPlayers}.`);
71861
+ throw new Error(`${gameFormat} maxPlayers must be 2..9; got ${maxPlayers}.`);
71861
71862
  }
71862
71863
  if (minPlayers < 2 || minPlayers > maxPlayers) {
71863
- throw new Error(`sit-and-go minPlayers must be 2..maxPlayers (${maxPlayers}); got ${minPlayers}.`);
71864
+ throw new Error(`${gameFormat} minPlayers must be 2..maxPlayers (${maxPlayers}); got ${minPlayers}.`);
71864
71865
  }
71865
71866
  const startTime = sngConfig?.startTime;
71866
- if (minPlayers !== maxPlayers && !startTime) {
71867
- throw new Error("sit-and-go with minPlayers < maxPlayers needs sngConfig.startTime (a scheduled start).");
71868
- }
71869
- if (startTime !== undefined && startTime <= nowSeconds) {
71870
- throw new Error(`sngConfig.startTime ${startTime} must be in the future (now ${nowSeconds}).`);
71871
- }
71872
71867
  const levels = sngConfig?.lateRegistrationLevels;
71873
- if (levels !== undefined) {
71874
- if (!Number.isInteger(levels) || levels <= 0) {
71875
- throw new Error(`sngConfig.lateRegistrationLevels must be a positive whole number of levels; got ${levels}.`);
71876
- }
71868
+ if (levels !== undefined && (!Number.isInteger(levels) || levels <= 0)) {
71869
+ throw new Error(`sngConfig.lateRegistrationLevels must be a positive whole number of levels; got ${levels}.`);
71870
+ }
71871
+ if (gameFormat === exports.GameFormat.TOURNAMENT) {
71877
71872
  if (!startTime) {
71878
- throw new Error("sngConfig.lateRegistrationLevels needs sngConfig.startTime (late registration is for a scheduled sit-and-go).");
71873
+ throw new Error("tournament needs sngConfig.startTime.");
71874
+ }
71875
+ if (startTime <= nowSeconds) {
71876
+ throw new Error(`sngConfig.startTime ${startTime} must be in the future (now ${nowSeconds}).`);
71879
71877
  }
71878
+ return;
71879
+ }
71880
+ if (minPlayers !== maxPlayers) {
71881
+ throw new Error("sit-and-go needs minPlayers == maxPlayers (it starts when the table fills); a flexible field is a tournament.");
71882
+ }
71883
+ if (startTime) {
71884
+ throw new Error("sngConfig.startTime is only valid for a tournament.");
71885
+ }
71886
+ if (levels !== undefined) {
71887
+ throw new Error("sngConfig.lateRegistrationLevels is only valid for a tournament.");
71880
71888
  }
71881
- if (sngConfig?.waitForStartTime && !startTime) {
71882
- throw new Error("sngConfig.waitForStartTime needs sngConfig.startTime (it holds a scheduled sit-and-go until its start time).");
71889
+ if (sngConfig?.waitForStartTime) {
71890
+ throw new Error("sngConfig.waitForStartTime is only valid for a tournament.");
71883
71891
  }
71884
71892
  }
71885
71893
  /**
@@ -72014,7 +72022,7 @@ class SigningCosmosClient extends CosmosClient {
72014
72022
  if (!sngConfig.blindStructure && (!sngConfig.blindLevelDuration || sngConfig.blindLevelDuration <= 0)) {
72015
72023
  throw new Error(`${gameFormat} games require a positive blindLevelDuration (or a blindStructure); got ${sngConfig.blindLevelDuration}.`);
72016
72024
  }
72017
- assertCreatableSngField(minPlayers, maxPlayers, sngConfig);
72025
+ assertCreatableSngField(gameFormat, minPlayers, maxPlayers, sngConfig);
72018
72026
  }
72019
72027
  assertCreatableBettingLimit(bettingLimit, gameVariant);
72020
72028
  await this.initializeSigningClient();