Skip to content

feat: Represent session game outcome as win/loss/draw#288

Merged
Amund211 merged 1 commit into
mainfrom
session-game-outcome-draws
Jun 28, 2026
Merged

feat: Represent session game outcome as win/loss/draw#288
Amund211 merged 1 commit into
mainfrom
session-game-outcome-draws

Conversation

@Amund211

Copy link
Copy Markdown
Owner

Summary

Replaces the Won bool on session-detail game results with a three-state
GameOutcome enum (win / loss / draw). Draws are rare but do happen in
Bedwars; today they are silently miscounted as losses because Wins doesn't
increment.

Changes

  • domain.GameResult.Won boolOutcome GameOutcome (win/loss/draw), a
    new enum mirroring the existing domain.Gamemode pattern.
  • Outcome is derived from the Wins/Losses deltas in buildGameSegment (the
    Losses counter was previously never read). Added a validation guard
    rejecting impossible single-game movement (deltas outside {0,1}, or both
    win and loss advancing), consistent with the existing FinalDeaths/BedsLost
    guard → falls back to Game: nil.
  • Wire/API change in session-at: "won": bool becomes
    "outcome": "win" | "loss" | "draw", with a new
    gameOutcomeToRainbowOutcome converter.
  • Tests updated to assert outcomes; added draw and invalid-delta cases.

Detection assumption

A draw is treated as "one game played, but neither Wins nor Losses
incremented". This relies on a draw still advancing GamesPlayed by 1 while
crediting neither counter (otherwise it's filtered out upstream as a non-game).
The enum modeling is correct regardless, but worth confirming against real draw
data if any exists.

⚠️ Downstream consumers

This changes the session-at JSON contract (wonoutcome). Rainbow PR
#256 must be updated to work with this updated schema:

Amund211/rainbow#256

🤖 Generated with Claude Code

Replace GameResult.Won (bool) with a three-state GameOutcome enum so draws
are recorded as draws instead of silently counting as losses. The outcome
is derived from the Wins/Losses deltas (Losses was previously unused), with
validation rejecting impossible single-game movement. The session-at wire
field changes from "won": bool to "outcome": "win"|"loss"|"draw".

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 28, 2026 20:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates session game results to model the outcome as a three-state enum (win/loss/draw) instead of a boolean, and wires that through the session-at JSON response to correctly represent rare draw games.

Changes:

  • Replace domain.GameResult.Won bool with domain.GameOutcome (Outcome field).
  • Derive outcome from per-game Wins/Losses deltas in buildGameSegment, including validation that rejects impossible deltas (falls back to Game: nil).
  • Update session-at response schema from "won": bool to "outcome": "win" | "loss" | "draw", plus updated tests (including draw + invalid-delta cases).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
internal/domain/game_result.go Introduces GameOutcome enum and updates GameResult to use Outcome.
internal/app/session_at.go Computes Outcome from wins/losses deltas and validates impossible single-game movements.
internal/app/session_at_test.go Updates assertions to outcomes and adds coverage for draw + invalid win/loss delta scenarios.
internal/ports/rainbow_converters.go Adds gameOutcomeToRainbowOutcome converter for stable JSON contract strings.
internal/ports/session_at.go Updates session-at wire format to emit outcome and performs conversion.
internal/ports/session_at_test.go Updates handler tests to expect outcome instead of won.

Comment on lines +242 to +244
// unreachable
reporting.Report(ctx,
fmt.Errorf("weird Wins/Losses delta for single-game segment"),
@Amund211 Amund211 merged commit 3736c2c into main Jun 28, 2026
10 checks passed
@Amund211 Amund211 deleted the session-game-outcome-draws branch June 28, 2026 20:46
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.

2 participants