From 14a2dbc955dd87a225cb8bc7bed1fc4537ef7a0c Mon Sep 17 00:00:00 2001 From: Calcitem Date: Thu, 20 May 2021 23:38:25 +0800 Subject: [PATCH] flutter: Remove legacy regret code --- src/ui/flutter_app/lib/l10n/intl_en.arb | 4 --- src/ui/flutter_app/lib/l10n/intl_zh.arb | 1 - src/ui/flutter_app/lib/mill/game.dart | 41 ----------------------- src/ui/flutter_app/lib/mill/position.dart | 39 --------------------- 4 files changed, 85 deletions(-) diff --git a/src/ui/flutter_app/lib/l10n/intl_en.arb b/src/ui/flutter_app/lib/l10n/intl_en.arb index a498c90e..590bf7ac 100644 --- a/src/ui/flutter_app/lib/l10n/intl_en.arb +++ b/src/ui/flutter_app/lib/l10n/intl_en.arb @@ -284,10 +284,6 @@ "@youLose": { "description": "You Lose!" }, - "regret": "Undo", - "@regret": { - "description": "Undo" - }, "analyze": "Analyze", "@analyze": { "description": "Analyze" diff --git a/src/ui/flutter_app/lib/l10n/intl_zh.arb b/src/ui/flutter_app/lib/l10n/intl_zh.arb index 684ac448..4a538c6d 100644 --- a/src/ui/flutter_app/lib/l10n/intl_zh.arb +++ b/src/ui/flutter_app/lib/l10n/intl_zh.arb @@ -71,7 +71,6 @@ "youWin": "恭喜你赢了", "challengeHarderLevel": "后续提升难度吗?\n提升后的难度等级将为", "youLose": "你输了", - "regret": "悔棋", "analyze": "分析", "playerName": "棋手姓名", "about": "关于", diff --git a/src/ui/flutter_app/lib/mill/game.dart b/src/ui/flutter_app/lib/mill/game.dart index 48a08b25..216db1da 100644 --- a/src/ui/flutter_app/lib/mill/game.dart +++ b/src/ui/flutter_app/lib/mill/game.dart @@ -139,47 +139,6 @@ class Game { return true; } - bool regret({moves = 2}) { - // - // Can regret only our turn - // TODO - if (_position.side != PieceColor.black) { - //Audios.playTone(Audios.invalidSoundId); - return false; - } - - var regretted = false; - - /// Regret 2 step - - for (var i = 0; i < moves; i++) { - // - if (!_position.regret()) break; - - final lastMove = _position.lastMove; - - if (lastMove != null) { - // - _blurIndex = lastMove.from ?? invalidIndex; - _focusIndex = lastMove.to ?? invalidIndex; - // - } else { - // - _blurIndex = _focusIndex = invalidIndex; - } - - regretted = true; - } - - if (regretted) { - //Audios.playTone(Audios.regretSoundId); - return true; - } - - //Audios.playTone(Audios.invalidSoundId); - return false; - } - printStat() { double whiteWinRate = 0; double blackWinRate = 0; diff --git a/src/ui/flutter_app/lib/mill/position.dart b/src/ui/flutter_app/lib/mill/position.dart index dd0a194c..91590cfa 100644 --- a/src/ui/flutter_app/lib/mill/position.dart +++ b/src/ui/flutter_app/lib/mill/position.dart @@ -1062,45 +1062,6 @@ class Position { Game.instance.setWhoIsAi(engineTypeBackup); } - bool regret() { - // TODO - final lastMove = recorder!.removeLast(); - if (lastMove == null) return false; - - _grid[lastMove.from] = _grid[lastMove.to]; - _grid[lastMove.to] = lastMove.removed; - board[lastMove.from] = board[lastMove.to]; - board[lastMove.to] = lastMove.removed; - - changeSideToMove(); - - final counterMarks = GameRecorder.fromCounterMarks(lastMove.counterMarks); - recorder!.halfMove = counterMarks.halfMove; - recorder!.fullMove = counterMarks.fullMove; - - if (lastMove.removed != Piece.noPiece) { - // - // Find last remove position (or opening), NativeEngine need - final tempPosition = Position.clone(this); - - final moves = recorder!.reverseMovesToPrevRemove(); - moves.forEach((move) { - // - tempPosition._grid[move.from] = tempPosition._grid[move.to]; - tempPosition._grid[move.to] = move.removed; - - tempPosition._sideToMove = - PieceColor.opponent(tempPosition._sideToMove); - }); - - recorder!.lastPositionWithRemove = tempPosition.fen(); - } - - result = GameResult.pending; - - return true; - } - String movesSinceLastRemove() { int? i = 0; String moves = "";