Add LeaderboardV4: startGame tracking and abandoned game resolution#101
Open
bh2smith wants to merge 5 commits into
Open
Add LeaderboardV4: startGame tracking and abandoned game resolution#101bh2smith wants to merge 5 commits into
bh2smith wants to merge 5 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Track when players enter a game so abandoned sessions can be detected and resolved as losses. Adds startGame(gameId) for players, resolveAbandoned(gameId, players) for the owner, and GameStarted/GameAbandoned events for analytics.
Add startGame ABI and encodeStartGame helper. Entry gate now sends startGame(gameId) in the same batch transaction as the CRC entry fee, so abandoned games are trackable on-chain from the moment a player pays to enter.
Anyone can resolve abandoned games once the abandonmentTimeout (default 1 hour) has elapsed since startGame was called. Owner can adjust the timeout via setAbandonmentTimeout.
bh2smith
force-pushed
the
feat/leaderboard-v4-start-game
branch
from
May 25, 2026 05:44
0206036 to
715eabb
Compare
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.
Summary
CardRoomLeaderboardV4contract with game session trackingstartGame(gameId)records when a player enters a game, emitsGameStartedeventrecordSoloResult/recordVsAiResultclear the active game on completion (backward compatible — works without callingstartGame)resolveAbandoned(gameId, players[])lets the owner batch-record losses for players who started but never finishedNew contract functions
startGame(uint8 gameId)resolveAbandoned(uint8 gameId, address[] players)New events
GameStarted(uint8 gameId, address player, uint256 timestamp)GameAbandoned(uint8 gameId, address player, uint256 timestamp)Upgrade instructions
Prerequisites: PR #100 (V3) must be merged and deployed first.
1. Deploy (simulation):
2. Deploy (broadcast):
3. Verify:
Frontend integration
After upgrade, call
startGame(gameId)when a player enters a game (before dealing). No changes needed forrecordSoloResult/recordVsAiResult— they continue to work as before.To resolve abandoned games, query
GameStartedevents without matchingGameResultevents (e.g., via Dune), then callresolveAbandonedwith the stale players.Test plan
forge test --match-contract CardRoomLeaderboardV4Test(16 tests)startGameemits event and setsgameStartedAtrecordResultclearsgameStartedAtrecordResultstill works without callingstartGamefirstresolveAbandonedrecords loss with max cards for solo, 0 for vs-AIresolveAbandonedreverts for players without active games