Feat/hand limit rework#1359
Open
itsalaidbacklife wants to merge 25 commits into
Open
Conversation
… phase Introduces a new DISCARDING_TO_HAND_LIMIT game phase (value 6) so players can always draw or resolve moves that overflow the 8-card hand limit, then discard down immediately rather than being blocked upfront. - Draw: removed the block-at-8 validation; drawing a 9th card enters the new phase instead of incrementing turn - Five: always draws 3 cards (removed the spaceInHand cap); overflows trigger the discard phase - Nine: if the returned card pushes the targeted player over 8, they enter the discard phase before getting their turn - New discard-to-hand-limit validate/execute helpers; supports discarding 1 card (hand=9) or 2 cards (hand=10) in a single move - Frontend: DiscardToHandLimitDialog, game store computed/action wiring, socket event handler, and i18n strings - AI: generates all valid discard combinations for the new move type - Tests: updated basicMoves, 5_fives, and 9_nines specs; new handLimit.spec.js Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nd limit, triggering discard dialog for player'
itsalaidbacklife
commented
May 5, 2026
Contributor
Author
itsalaidbacklife
left a comment
There was a problem hiding this comment.
Drafted, needs iterating
Comment on lines
+144
to
+161
| const overflowCount = playerHand.length - 8; | ||
| if (overflowCount <= 0) {break;} | ||
| const getCombinations = (arr, k) => { | ||
| if (k === 1) {return arr.map((item) => [ item ]);} | ||
| const result = []; | ||
| for (let i = 0; i <= arr.length - k; i++) { | ||
| for (const rest of getCombinations(arr.slice(i + 1), k - 1)) { | ||
| result.push([ arr[i], ...rest ]); | ||
| } | ||
| } | ||
| return result; | ||
| }; | ||
| res = getCombinations(playerHand, overflowCount).map((combo) => ({ | ||
| moveType, | ||
| playedBy, | ||
| discardedCards: combo.map((card) => card.id), | ||
| })); | ||
| break; |
Contributor
Author
There was a problem hiding this comment.
Should investigate this from a performance perspective. Recursion smells and I could see this blowing up
| for (const cardId of discardIds) { | ||
| const cardIndex = player.hand.findIndex(({ id }) => id === cardId); | ||
| if (cardIndex !== -1) { | ||
| discardedCards.push(player.hand[cardIndex]); |
Contributor
Author
There was a problem hiding this comment.
Should we be this defensive. Given that validate runs first we could take discarded cards as-is. But this further ensures we sanity check which isn't crazy.
Syntactically if we're constructing discarded cards from the ones we find, I'd prefer this in three lines, splice then two pushes
…imit after opponent nines and player draws'
…es player at the hand limit and player then plays points
…g a 4 on opponent when player has 10 cards in hand
… to hand limit after four resolution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Revises how the hand limit works so that at the end of your turn, you discard down to 8 (no other limitations on moves)
Issue number
Relevant issue number
Please check the following
Please describe additional details for testing this change