diff --git a/.pr-body.md b/.pr-body.md new file mode 100644 index 0000000..1c79e7c --- /dev/null +++ b/.pr-body.md @@ -0,0 +1,15 @@ +## Summary + +Fixes `Hand.isPlayable()` incorrectly treating `_inactive[i] === 2` (new player) as playable. + +Per **HAND.md** and **APPENDIX_SEATING.md**, `_inactive: 2` means "new player" and they are inactive until next hand. Only `_inactive === 0` or `undefined` should count as playable. + +## Changes + +- **src/Hand.ts**: In `Hand.isPlayable()`, only treat `_inactive[i] === 0` or `undefined` as active; `1` (waiting/sitting out) and `2` (new player) are not playable. +- **CONTRIBUTION_FINDINGS.md**: Added audit of issues, bugs, docs, and improvement ideas for future contributions. + +## Test + +- Fixes failing test: `Hand Data Extraction > Hand.isPlayable > should treat new players (_inactive: 2) as not playable` +- `npx vitest run src/__tests__/api/hand/data-extraction.test.ts` passes (45 tests) diff --git a/package-lock.json b/package-lock.json index 223790a..2260bf6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@yuga-labs/poker-engine", - "version": "2.0.2", + "version": "2.1.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@yuga-labs/poker-engine", - "version": "2.0.2", + "version": "2.1.2", "dependencies": { "@js-temporal/polyfill": "^0.5.1" }, diff --git a/src/Hand.ts b/src/Hand.ts index 63e0ab8..373075e 100644 --- a/src/Hand.ts +++ b/src/Hand.ts @@ -128,8 +128,8 @@ export namespace Hand { for (let i = 0; i < hand.players.length; i++) { // Check if player is active (no _inactive array means all active) - // 0 - active, 1 - inactive, 2 - new player - const isActive = !Array.isArray(hand._inactive) || hand._inactive[i] === 0 || hand._inactive[i] === 2; + // 0 - active, 1 - waiting for BB / sitting out, 2 - new player (inactive until next hand) + const isActive = !Array.isArray(hand._inactive) || hand._inactive[i] === 0 || hand._inactive[i] === undefined; // Check if player has chips const hasChips = (hand.startingStacks[i] ?? 0) > 0;