@block52/poker-vm-sdk 1.14.0 → 1.16.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.d.ts +22 -6
- package/dist/index.esm.js +53 -18
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +53 -17
- package/dist/index.js.map +1 -1
- package/dist/signingClient.d.ts +5 -3
- package/dist/signingClient.d.ts.map +1 -1
- package/dist/types/game.d.ts +10 -2
- package/dist/types/game.d.ts.map +1 -1
- package/dist/utils/blindStructure.d.ts +6 -0
- package/dist/utils/blindStructure.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -56652,7 +56652,8 @@ const isValidPlayerAddress = (address) => {
|
|
|
56652
56652
|
* start: 25/50
|
|
56653
56653
|
* duration: 5m
|
|
56654
56654
|
* progression: double | linear 25 | percentage 1.5
|
|
56655
|
-
* round: 25 percentage
|
|
56655
|
+
* round: 25 percentage: the engine's roundTo
|
|
56656
|
+
* round: blinds double / linear: round levels of 1,000+ (roundBlinds)
|
|
56656
56657
|
* ante: bb | bb * 0.1 | level >= 4 ? bb * 0.1 : 0
|
|
56657
56658
|
* cap: 15
|
|
56658
56659
|
* }
|
|
@@ -56868,6 +56869,15 @@ function parseTable(body) {
|
|
|
56868
56869
|
out.maxLevel = parseInteger("cap", body.fields.get("cap").join(" "));
|
|
56869
56870
|
return out;
|
|
56870
56871
|
}
|
|
56872
|
+
/** `round: blinds` on double / linear turns on roundBlinds (poker-vm#2738); no other value is accepted there. */
|
|
56873
|
+
function parseRoundBlinds(f) {
|
|
56874
|
+
if (!f.has("round"))
|
|
56875
|
+
return {};
|
|
56876
|
+
const value = f.get("round").join(" ");
|
|
56877
|
+
if (value !== "blinds")
|
|
56878
|
+
fail(`double and linear take "round: blinds" (round levels of 1,000+), got "round: ${value}"`);
|
|
56879
|
+
return { roundBlinds: true };
|
|
56880
|
+
}
|
|
56871
56881
|
function parseAlgorithmic(body) {
|
|
56872
56882
|
const f = body.fields;
|
|
56873
56883
|
for (const key of f.keys()) {
|
|
@@ -56896,16 +56906,16 @@ function parseAlgorithmic(body) {
|
|
|
56896
56906
|
const [kind, ...rest] = f.get("progression");
|
|
56897
56907
|
switch (kind) {
|
|
56898
56908
|
case "double":
|
|
56899
|
-
if (rest.length !== 0
|
|
56900
|
-
fail("double takes no argument
|
|
56901
|
-
return { progression: "double", ...base };
|
|
56909
|
+
if (rest.length !== 0)
|
|
56910
|
+
fail("double takes no argument");
|
|
56911
|
+
return { progression: "double", ...base, ...parseRoundBlinds(f) };
|
|
56902
56912
|
case "linear": {
|
|
56903
|
-
if (rest.length !== 1
|
|
56904
|
-
fail('linear needs one step, e.g. "linear 25"
|
|
56913
|
+
if (rest.length !== 1)
|
|
56914
|
+
fail('linear needs one step, e.g. "linear 25"');
|
|
56905
56915
|
const step = parseAmount("linear step", rest[0]);
|
|
56906
56916
|
if (BigInt(step) <= 0n)
|
|
56907
56917
|
fail("linear step must be positive");
|
|
56908
|
-
return { progression: "linear", ...base, step };
|
|
56918
|
+
return { progression: "linear", ...base, step, ...parseRoundBlinds(f) };
|
|
56909
56919
|
}
|
|
56910
56920
|
case "percentage": {
|
|
56911
56921
|
if (rest.length !== 1)
|
|
@@ -56978,9 +56988,13 @@ function formatBlindStructure(structure, name = "custom") {
|
|
|
56978
56988
|
switch (structure.progression) {
|
|
56979
56989
|
case "double":
|
|
56980
56990
|
lines.push(" progression: double");
|
|
56991
|
+
if (structure.roundBlinds)
|
|
56992
|
+
lines.push(" round: blinds");
|
|
56981
56993
|
break;
|
|
56982
56994
|
case "linear":
|
|
56983
56995
|
lines.push(` progression: linear ${structure.step}`);
|
|
56996
|
+
if (structure.roundBlinds)
|
|
56997
|
+
lines.push(" round: blinds");
|
|
56984
56998
|
break;
|
|
56985
56999
|
case "percentage":
|
|
56986
57000
|
lines.push(` progression: percentage ${formatBps(structure.factorBps)}`);
|
|
@@ -57007,8 +57021,8 @@ function formatBlindStructure(structure, name = "custom") {
|
|
|
57007
57021
|
* levels can be previewed before the table exists.
|
|
57008
57022
|
*/
|
|
57009
57023
|
const BLIND_PRESET_STRUCTURES = {
|
|
57010
|
-
turbo: { progression: "double", startSmallBlind: "25", startBigBlind: "50", durationMinutes: 5, ante: { startLevel: 4, bps: 1000 } },
|
|
57011
|
-
standard: { progression: "double", startSmallBlind: "25", startBigBlind: "50", durationMinutes: 10, ante: { startLevel: 5, bps: 1000 } },
|
|
57024
|
+
turbo: { progression: "double", startSmallBlind: "25", startBigBlind: "50", durationMinutes: 5, roundBlinds: true, ante: { startLevel: 4, bps: 1000 } },
|
|
57025
|
+
standard: { progression: "double", startSmallBlind: "25", startBigBlind: "50", durationMinutes: 10, roundBlinds: true, ante: { startLevel: 5, bps: 1000 } },
|
|
57012
57026
|
deep_stack: {
|
|
57013
57027
|
progression: "percentage",
|
|
57014
57028
|
startSmallBlind: "25",
|
|
@@ -57018,7 +57032,7 @@ const BLIND_PRESET_STRUCTURES = {
|
|
|
57018
57032
|
durationMinutes: 15,
|
|
57019
57033
|
ante: { startLevel: 6, bps: 1250 }
|
|
57020
57034
|
},
|
|
57021
|
-
hyper_turbo: { progression: "double", startSmallBlind: "50", startBigBlind: "100", durationMinutes: 3, ante: { startLevel: 3, bps: 1000 } }
|
|
57035
|
+
hyper_turbo: { progression: "double", startSmallBlind: "50", startBigBlind: "100", durationMinutes: 3, roundBlinds: true, ante: { startLevel: 3, bps: 1000 } }
|
|
57022
57036
|
};
|
|
57023
57037
|
/** Replaces a preset with its concrete structure (a deep copy); anything else is returned as is. */
|
|
57024
57038
|
function resolveBlindPreset(structure) {
|
|
@@ -57029,6 +57043,17 @@ function resolveBlindPreset(structure) {
|
|
|
57029
57043
|
fail(`"${structure.preset}" is not a preset (${BLIND_PRESETS.join(", ")})`);
|
|
57030
57044
|
return JSON.parse(JSON.stringify(preset));
|
|
57031
57045
|
}
|
|
57046
|
+
/**
|
|
57047
|
+
* The engine's roundBlind (poker-vm#2738): a big blind of 1,000 or more rounded
|
|
57048
|
+
* up to two significant figures (1,280 → 1,300; 10,240 → 11,000). The unit is
|
|
57049
|
+
* then at least 100, so the result stays even. Below 1,000 it is returned as is.
|
|
57050
|
+
*/
|
|
57051
|
+
function roundBlind(bigBlind) {
|
|
57052
|
+
if (bigBlind < 1000n)
|
|
57053
|
+
return bigBlind;
|
|
57054
|
+
const unit = 10n ** BigInt(bigBlind.toString().length - 2);
|
|
57055
|
+
return ((bigBlind + unit - 1n) / unit) * unit;
|
|
57056
|
+
}
|
|
57032
57057
|
function algorithmicSmallBlind(structure, n) {
|
|
57033
57058
|
const sb0 = BigInt(structure.startSmallBlind);
|
|
57034
57059
|
switch (structure.progression) {
|
|
@@ -57077,8 +57102,13 @@ function expandBlindLevel(structure, n) {
|
|
|
57077
57102
|
row.durationMinutes = n >= rows.length ? rows[rows.length - 1].durationMinutes : rows[n].durationMinutes;
|
|
57078
57103
|
return row;
|
|
57079
57104
|
}
|
|
57080
|
-
|
|
57081
|
-
|
|
57105
|
+
let sb = algorithmicSmallBlind(structure, m);
|
|
57106
|
+
let bb = sb * 2n;
|
|
57107
|
+
// Level 0 is the creator's opening blinds and is never rounded.
|
|
57108
|
+
if (structure.progression !== "percentage" && structure.roundBlinds && m > 0) {
|
|
57109
|
+
bb = roundBlind(bb);
|
|
57110
|
+
sb = bb / 2n;
|
|
57111
|
+
}
|
|
57082
57112
|
let ante = 0n;
|
|
57083
57113
|
if (structure.ante && n >= structure.ante.startLevel)
|
|
57084
57114
|
ante = (bb * BigInt(structure.ante.bps)) / BPS;
|
|
@@ -71798,7 +71828,8 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
71798
71828
|
* `bettingLimit` is the table's betting structure (block52/pokerchain#407).
|
|
71799
71829
|
* Omit it for the variant's default: pot-limit for omaha (PLO), no-limit for
|
|
71800
71830
|
* texas-holdem. Omitted, the field is not encoded at all, so a chain without
|
|
71801
|
-
* it accepts the tx unchanged. Fixed-limit is
|
|
71831
|
+
* it accepts the tx unchanged. Fixed-limit is texas-holdem only (poker-vm#2654,
|
|
71832
|
+
* block52/pokerchain#439).
|
|
71802
71833
|
*/
|
|
71803
71834
|
async createGame(gameFormat, gameVariant, minPlayers, maxPlayers, minBuyInB52USDC, maxBuyInB52USDC, smallBlindB52USDC, bigBlindB52USDC, timeout, rakeConfig, sngConfig, name, bettingLimit) {
|
|
71804
71835
|
// Validate SNG/Tournament config BEFORE any network work — fail fast.
|
|
@@ -71821,7 +71852,7 @@ class SigningCosmosClient extends CosmosClient {
|
|
|
71821
71852
|
}
|
|
71822
71853
|
assertCreatableSngField(minPlayers, maxPlayers, sngConfig);
|
|
71823
71854
|
}
|
|
71824
|
-
assertCreatableBettingLimit(bettingLimit);
|
|
71855
|
+
assertCreatableBettingLimit(bettingLimit, gameVariant);
|
|
71825
71856
|
await this.initializeSigningClient();
|
|
71826
71857
|
if (!this.signingClient || !this.wallet) {
|
|
71827
71858
|
throw new Error("Signing client not initialized");
|
|
@@ -72764,14 +72795,18 @@ async function createSigningClientFromMnemonic(config, mnemonic) {
|
|
|
72764
72795
|
}
|
|
72765
72796
|
/**
|
|
72766
72797
|
* Throws for a betting limit a table cannot be created with (block52/pokerchain#407).
|
|
72767
|
-
* Undefined is allowed: the chain applies the variant's default.
|
|
72798
|
+
* Undefined is allowed: the chain applies the variant's default. Fixed-limit is
|
|
72799
|
+
* texas-holdem only, as the chain decides (block52/pokerchain#439, poker-vm#2654).
|
|
72768
72800
|
*/
|
|
72769
|
-
function assertCreatableBettingLimit(bettingLimit) {
|
|
72801
|
+
function assertCreatableBettingLimit(bettingLimit, gameVariant) {
|
|
72770
72802
|
if (bettingLimit === undefined) {
|
|
72771
72803
|
return;
|
|
72772
72804
|
}
|
|
72773
72805
|
if (bettingLimit === exports.BettingLimit.FIXED_LIMIT) {
|
|
72774
|
-
|
|
72806
|
+
if (gameVariant !== exports.GameVariant.TEXAS_HOLDEM) {
|
|
72807
|
+
throw new Error(`Betting limit fixed-limit is only available for texas-holdem; got ${gameVariant}.`);
|
|
72808
|
+
}
|
|
72809
|
+
return;
|
|
72775
72810
|
}
|
|
72776
72811
|
if (bettingLimit !== exports.BettingLimit.NO_LIMIT && bettingLimit !== exports.BettingLimit.POT_LIMIT) {
|
|
72777
72812
|
throw new Error(`Invalid betting limit: ${bettingLimit}.`);
|
|
@@ -72878,6 +72913,7 @@ exports.parseGameFormat = parseGameFormat;
|
|
|
72878
72913
|
exports.parseGameVariant = parseGameVariant;
|
|
72879
72914
|
exports.registry = registry;
|
|
72880
72915
|
exports.resolveBlindPreset = resolveBlindPreset;
|
|
72916
|
+
exports.roundBlind = roundBlind;
|
|
72881
72917
|
exports.toValoperAddress = toValoperAddress;
|
|
72882
72918
|
exports.txFailureHash = txFailureHash;
|
|
72883
72919
|
exports.txFailurePhase = txFailurePhase;
|