@block52/poker-vm-sdk 1.15.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 +17 -3
- package/dist/index.esm.js +43 -13
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +43 -12
- package/dist/index.js.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;
|
|
@@ -72883,6 +72913,7 @@ exports.parseGameFormat = parseGameFormat;
|
|
|
72883
72913
|
exports.parseGameVariant = parseGameVariant;
|
|
72884
72914
|
exports.registry = registry;
|
|
72885
72915
|
exports.resolveBlindPreset = resolveBlindPreset;
|
|
72916
|
+
exports.roundBlind = roundBlind;
|
|
72886
72917
|
exports.toValoperAddress = toValoperAddress;
|
|
72887
72918
|
exports.txFailureHash = txFailureHash;
|
|
72888
72919
|
exports.txFailurePhase = txFailurePhase;
|