Ejemplo n.º 1
0
        private void playerMakeMoveHisTurn()
        {
            m_MoveNum         = eMoveNum.FirstMove;
            m_FirstMovePoint  = askPlayingPlayerForMoveCheckMoveAndMakeCoordinate();
            m_FirstMoveSymbol = m_GameBoard.ExposeSymbolAndTakeValue(m_FirstMovePoint);

            m_FormGame.showBoardFromLogic(m_GameBoard.Board, PlayerOne, PlayerTwo);
            m_FormGame.WaitForPushButtom = false;
            m_FormGame.ShowDialog();
            m_FormGame.WaitForPushButtom = true;

            m_MoveNum          = eMoveNum.SecondMove;
            m_SecondMovePoint  = askPlayingPlayerForMoveCheckMoveAndMakeCoordinate();
            m_SecondMoveSymbol = m_GameBoard.ExposeSymbolAndTakeValue(m_SecondMovePoint);

            m_FormGame.showBoardFromLogic(m_GameBoard.Board, PlayerOne, PlayerTwo);
            m_FormGame.WaitForPushButtom = false;
            m_FormGame.ShowDialog();

            if (m_SecondMoveSymbol != m_FirstMoveSymbol)
            {
                cancelLastPlayingPlayerPlay();
            }
            else
            {
                if (m_PlayerTurn == eTurn.PlayerOne)
                {
                    m_PlayerOne.GivePlayerOnePoint();
                    m_GameBoard.PaintCubeInColor(m_FirstMovePoint, m_SecondMovePoint, PlayerOne.Color);
                }
                else
                {
                    m_PlayerTwo.GivePlayerOnePoint();
                    m_GameBoard.PaintCubeInColor(m_FirstMovePoint, m_SecondMovePoint, m_PlayerTwo.Color);
                }

                m_FormGame.showBoardFromLogic(m_GameBoard.Board, PlayerOne, PlayerTwo);
            }

            if (m_PlayerTwo.IsAi() == true)
            {
                m_PlayerTwo.AiBrain.SetCardRevealedFromLastMove(m_FirstMovePoint, m_FirstMoveSymbol, m_SecondMovePoint, m_SecondMoveSymbol);
            }
        }
Ejemplo n.º 2
0
        private void playerMakeMoveHisTurn(GameBoard io_Board, eTurn i_PlayingPlayer)
        {
            eMoveNum   moveNum             = eMoveNum.FirstMove;
            Coordinate firstMoveCoordinate =
                askPlayingPlayerForMoveCheckMoveAndMakeCoordinate(io_Board, i_PlayingPlayer, moveNum, null);
            int symbolOfFirstMove;

            symbolOfFirstMove = m_Ui.representTheBoardWithMove(io_Board, firstMoveCoordinate);

            moveNum = eMoveNum.SecondMove;
            Coordinate secondMoveCoordinate = askPlayingPlayerForMoveCheckMoveAndMakeCoordinate(io_Board, i_PlayingPlayer, moveNum, symbolOfFirstMove);

            int symbolOfSecondMove;

            symbolOfSecondMove = m_Ui.representTheBoardWithMove(io_Board, secondMoveCoordinate);

            if (symbolOfSecondMove != symbolOfFirstMove)
            {
                System.Threading.Thread.Sleep(2000);
                cancelLastPlayingPlayerPlay(io_Board, firstMoveCoordinate, secondMoveCoordinate);
            }
            else
            {
                if (i_PlayingPlayer == eTurn.PlayerOne)
                {
                    m_PlayerOne.GivePlayerOnePoint();
                }
                else
                {
                    m_PlayerTwo.GivePlayerOnePoint();
                }
            }

            if (m_PlayerTwo.IsAi() == true)
            {
                m_PlayerTwo.AiBrain.SetCardRevealedFromLastMove(firstMoveCoordinate, symbolOfFirstMove, secondMoveCoordinate, symbolOfSecondMove);
            }
        }
Ejemplo n.º 3
0
        private Coordinate askPlayingPlayerForMoveAndMakeCoordinate(GameBoard io_Board, eTurn io_PlayingPlayer, eMoveNum io_MoveNum, int?i_SymbolOfFirstMoveCardRevealed)
        {
            Coordinate moveCoordinate;

            if (io_PlayingPlayer == eTurn.PlayerOne)
            {
                moveCoordinate = getMoveFromHumanPlayerAndMakeCoordinate(io_Board);
            }
            else
            {
                if (m_PlayerTwo.IsAi() == true)
                {
                    UI.printComputerMakingAMove();

                    if (io_MoveNum == eMoveNum.FirstMove)
                    {
                        moveCoordinate = m_PlayerTwo.AiBrain.MakingFirstMove();
                    }
                    else
                    {
                        moveCoordinate = m_PlayerTwo.AiBrain.MakingSecondMove(i_SymbolOfFirstMoveCardRevealed.Value);
                    }

                    System.Console.Write(UI.sr_ColSymbol[moveCoordinate.Col]);
                    System.Console.WriteLine(UI.sr_RowSymbol[moveCoordinate.Row]);
                    System.Threading.Thread.Sleep(2000);
                }
                else
                {
                    moveCoordinate = getMoveFromHumanPlayerAndMakeCoordinate(io_Board);
                }
            }

            return(moveCoordinate);
        }
Ejemplo n.º 4
0
        private Coordinate askPlayingPlayerForMoveCheckMoveAndMakeCoordinate(GameBoard io_Board, eTurn io_PlayingPlayer, eMoveNum i_MoveNum, int?i_SymbolOfFirstMoveCardRevealed)
        {
            Coordinate moveCoordinate;
            bool       v_AlreadyExposed;

            do
            {
                m_Ui.printMakeAMove(m_PlayerOne.NameOfPlayer, m_PlayerTwo.NameOfPlayer, io_PlayingPlayer);
                moveCoordinate   = askPlayingPlayerForMoveAndMakeCoordinate(io_Board, io_PlayingPlayer, i_MoveNum, i_SymbolOfFirstMoveCardRevealed);
                v_AlreadyExposed = CheckInput.IssueErrorMessageExposedCube(CheckIfCoordinateisExposed(io_Board, moveCoordinate));
            }while (v_AlreadyExposed == true);

            return(moveCoordinate);
        }