예제 #1
0
        public void FinalizeWeenieMove(ChessMoveResult result)
        {
            var move = Logic.GetLastMove();

            Log.Add(move);

            // need to use destination coordinate as Logic has already moved the piece
            var piece = Logic.GetPiece(move.To);

            if (result.HasFlag(ChessMoveResult.OKMoveToEmptySquare))
            {
                MoveWeeniePiece(piece);

                var flags = move.Flags;
                if ((flags & (ChessMoveFlag.KingSideCastle | ChessMoveFlag.QueenSideCastle)) != 0)
                {
                    var castlingTo = new ChessPieceCoord(move.To);
                    if (flags.HasFlag(ChessMoveFlag.KingSideCastle))
                    {
                        castlingTo.MoveOffset(-1, 0);
                    }
                    if (flags.HasFlag(ChessMoveFlag.QueenSideCastle))
                    {
                        castlingTo.MoveOffset(1, 0);
                    }

                    var rookPiece = Logic.GetPiece(castlingTo);
                    Debug.Assert(rookPiece != null);

                    MoveWeeniePiece(rookPiece);
                }
            }
            else if (result.HasFlag(ChessMoveResult.OKMoveToOccupiedSquare))
            {
                AttackWeeniePiece(piece, move.CapturedGuid);
            }
        }
예제 #2
0
        public void PieceReady(ObjectGuid pieceGuid)
        {
            if (MoveResult.HasFlag(ChessMoveResult.OKMovePromotion))
            {
                var piece = Logic.GetPiece(pieceGuid);
                Debug.Assert(piece != null);
                UpgradeWeeniePiece(piece);
            }

            Motions.Remove(pieceGuid);
            if (Motions.Count == 0)
            {
                WaitingForMotion = false;
                FinishTurn();
            }
        }