feat(lobby): drop left honest-AI games from the finished list
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 9s
CI / integration (pull_request) Successful in 13s
CI / ui (pull_request) Has been skipped
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m4s
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 9s
CI / integration (pull_request) Successful in 13s
CI / ui (pull_request) Has been skipped
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m4s
A finished honest-AI (vs_ai) game the player left — by resigning or by abandoning it to the 7-day inactivity timeout (end_reason 'resign'/'timeout') — no longer appears in that player's own lobby finished list. The new game.Service.ListForLobby filters ListForAccount for the lobby endpoint only; the admin console and the account-merge count keep the full set. The filter keys on the game's end reason, not on which seat left, so it extends to any player should the robot ever resign.
This commit is contained in:
@@ -1190,13 +1190,37 @@ func (svc *Service) SharedGame(ctx context.Context, a, b uuid.UUID) (bool, error
|
||||
return svc.store.SharedGameExists(ctx, a, b)
|
||||
}
|
||||
|
||||
// ListForAccount returns every game the account is seated in, newest first, for the
|
||||
// lobby's active/finished lists. The live position is not loaded — the summaries come
|
||||
// straight from the durable rows.
|
||||
// ListForAccount returns every game the account is seated in, newest first — the full
|
||||
// set behind the admin console, the account-merge count and the block-time forfeit
|
||||
// sweep. The player's own lobby uses ListForLobby, which drops the honest-AI games the
|
||||
// player left. The live position is not loaded — the summaries come straight from the
|
||||
// durable rows.
|
||||
func (svc *Service) ListForAccount(ctx context.Context, accountID uuid.UUID) ([]Game, error) {
|
||||
return svc.store.ListGamesForAccount(ctx, accountID)
|
||||
}
|
||||
|
||||
// ListForLobby returns the games shown in the account's own lobby: ListForAccount minus
|
||||
// the honest-AI games the player left — by resigning or by abandoning to the inactivity
|
||||
// timeout (games.end_reason 'resign'/'timeout') — which drop out of the finished list
|
||||
// automatically. The robot never leaves (it moves at once, never sleeps, never resigns),
|
||||
// so only a human's departure matches; the predicate is a game property, not a seat
|
||||
// check, so it extends to any player should the robot ever resign. Admin and
|
||||
// account-merge views keep using ListForAccount and see the full set.
|
||||
func (svc *Service) ListForLobby(ctx context.Context, accountID uuid.UUID) ([]Game, error) {
|
||||
games, err := svc.ListForAccount(ctx, accountID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
kept := games[:0]
|
||||
for _, g := range games {
|
||||
if g.VsAI && (g.EndReason == "resign" || g.EndReason == "timeout") {
|
||||
continue
|
||||
}
|
||||
kept = append(kept, g)
|
||||
}
|
||||
return kept, nil
|
||||
}
|
||||
|
||||
// CountActiveQuickGames reports how many in-progress quick games the account holds —
|
||||
// the count the simultaneous-game limit (MaxActiveQuickGames) is checked against. It
|
||||
// counts active and still-open quick games (including honest-AI ones) and excludes
|
||||
|
||||
Reference in New Issue
Block a user