@pokertools/engine 1.0.1 → 1.0.4
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/README.md +591 -445
- package/dist/.tsbuildinfo +1 -0
- package/dist/actions/betting.js +7 -2
- package/dist/actions/dealing.js +46 -20
- package/dist/actions/management.js +26 -5
- package/dist/actions/special.d.ts +18 -0
- package/dist/actions/special.js +20 -0
- package/dist/browser.d.ts +27 -0
- package/dist/browser.js +73 -0
- package/dist/engine/PokerEngine.d.ts +23 -2
- package/dist/engine/PokerEngine.js +54 -2
- package/dist/errors/ErrorCodes.d.ts +4 -35
- package/dist/errors/ErrorCodes.js +7 -41
- package/dist/errors/index.d.ts +0 -1
- package/dist/errors/index.js +1 -1
- package/dist/history/exporter.d.ts +1 -2
- package/dist/history/formats/json.d.ts +1 -1
- package/dist/history/formats/pokerstars.d.ts +1 -1
- package/dist/history/handHistoryBuilder.d.ts +1 -2
- package/dist/history/handHistoryBuilder.js +4 -1
- package/dist/index.d.ts +1 -1
- package/dist/rules/actionOrder.js +4 -4
- package/dist/rules/blinds.d.ts +2 -0
- package/dist/rules/blinds.js +27 -3
- package/dist/rules/headsUp.js +18 -0
- package/dist/rules/showdown.js +10 -0
- package/dist/utils/cardUtils.d.ts +2 -1
- package/dist/utils/cardUtils.js +2 -1
- package/dist/utils/invariants.js +4 -0
- package/dist/utils/positioning.js +2 -2
- package/dist/utils/serialization.d.ts +1 -0
- package/dist/utils/serialization.js +2 -0
- package/dist/utils/viewMasking.d.ts +2 -1
- package/dist/utils/viewMasking.js +9 -1
- package/package.json +31 -5
- package/dist/history/types.d.ts +0 -73
- package/dist/history/types.js +0 -5
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -10,9 +10,10 @@ exports.sanitizeActionHistory = sanitizeActionHistory;
|
|
|
10
10
|
*
|
|
11
11
|
* @param state Full game state
|
|
12
12
|
* @param playerId Player requesting view (null = spectator)
|
|
13
|
+
* @param version State version number (defaults to 0 if not provided)
|
|
13
14
|
* @returns Masked public state
|
|
14
15
|
*/
|
|
15
|
-
function createPublicView(state, playerId = null) {
|
|
16
|
+
function createPublicView(state, playerId = null, version = 0) {
|
|
16
17
|
const maskedPlayers = state.players.map((player, _seat) => {
|
|
17
18
|
if (!player)
|
|
18
19
|
return null;
|
|
@@ -23,11 +24,18 @@ function createPublicView(state, playerId = null) {
|
|
|
23
24
|
hand: visibleHand,
|
|
24
25
|
};
|
|
25
26
|
});
|
|
27
|
+
// Convert Map to plain object for JSON serialization
|
|
28
|
+
const currentBetsObj = {};
|
|
29
|
+
for (const [seat, amount] of state.currentBets.entries()) {
|
|
30
|
+
currentBetsObj[seat] = amount;
|
|
31
|
+
}
|
|
26
32
|
return {
|
|
27
33
|
...state,
|
|
28
34
|
deck: [], // Always hide deck
|
|
29
35
|
players: maskedPlayers,
|
|
36
|
+
currentBets: currentBetsObj, // Serializable record
|
|
30
37
|
viewingPlayerId: playerId,
|
|
38
|
+
version,
|
|
31
39
|
};
|
|
32
40
|
}
|
|
33
41
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pokertools/engine",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Enterprise-grade Texas Hold'em poker engine",
|
|
5
|
+
"author": "A.Aurelius",
|
|
6
|
+
"license": "MIT",
|
|
5
7
|
"main": "dist/index.js",
|
|
6
8
|
"types": "dist/index.d.ts",
|
|
7
9
|
"exports": {
|
|
@@ -10,16 +12,32 @@
|
|
|
10
12
|
"require": "./dist/index.js",
|
|
11
13
|
"import": "./dist/index.js",
|
|
12
14
|
"default": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./browser": {
|
|
17
|
+
"types": "./dist/browser.d.ts",
|
|
18
|
+
"browser": "./dist/browser.js",
|
|
19
|
+
"require": "./dist/browser.js",
|
|
20
|
+
"import": "./dist/browser.js",
|
|
21
|
+
"default": "./dist/browser.js"
|
|
13
22
|
}
|
|
14
23
|
},
|
|
24
|
+
"browser": "./dist/browser.js",
|
|
15
25
|
"files": [
|
|
16
26
|
"dist",
|
|
17
27
|
"README.md",
|
|
18
28
|
"LICENSE"
|
|
19
29
|
],
|
|
30
|
+
"sideEffects": false,
|
|
20
31
|
"scripts": {
|
|
21
32
|
"build": "tsc",
|
|
22
|
-
"
|
|
33
|
+
"build:watch": "tsc --watch",
|
|
34
|
+
"clean": "rm -rf dist coverage",
|
|
35
|
+
"typecheck": "tsc --noEmit",
|
|
36
|
+
"lint": "eslint . --ext .ts",
|
|
37
|
+
"lint:fix": "eslint . --ext .ts --fix",
|
|
38
|
+
"test": "NODE_OPTIONS='--no-warnings' jest",
|
|
39
|
+
"test:watch": "NODE_OPTIONS='--no-warnings' jest --watch",
|
|
40
|
+
"test:coverage": "NODE_OPTIONS='--no-warnings' jest --coverage"
|
|
23
41
|
},
|
|
24
42
|
"keywords": [
|
|
25
43
|
"poker",
|
|
@@ -27,10 +45,11 @@
|
|
|
27
45
|
"engine",
|
|
28
46
|
"game-engine",
|
|
29
47
|
"redux",
|
|
30
|
-
"immutable"
|
|
48
|
+
"immutable",
|
|
49
|
+
"state-management",
|
|
50
|
+
"tournament",
|
|
51
|
+
"cash-game"
|
|
31
52
|
],
|
|
32
|
-
"author": "A.Aurelius",
|
|
33
|
-
"license": "MIT",
|
|
34
53
|
"repository": {
|
|
35
54
|
"type": "git",
|
|
36
55
|
"url": "https://github.com/aaurelions/pokertools.git",
|
|
@@ -43,8 +62,15 @@
|
|
|
43
62
|
"publishConfig": {
|
|
44
63
|
"access": "public"
|
|
45
64
|
},
|
|
65
|
+
"engines": {
|
|
66
|
+
"node": ">=18.0.0"
|
|
67
|
+
},
|
|
46
68
|
"dependencies": {
|
|
47
69
|
"@pokertools/evaluator": "*",
|
|
48
70
|
"@pokertools/types": "*"
|
|
71
|
+
},
|
|
72
|
+
"peerDependencies": {
|
|
73
|
+
"@pokertools/evaluator": "*",
|
|
74
|
+
"@pokertools/types": "*"
|
|
49
75
|
}
|
|
50
76
|
}
|
package/dist/history/types.d.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hand history types
|
|
3
|
-
*/
|
|
4
|
-
import { Street, Action } from "@pokertools/types";
|
|
5
|
-
/**
|
|
6
|
-
* Hand history record
|
|
7
|
-
* Contains complete information about a single hand
|
|
8
|
-
*/
|
|
9
|
-
export interface HandHistory {
|
|
10
|
-
readonly handId: string;
|
|
11
|
-
readonly timestamp: number;
|
|
12
|
-
readonly tableName: string;
|
|
13
|
-
readonly gameType: "Cash" | "Tournament";
|
|
14
|
-
readonly stakes: {
|
|
15
|
-
readonly smallBlind: number;
|
|
16
|
-
readonly bigBlind: number;
|
|
17
|
-
readonly ante: number;
|
|
18
|
-
};
|
|
19
|
-
readonly maxPlayers: number;
|
|
20
|
-
readonly buttonSeat: number;
|
|
21
|
-
readonly players: readonly HandHistoryPlayer[];
|
|
22
|
-
readonly streets: readonly StreetHistory[];
|
|
23
|
-
readonly winners: readonly WinnerRecord[];
|
|
24
|
-
readonly totalPot: number;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Player information in hand history
|
|
28
|
-
*/
|
|
29
|
-
export interface HandHistoryPlayer {
|
|
30
|
-
readonly seat: number;
|
|
31
|
-
readonly name: string;
|
|
32
|
-
readonly startingStack: number;
|
|
33
|
-
readonly endingStack: number;
|
|
34
|
-
readonly cards?: readonly string[];
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* History for a single street
|
|
38
|
-
*/
|
|
39
|
-
export interface StreetHistory {
|
|
40
|
-
readonly street: Street;
|
|
41
|
-
readonly board: readonly string[];
|
|
42
|
-
readonly actions: readonly ActionRecord[];
|
|
43
|
-
readonly pot: number;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Action record in history
|
|
47
|
-
*/
|
|
48
|
-
export interface ActionRecord {
|
|
49
|
-
readonly seat: number;
|
|
50
|
-
readonly playerName: string;
|
|
51
|
-
readonly action: Action;
|
|
52
|
-
readonly amount?: number;
|
|
53
|
-
readonly isAllIn?: boolean;
|
|
54
|
-
readonly timestamp: number;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Winner record
|
|
58
|
-
*/
|
|
59
|
-
export interface WinnerRecord {
|
|
60
|
-
readonly seat: number;
|
|
61
|
-
readonly playerName: string;
|
|
62
|
-
readonly amount: number;
|
|
63
|
-
readonly hand?: readonly string[];
|
|
64
|
-
readonly handRank?: string;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Hand history format options
|
|
68
|
-
*/
|
|
69
|
-
export interface ExportOptions {
|
|
70
|
-
readonly format: "pokerstars" | "json" | "compact";
|
|
71
|
-
readonly includeHoleCards?: boolean;
|
|
72
|
-
readonly timezone?: string;
|
|
73
|
-
}
|
package/dist/history/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"root":["../src/index.ts","../src/actions/betting.ts","../src/actions/dealing.ts","../src/actions/management.ts","../src/actions/showdownActions.ts","../src/actions/special.ts","../src/actions/streetProgression.ts","../src/actions/tournament.ts","../src/actions/validation.ts","../src/engine/PokerEngine.ts","../src/engine/gameReducer.ts","../src/errors/ConfigError.ts","../src/errors/CriticalStateError.ts","../src/errors/ErrorCodes.ts","../src/errors/IllegalActionError.ts","../src/errors/PokerEngineError.ts","../src/errors/index.ts","../src/history/exporter.ts","../src/history/handHistoryBuilder.ts","../src/history/types.ts","../src/history/formats/json.ts","../src/history/formats/pokerstars.ts","../src/rules/actionOrder.ts","../src/rules/blinds.ts","../src/rules/headsUp.ts","../src/rules/showdown.ts","../src/rules/sidePots.ts","../src/utils/cardUtils.ts","../src/utils/constants.ts","../src/utils/deck.ts","../src/utils/invariants.ts","../src/utils/positioning.ts","../src/utils/rake.ts","../src/utils/serialization.ts","../src/utils/validation.ts","../src/utils/viewMasking.ts"],"version":"5.9.3"}
|