Exemple #1
0
        public void GetWinner(int player1Points, int player2Points)
        {
            ConsoleService.CountMessage();
            ConsoleService.Warn(ConsoleService.GetPlayerInfo(_game.Player1));
            ConsoleService.Warn(ConsoleService.GetPlayerInfo(_game.Player2));

            if (player1Points <= Configuration.MAX_VALUE & player2Points > Configuration.MAX_VALUE)
            {
                ConsoleService.Congrat(_game.Player1.Name);
            }
            if (player2Points <= Configuration.MAX_VALUE & player1Points > Configuration.MAX_VALUE)
            {
                ConsoleService.Congrat(_game.Player2.Name);
            }
            if (player2Points > Configuration.MAX_VALUE & player1Points > Configuration.MAX_VALUE)
            {
                ConsoleService.BothLose();
            }
            if (player1Points > player2Points & player1Points <= Configuration.MAX_VALUE)
            {
                ConsoleService.Congrat(_game.Player1.Name);
            }
            if (player1Points < player2Points & player2Points <= Configuration.MAX_VALUE)
            {
                ConsoleService.Congrat(_game.Player2.Name);
            }
            if (player1Points == player2Points & player1Points <= Configuration.MAX_VALUE)
            {
                ConsoleService.NoWinner();
            }
            StartNewGame();
        }
Exemple #2
0
        public void SetPlayersName()
        {
            bool nameIsValid = false;

            while (!nameIsValid)
            {
                if (name == string.Empty)
                {
                    name = ConsoleService.AskName();
                }
                if (name != string.Empty)
                {
                    try
                    {
                        _game.Player1.Name = name;
                        nameIsValid        = true;
                    }
                    catch (Exception ex)
                    {
                        ConsoleService.Warn(ex.Message);
                    }
                }
            }
        }
Exemple #3
0
        public bool GetTheDealForComputer(Player player, bool takeSecondPlayer)
        {
            int    player2Points = ConsoleService.GetPlayerScore(_game.Player2);
            string infoPlayer2   = ConsoleService.GetPlayerInfo(_game.Player2);

            ConsoleService.Warn(infoPlayer2);
            while (takeSecondPlayer)
            {
                ConsoleService.AskComputerToTakeACard(_game.Player2.Name);
                player2Points = ConsoleService.GetPlayerScore(player);
                if (player2Points < Configuration.ACCEPTABLE_RISK & takeSecondPlayer)
                {
                    _deckService.Deal(_game.Player2);
                    infoPlayer2   = ConsoleService.GetPlayerInfo(_game.Player2);
                    player2Points = ConsoleService.GetPlayerScore(_game.Player2);
                    ConsoleService.Warn(infoPlayer2);
                    if (player2Points >= Configuration.ACCEPTABLE_RISK)
                    {
                        takeSecondPlayer = false;
                    }
                }
            }
            return(takeSecondPlayer = false);
        }
Exemple #4
0
        public bool GetTheDealForPlayers(Player player, bool takeFirstPlayer)
        {
            int    player1Points = ConsoleService.GetPlayerScore(_game.Player1);
            string infoPlayer1   = ConsoleService.GetPlayerInfo(_game.Player1);

            ConsoleService.Warn(infoPlayer1);
            while (takeFirstPlayer)
            {
                player1Points = ConsoleService.GetPlayerScore(player);
                if (player1Points > Configuration.MAX_VALUE)
                {
                    takeFirstPlayer = false;
                }
                takeFirstPlayer = ConsoleService.AskPlayerToTakeACard(_game.Player1.Name);
                if (player1Points <= Configuration.MAX_VALUE & takeFirstPlayer)
                {
                    _deckService.Deal(_game.Player1);
                    player1Points = ConsoleService.GetPlayerScore(_game.Player1);
                    infoPlayer1   = ConsoleService.GetPlayerInfo(_game.Player1);
                    ConsoleService.Warn(infoPlayer1);
                }
            }
            return(takeFirstPlayer = false);
        }