Skip to content

Feat/hand limit rework#1359

Open
itsalaidbacklife wants to merge 25 commits into
mainfrom
feat/hand-limit-rework
Open

Feat/hand limit rework#1359
itsalaidbacklife wants to merge 25 commits into
mainfrom
feat/hand-limit-rework

Conversation

@itsalaidbacklife
Copy link
Copy Markdown
Contributor

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

  • Resolves #

Please check the following

  • Do the tests still pass? (see Run the Tests)
  • Is the code formatted properly? (see Linting (Formatting))
  • For New Features:
    • Have tests been added to cover any new features or fixes?
    • Has the documentation been updated accordingly?

Please describe additional details for testing this change

itsalaidbacklife and others added 2 commits May 2, 2026 12:26
… 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>
@itsalaidbacklife itsalaidbacklife added version-major A large update that warrants changing the MAJOR version of the app e.g. (4.0.0 => 5.0.0) backend Requires changes to the (node) backend webserver frontend Requires changes to the frontend (vue) client rules change Adjustment to the rules of the game labels May 2, 2026
Copy link
Copy Markdown
Contributor Author

@itsalaidbacklife itsalaidbacklife left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should investigate this from a performance perspective. Recursion smells and I could see this blowing up

Comment thread api/helpers/game-states/get-active-player-p-num.js
Comment thread api/helpers/game-states/get-log.js
for (const cardId of discardIds) {
const cardIndex = player.hand.findIndex(({ id }) => id === cardId);
if (cardIndex !== -1) {
discardedCards.push(player.hand[cardIndex]);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread api/helpers/game-states/moves/discard-to-hand-limit/validate.js
Comment thread docs/game-state-api.md
Comment thread src/stores/game.js
Comment thread src/stores/game.js
Comment thread src/plugins/sockets/inGameEvents.js Outdated
…es player at the hand limit and player then plays points
…g a 4 on opponent when player has 10 cards in hand
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Requires changes to the (node) backend webserver frontend Requires changes to the frontend (vue) client rules change Adjustment to the rules of the game version-major A large update that warrants changing the MAJOR version of the app e.g. (4.0.0 => 5.0.0)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant