Example #1
0
        public override BoardMinified UndoRule(BoardMinified board, HistoryItemMinified toUndo,
                                               HistoryItemMinified lastMoveBeforeUndo)
        {
            if (
                lastMoveBeforeUndo != null &&
                toUndo.IsKill &&
                lastMoveBeforeUndo.IsKill &&
                toUndo.Player == lastMoveBeforeUndo.Player)
            {
                var piece = board.GetPiece(toUndo.From.X, toUndo.From.Y, toUndo.Player);
                piece.ClearMoves();

                var newPiece = NeedToCaptureRule.Check(piece, board, board.GetSize());
                if (newPiece.HasAvailableMoves())
                {
                    board.ClearMoves();
                    board.UpdatePieceAvailableMoves(newPiece, toUndo.Player);

                    if (board.ActivePlayer != lastMoveBeforeUndo.Player)
                    {
                        board.SwitchPlayers();
                    }

                    return(board);
                }
            }

            return(NextUndo(board, toUndo, lastMoveBeforeUndo));
        }
Example #2
0
        public override BoardMinified UndoRule(BoardMinified board, HistoryItemMinified toUndo,
                                               HistoryItemMinified lastMoveBeforeUndo)
        {
            if (board.ActivePlayer != toUndo.Player)
            {
                board.SwitchPlayers();
            }

            return(NextUndo(board, toUndo, lastMoveBeforeUndo));
        }
Example #3
0
 public override BoardMinified ApplyRule(BoardMinified board, HistoryItemMinified latestMove)
 {
     board.SwitchPlayers();
     return(Next(board, latestMove));
 }