Esempio n. 1
0
        public void UpdatePiecesAfterActionUndo(GameAction action)
        {
            UIPiece piece = GetPieceByPos(action.To);

            piece.UpdatePosition(action.From);

            if (action.Capture != null)
            {
                ulong     capturedBB        = BitboardUtils.GetBitboard(action.Capture.Value);
                PieceType capturedPieceType = gameState.GetPieceBySquare(1 - gameState.Turn, capturedBB).Value;
                CreatePiece(capturedPieceType, 1 - gameState.Turn, action.Capture.Value);
            }

            if (action.ChangeType != null)
            {
                ulong     fromBB            = BitboardUtils.GetBitboard(action.From);
                PieceType originalPieceType = gameState.GetPieceBySquare(gameState.Turn, fromBB).Value;
                piece.ChangeType(originalPieceType);
            }

            if (action.ExtraAction != null)
            {
                UpdatePiecesAfterActionUndo(action.ExtraAction);
            }
        }
Esempio n. 2
0
        public void UpdatePiecesAfterAction(GameAction action)
        {
            if (action.Capture != null)
            {
                CapturePiece(action.Capture.Value);
            }

            UIPiece piece = GetPieceByPos(action.From);

            piece.UpdatePosition(action.To);
            if (action.ChangeType != null)
            {
                piece.ChangeType(action.ChangeType.Value);
            }

            if (action.ExtraAction != null)
            {
                UpdatePiecesAfterAction(action.ExtraAction);
            }
        }