コード例 #1
0
        private void checkGameStatus()
        {
            List <Move> diagonalMovesOfPlayer1 = m_BoardGame.GetListOfPlayerDiagonalMoves(Player.eShapeType.X);
            List <Move> diagonalMovesOfPlayer2 = m_BoardGame.GetListOfPlayerDiagonalMoves(Player.eShapeType.O);
            List <Move> jumpsMovesOfPlayer1    = m_BoardGame.GetListOfPlayerJumps(Player.eShapeType.X);
            List <Move> jumpsMovesOfPlayer2    = m_BoardGame.GetListOfPlayerJumps(Player.eShapeType.O);

            if (diagonalMovesOfPlayer1.Count == 0 && diagonalMovesOfPlayer2.Count == 0 && jumpsMovesOfPlayer1.Count == 0 && jumpsMovesOfPlayer2.Count == 0)
            {
                this.m_GameStatus = eGameStatus.Draw;
            }
            else
            {
                if ((diagonalMovesOfPlayer1.Count == 0 && jumpsMovesOfPlayer1.Count == 0) || (m_BoardGame.GetPointsOfPlayer(m_Player1.GetShapeType()) == 0))
                {
                    this.m_GameStatus = eGameStatus.Lose;
                    m_Player2.Points  = (m_BoardGame.GetPointsOfPlayer(m_Player2.GetShapeType()) - m_BoardGame.GetPointsOfPlayer(m_Player1.GetShapeType()));
                }
                else
                {
                    if ((diagonalMovesOfPlayer2.Count == 0 && jumpsMovesOfPlayer2.Count == 0) || (m_BoardGame.GetPointsOfPlayer(m_Player2.GetShapeType()) == 0))
                    {
                        this.m_GameStatus = eGameStatus.Winner;
                        m_Player1.Points  = (m_BoardGame.GetPointsOfPlayer(m_Player1.GetShapeType()) - m_BoardGame.GetPointsOfPlayer(m_Player2.GetShapeType()));
                    }
                }
            }
        }
コード例 #2
0
        public bool isValidMove(Move i_CurrentMove, Player i_PlayerTurn)
        {
            bool isValid = false;

            if (i_PlayerTurn.IsJumpTurn)
            {
                if (isContainsMoveElement(m_LegalJumps, i_CurrentMove))
                {
                    isValid = true;
                    i_CurrentMove.MoveType = Move.eTypeOfMove.Jump;
                }
            }
            else
            {
                List <Move> playerJumpMoves = m_BoardGame.GetListOfPlayerJumps(i_PlayerTurn.GetShapeType());

                if (playerJumpMoves.Count > 0)
                {
                    if (isContainsMoveElement(playerJumpMoves, i_CurrentMove))
                    {
                        isValid = true;
                        i_CurrentMove.MoveType  = Move.eTypeOfMove.Jump;
                        i_PlayerTurn.IsJumpTurn = true;
                    }
                    else
                    {
                        i_PlayerTurn.IsJumpTurn = false;
                        // InvalidMove.Invoke(this, EventArgs.Empty);
                        isValid = false;
                    }
                }
                else
                {
                    if (i_CurrentMove.CheckIsValidMove(i_PlayerTurn.GetShapeType()))
                    {
                        isValid = true;
                        i_CurrentMove.MoveType = Move.eTypeOfMove.Regular;
                    }
                    else
                    {
                        isValid = false;
                        // InvalidMove.Invoke(this, EventArgs.Empty);
                    }
                }
            }

            return(isValid);
        }
コード例 #3
0
        private void playCurrentPlayerTurn(Move i_CurrentMove, Player i_PlayerTurn, Player i_NotPlayerTurn)
        {
            bool isValid = isValidMove(i_CurrentMove, i_PlayerTurn);

            if (!isValid)
            {
                InvalidMove.Invoke(this, EventArgs.Empty);
            }
            else
            {
                MakeMove.Invoke(i_CurrentMove, EventArgs.Empty);
                i_CurrentMove.MoveOnBoard(m_BoardGame);

                if (i_PlayerTurn.IsJumpTurn)
                {
                    if (hasAnotherJump(i_CurrentMove, i_PlayerTurn))
                    {
                        m_LegalJumps = getListOfJumpsForPiece(i_PlayerTurn.GetShapeType(), i_CurrentMove.ToSquare);
                    }
                    else
                    {
                        v_Turn = !v_Turn;
                        i_PlayerTurn.IsJumpTurn = false;
                    }
                }
                else
                {
                    v_Turn = !v_Turn;
                }
            }
        }
コード例 #4
0
        private bool hasAnotherJump(Move i_CurrentMove, Player i_PlayerTurn)
        {
            List <Move> playerSecondJumps = getListOfJumpsForPiece(i_PlayerTurn.GetShapeType(), i_CurrentMove.ToSquare);

            return((playerSecondJumps.Count > 0) ? true : false);
        }