chess: only credit the player's own castling (#602)
- Commit
c6f8f509aa998436bf81de1710b00ae68c004ec4- Author
- vayun-mathur <[email protected]>
- When
- 2026-08-26 17:42 UTC (3 months ago)
- Parents
ba73816
Diff
games/chess/src/main/java/com/vayunmathur/games/chess/MainActivity.kt
diff --git a/games/chess/src/main/java/com/vayunmathur/games/chess/MainActivity.kt b/games/chess/src/main/java/com/vayunmathur/games/chess/MainActivity.ktindex b704e5c006..18b2e2f60d 100644--- a/games/chess/src/main/java/com/vayunmathur/games/chess/MainActivity.kt+++ b/games/chess/src/main/java/com/vayunmathur/games/chess/MainActivity.kt@@ -326,6 +326,13 @@ fun ChessGame( LaunchedEffect(uiState.board.lastMove) { val lastMove = uiState.board.lastMove ?: return@LaunchedEffect+ // The engine's replies land in the same board state as the human's moves, so credit the+ // move only when the side that made it is the one the player is sitting on.+ val playedByPlayer = when (val mode = uiState.gameMode) {+ is GameMode.VsAI -> lastMove.piece.color == mode.playerColor+ GameMode.TwoPlayer -> true+ }+ if (!playedByPlayer) return@LaunchedEffect if (lastMove.isCastling) { achievementsManager.onAchievementUnlocked("castled") }