Modern Apps git

← Modern-Apps.git

games-chess: show the right resign result text

Commit
0e102b78cce7b7d67c8e756686265d64f70e45ae
Author
Vayun Mathur <[email protected]>
When
2026-11-07 11:36 UTC (29 days ago)
Parents
ee6d0a9
OnlineChessViewModel.resultTextFor had the two resign strings
swapped: when the server reported the local player as the winner
(the opponent resigned) it showed 'You resigned.', and when the
opponent won (the local player resigned) it showed 'Opponent
resigned. You win!'. Lichess gameState.winner is the winning color,
so iWon == true must map to the opponent-resigned string and every
other case (opponent won, or no winner yet) to 'You resigned.'.

Found by the pass-3 online ViewModel tests, which drive a scripted
game stream ending in both resign outcomes.

(cherry picked from commit 9863f45078e2925a0055a8f6ec9c37acfd19984b)

Diff

games/chess/src/main/java/com/vayunmathur/games/chess/platform/OnlineChessViewModel.kt
diff --git a/games/chess/src/main/java/com/vayunmathur/games/chess/platform/OnlineChessViewModel.kt b/games/chess/src/main/java/com/vayunmathur/games/chess/platform/OnlineChessViewModel.ktindex ef0f9bcf9d..f99b3a8cb0 100644--- a/games/chess/src/main/java/com/vayunmathur/games/chess/platform/OnlineChessViewModel.kt+++ b/games/chess/src/main/java/com/vayunmathur/games/chess/platform/OnlineChessViewModel.kt@@ -47,6 +47,7 @@ class OnlineChessViewModel(application: Application) : AndroidViewModel(applicat      private val tokenStore = LichessTokenStore(application)     private val authManager = LichessAuthManager(application, tokenStore)+     private val api = LichessApi(tokenStore)      private val _uiState = MutableStateFlow(OnlineChessUiState())@@ -404,10 +405,10 @@ class OnlineChessViewModel(application: Application) : AndroidViewModel(applicat             "draw", "stalemate" -> context.getString(                 com.vayunmathur.games.chess.R.string.online_result_draw             )-            // `winner` is the color that won: present → the other side resigned; absent → I resigned-            // (my resign POST raced the state, or the server reports it without a winner).+            // `winner` is the color that won: my color → the opponent resigned; the+            // opponent's color (or no winner, when my resign POST raced the state) → I resigned.             "resign" ->-                if (iWon == false) context.getString(+                if (iWon == true) context.getString(                     com.vayunmathur.games.chess.R.string.online_result_opponent_resigned                 ) else context.getString(                     com.vayunmathur.games.chess.R.string.online_result_resigned