Exemplo n.º 1
0
        public GameResult movingPhase()
        {
            GameResult gameState = referee.getGameState(xPlayer, oPlayer, gameBoard);
            MoveAction act       = MoveAction.Move;

            currPlayer = xPlayer;
            while (gameState == GameResult.NotWon)
            {
                gameBoard.Display($@"X cows: {gameBoard.numCows(Player.X)} O cows: {gameBoard.numCows(Player.O)}");

                if (act == MoveAction.Move)
                {
                    switch (gameBoard.Move(currPlayer, referee))
                    {
                    case MoveResult.InvalidPickUp: break;

                    case MoveResult.InvalidPutDown: break;

                    case MoveResult.MillMade: act = MoveAction.Shoot;  break;

                    case MoveResult.Done:
                        if (currPlayer == xPlayer)
                        {
                            currPlayer = oPlayer;
                        }
                        else
                        {
                            currPlayer = xPlayer;
                        }
                        break;
                    }
                }
                else
                {
                    if (gameBoard.Shoot(currPlayer, referee) == ShootResult.Done)
                    {
                        act = MoveAction.Move;
                        if (currPlayer == xPlayer)
                        {
                            currPlayer = oPlayer;
                        }
                        else
                        {
                            currPlayer = xPlayer;
                        }
                    }
                }
                gameState = referee.getGameState(xPlayer, oPlayer, gameBoard);
            }
            gameBoard.Display($@"X cows: {gameBoard.numCows(Player.X)} O cows: {gameBoard.numCows(Player.O)}");
            return(gameState);
        }