Ejemplo n.º 1
0
        internal void MoveOnBoard(BoardGame i_BoardGame)
        {
            Square fromSquare = i_BoardGame.GetSquare(this.FromSquare.Row, this.FromSquare.Column);
            Square toSquare   = i_BoardGame.GetSquare(this.ToSquare.Row, this.ToSquare.Column);

            switch (this.MoveType)
            {
            case (eTypeOfMove.Regular):

                if (fromSquare.Type == Square.eSquareType.X && toSquare.Row == 0)
                {
                    toSquare.Type = Square.eSquareType.K;
                }

                else
                if (fromSquare.Type == Square.eSquareType.O && toSquare.Row == i_BoardGame.GetSize() - 1)
                {
                    toSquare.Type = Square.eSquareType.U;
                }
                else
                {
                    toSquare.Type = fromSquare.Type;
                }
                fromSquare.Type = Square.eSquareType.None;

                break;

            case (eTypeOfMove.Jump):
                capturePieceOnBoard(i_BoardGame);

                if (fromSquare.Type == Square.eSquareType.X && toSquare.Row == 0)
                {
                    toSquare.Type = Square.eSquareType.K;
                }

                else
                {
                    if (fromSquare.Type == Square.eSquareType.O && toSquare.Row == i_BoardGame.GetSize() - 1)
                    {
                        toSquare.Type = Square.eSquareType.U;
                    }
                    else
                    {
                        toSquare.Type = fromSquare.Type;
                    }
                }
                fromSquare.Type = Square.eSquareType.None;
                break;
            }


            i_BoardGame.PrintBoard();
        }
Ejemplo n.º 2
0
        public void capturePieceOnBoard(BoardGame i_BoardGame)
        {
            int rowOfCapturPiece    = 0;
            int columnOfCapturPiece = 0;

            if (m_FromSquare.Row > m_ToSquare.Row)
            {
                rowOfCapturPiece = m_FromSquare.Row - 1;

                if (m_FromSquare.Column > m_ToSquare.Column)
                {
                    columnOfCapturPiece = m_FromSquare.Column - 1;
                }
                else
                {
                    columnOfCapturPiece = m_FromSquare.Column + 1;
                }
            }
            else
            {
                rowOfCapturPiece = m_FromSquare.Row + 1;

                if (m_FromSquare.Column > m_ToSquare.Column)
                {
                    columnOfCapturPiece = m_FromSquare.Column - 1;
                }
                else
                {
                    columnOfCapturPiece = m_FromSquare.Column + 1;
                }
            }

            i_BoardGame.GetSquare(rowOfCapturPiece, columnOfCapturPiece).Type = Square.eSquareType.None;
        }
Ejemplo n.º 3
0
        public void GameRound(Move i_CurrentMove)
        {
            i_CurrentMove.FromSquare = m_BoardGame.GetSquare(i_CurrentMove.FromSquare.Row, i_CurrentMove.FromSquare.Column);
            i_CurrentMove.ToSquare   = m_BoardGame.GetSquare(i_CurrentMove.ToSquare.Row, i_CurrentMove.ToSquare.Column);

            if (this.m_GameStatus == eGameStatus.NotFinished)
            {
                if (v_Turn)
                {
                    playCurrentPlayerTurn(i_CurrentMove, m_Player1, m_Player2);
                }
                else
                {
                    if (m_Player2.PlayerType == Player.ePlayerType.Person)
                    {
                        playCurrentPlayerTurn(i_CurrentMove, m_Player2, m_Player1);
                    }
                }

                checkGameStatus();
                if (this.m_GameStatus == eGameStatus.NotFinished)
                {
                    if (!v_Turn)
                    {
                        if (m_Player2.PlayerType == Player.ePlayerType.Computer)
                        {
                            PlayComputerTurn();
                        }
                    }
                }
            }

            checkGameStatus();
            if (this.m_GameStatus != eGameStatus.NotFinished)
            {
                if (this.m_GameStatus == eGameStatus.Winner)
                {
                    EndGameRound.Invoke(Player1, EventArgs.Empty);
                }
                else
                {
                    EndGameRound.Invoke(Player2, EventArgs.Empty);
                }
            }
        }