Skip to content

Implement player exit: invalidate session, shred cards, advance initiative#105

Open
turkosaurus with Copilot wants to merge 4 commits into
mainfrom
copilot/closes-100-exiting-game-is-noop
Open

Implement player exit: invalidate session, shred cards, advance initiative#105
turkosaurus with Copilot wants to merge 4 commits into
mainfrom
copilot/closes-100-exiting-game-is-noop

Conversation

Copilot AI commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Exiting a game was a no-op — clicking "exit" just navigated home without touching server state, leaving the player's session key live, their cards in play, and their initiative slot active.

Changes

New SQL query

  • GameCardsShredByPlayer — bulk-shreds all cards held by a player in a game

Exit action handler (actions.go)

  • Added exit case handled before the game-state switch so it works in any state
  • Shreds all of the player's cards
  • If it's the player's turn (stateTurn / statePending), resets statePendingstateTurn if needed, then calls advanceTurn before deletion (so InitiativeAdvance still sees the correct max initiative)
  • Deletes the player from game_players — their slot becomes a gap the existing advanceTurn gap-handler already tolerates
  • Expires the session cookie (MaxAge: -1, HttpOnly: true) and responds with HX-Redirect: /

Footer template (tmpl.footer.html)

  • Exit dialog's confirmation button changed from a plain <a href="/"> to hx-post="/{game_id}/action/exit" so the server-side cleanup runs before the redirect

Security / correctness

  • Added math.MaxInt32 bounds check on the player ID parsed from the cookie before casting to int32

Copilot AI changed the title [WIP] Fix exiting game functionality for cookies and cards Implement player exit: invalidate session, shred cards, advance initiative Jun 14, 2026
Copilot AI requested a review from turkosaurus June 14, 2026 00:35
@turkosaurus
turkosaurus marked this pull request as ready for review June 14, 2026 01:47
@turkosaurus
turkosaurus requested review from katlukens and removed request for turkosaurus June 28, 2026 05:07

@katlukens katlukens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants