Ejemplo n.º 1
0
        public override void Update(Player player)
        {
            playerInput = Console.ReadLine();
            bool playerInputIsValid = false;

            while (!playerInputIsValid)
            {
                if (playerInput != "attack" && playerInput != "spell" && playerInput != "view stats" && playerInput != "run away" &&
                    playerInput != "cast fire" && playerInput != "cast thunder")
                {
                    Console.WriteLine("Wrong command given, please enter a new command");
                    playerInput = Console.ReadLine();
                    playerInput = playerInput.ToLower();
                }
                else
                {
                    playerInputIsValid = true;
                }
            }

            DetermineTurn(player, player.CurrentLocation.CurrentEnemy);

            if (playerTurn)
            {
                playerTurn = false;
                //InputManager.ManageBattleStateInput(player, player.CurrentLocation.CurrentEnemy, playerInput);
                if (Player.PlayerState == Player.State.Travel)
                {
                    return;
                }
                if (player.CurrentLocation.CurrentEnemy.CurrentHealth <= 0)
                {
                    Console.WriteLine("{0} killed a {1}", player.Name, player.CurrentLocation.CurrentEnemy.Name);
                    player.GainExperience(player.CurrentLocation.CurrentEnemy.ExperiencePoints);
                    Player.PlayerState = Player.State.Travel;
                    return;
                }

                player.CurrentLocation.CurrentEnemy.AttackCommand(player);
                if (player.CurrentHealth <= 0)
                {
                    Console.WriteLine("{0} was killed by a {1}", player.Name, player.CurrentLocation.CurrentEnemy.Name);
                    Player.PlayerState = Player.State.GameOver;
                    return;
                }
            }
            else
            {
                playerTurn = true;
                player.CurrentLocation.CurrentEnemy.AttackCommand(player);
                if (player.CurrentHealth <= 0)
                {
                    Console.WriteLine("{0} was killed by a {1}", player.Name, player.CurrentLocation.CurrentEnemy.Name);
                    Player.PlayerState = Player.State.GameOver;
                    return;
                }

                //InputManager.ManageBattleStateInput(player, player.CurrentLocation.CurrentEnemy, playerInput);
                if (player.CurrentLocation.CurrentEnemy.CurrentHealth <= 0)
                {
                    Console.WriteLine("{0} killed a {1}", player.Name, player.CurrentLocation.CurrentEnemy.Name);
                    player.GainExperience(player.CurrentLocation.CurrentEnemy.ExperiencePoints);
                    Player.PlayerState = Player.State.Travel;
                    return;
                }
            }
        }