Exemple #1
0
 public void TakeDamage(Weapon weapon, Dinosaur dinosaur, Herd herd)
 {
     hitPoints = (hitPoints - weapon.attackPower);
     Console.WriteLine($"{type} took {weapon.attackPower} damage!");
     Console.WriteLine($"{type} has {hitPoints} HP remaining!");
     if (dinosaur.hitPoints <= 0)
     {
         herd.RemoveFromHerd(dinosaur);
     }
 }
        public void RunBattlefield()
        {
            Herd battleHerd = new Herd();

            battleHerd.RunHerd();
            Fleet battleFleet = new Fleet();

            battleFleet.RunFleet();



            while (battleHerd.herd.Count > 0 && battleFleet.fleet.Count > 0)
            {
                battleHerd.herd[0].DinosaurUserPrompt(battleFleet.fleet[0], battleHerd.herd[0], battleFleet, battleHerd);
                Console.WriteLine();
                battleFleet.fleet[0].RobotUserPrompt(battleHerd.herd[0], battleHerd, battleFleet.fleet[0], battleFleet);
                Console.WriteLine();
            }
        }
Exemple #3
0
        public void DinosaurUserPrompt(Robot robot, Dinosaur dinosaur, Fleet fleet, Herd herd)
        {
            if (dinosaur.hitPoints <= 0)
            {
                herd.RemoveFromHerd(dinosaur);
            }

            else
            {
                Console.WriteLine($"Would you like {type} to attack or rest?");
                string answer = Console.ReadLine();

                if (answer.Equals("attack", StringComparison.OrdinalIgnoreCase))
                {
                    Attack();
                    Console.WriteLine($"{dinosaur.type} has {energy} energy remaining");
                    robot.TakeDamage(dinosaur, robot, fleet);
                }

                else if (answer.Equals("rest", StringComparison.OrdinalIgnoreCase))
                {
                    if (energy < 100)
                    {
                        Rest();
                    }

                    else
                    {
                        Console.WriteLine($"{type} already has full energy.");
                        Console.WriteLine("Please make a valid selction");
                        DinosaurUserPrompt(robot, dinosaur, fleet, herd);
                    }
                }

                else
                {
                    Console.WriteLine("Please make a valid selection");
                    DinosaurUserPrompt(robot, dinosaur, fleet, herd);
                }
            }
        }
        public void RobotUserPrompt(Dinosaur dinosaur, Herd herd, Robot robot, Fleet fleet)
        {
            if (robot.hitPoints <= 0)
            {
                fleet.RemoveFromFleet(robot);
            }

            else
            {
                Console.WriteLine($"Would you like {robotName} to attack or recharge?");
                string answer = Console.ReadLine();

                if (answer.Equals("attack", StringComparison.OrdinalIgnoreCase))
                {
                    Attack(weapon);
                    Console.WriteLine($"{robotName} has {powerLevel} power remaining!");
                    dinosaur.TakeDamage(weapon, dinosaur, herd);
                }
                else if (answer.Equals("recharge", StringComparison.OrdinalIgnoreCase))
                {
                    if (powerLevel < 100)
                    {
                        Recharge();
                    }

                    else
                    {
                        Console.WriteLine($"{robotName} already has full power.");
                        Console.WriteLine("Please make a valid selction");
                        RobotUserPrompt(dinosaur, herd, robot, fleet);
                    }
                }

                else
                {
                    Console.WriteLine("Please make a valid selection");
                    RobotUserPrompt(dinosaur, herd, robot, fleet);
                }
            }
        }