コード例 #1
0
ファイル: Board.cs プロジェクト: Sossenbinder/Chess
        private void PerformMove(Tile tile)
        {
            var chessPieceToMove            = m_selectedTile.GetChessPiece();
            var previousChessPieceOnNewTile = tile.GetChessPiece();

            m_selectedTile.SetChessPiece(null);

            //Convert pawn to queen if it got through
            if (chessPieceToMove.GetChessPieceType() == ChessPieceType.Pawn /*TODO*/)
            {
                tile.SetChessPiece(chessPieceToMove);
            }
            else
            {
                tile.SetChessPiece(chessPieceToMove);
            }

            var moveInformation = new Move(new BoardPosition(m_selectedTile.GetBoardPosition().X, m_selectedTile.GetBoardPosition().Y),
                                           new BoardPosition(tile.GetBoardPosition().X, tile.GetBoardPosition().Y));

            if (!m_validSpecialMove.Equals(SpecialMove.None))
            {
                CheckForSpecialMove(moveInformation);
            }

            chessPieceToMove.Move(moveInformation);

            if (previousChessPieceOnNewTile != null)
            {
                if (previousChessPieceOnNewTile.GetColor().Equals(ChessColor.Black))
                {
                    m_blackGraveyard.AddDeadChessPieces(previousChessPieceOnNewTile);
                }
                else
                {
                    m_whiteGraveyard.AddDeadChessPieces(previousChessPieceOnNewTile);
                }
            }

            if (m_activeColor.Equals(ChessColor.White))
            {
                m_whiteHistory.AddMove(moveInformation);
                m_activeColor = ChessColor.Black;
            }
            else
            {
                m_blackHistory.AddMove(moveInformation);
                m_activeColor = ChessColor.White;
            }
        }
コード例 #2
0
 public void playerturn()
 {
     PlayerTurn.Text = round.Equals(ChessColor.White) ? "Player 1 - White side " : "Player 2 - Black side";
 }