public void AttackRobot(Dinosaur dinosaur, Robot robot) { DinosaurAttackType attack = new DinosaurAttackType("", 0, 0); bool validInput = true; do { Console.Clear(); Console.WriteLine(dinosaur.type + ": Choose your move."); Console.WriteLine("a. " + dinosaur.attacks[0].type + " b. " + dinosaur.attacks[1].type); Console.WriteLine("c. " + dinosaur.attacks[2].type + " d. " + dinosaur.attacks[3].type); string selection = Console.ReadLine(); switch (selection) { case "a": attack = dinosaur.attacks[0]; validInput = false; break; case "b": attack = dinosaur.attacks[1]; validInput = false; break; case "c": attack = dinosaur.attacks[2]; validInput = false; break; case "d": attack = dinosaur.attacks[3]; validInput = false; break; default: Console.Clear(); Console.WriteLine("Please enter the letter corresponding to the weapon."); break; } } while (validInput); dinosaur.energy -= 10; int accuracy = attack.accuracy; int power = attack.power; Random random = new Random(); int random1 = random.Next(1, 101); if (random1 <= accuracy) { robot.health -= power; if (robot.health < 0) { robot.health = 0; } Console.Clear(); Console.WriteLine(dinosaur.type + " has attacked " + robot.name + "!"); Console.WriteLine(dinosaur.type + "'s energy is now " + dinosaur.energy); Console.WriteLine(robot.name + "'s health is now " + robot.health); Console.WriteLine(); Console.WriteLine("Press Enter to continue"); Console.ReadLine(); } else { Console.Clear(); Console.WriteLine(dinosaur.type + " missed!"); Console.WriteLine(dinosaur.type + "'s energy is now " + dinosaur.energy); Console.WriteLine(robot.name + "'s health is still " + robot.health); Console.WriteLine(); Console.WriteLine("Press Enter to continue"); Console.ReadLine(); } }
public DinosaurAttackType ChooseDinoAttack() { DinosaurAttackType attack = new DinosaurAttackType("", 0, 0); bool run = true; do { Console.WriteLine("Choose an attack:"); Console.WriteLine(); Console.WriteLine("a. Bite b. Stomp c. Scratch"); Console.WriteLine("d. Tail Whip e. Growl f. Roar"); Console.WriteLine("g. Body Slam h. Piledriver i. Slap"); Console.WriteLine("j. Spit k. Punch l. Kick"); Console.WriteLine("m. Hug n. Lick o. Headbutt"); Console.WriteLine("p. Stampede q. Stare r. Dance"); string selection = Console.ReadLine(); switch (selection) { case "a": attack.type = "Bite"; attack.power = 30; attack.accuracy = 90; run = false; break; case "b": attack.type = "Stomp"; attack.power = 80; attack.accuracy = 30; run = false; break; case "c": attack.type = "Scratch"; attack.power = 10; attack.accuracy = 80; run = false; break; case "d": attack.type = "Tail Whip"; attack.power = 40; attack.accuracy = 90; run = false; break; case "e": attack.type = "Growl"; attack.power = 3; attack.accuracy = 95; run = false; break; case "f": attack.type = "Roar"; attack.power = 4; attack.accuracy = 94; run = false; break; case "g": attack.type = "Body Slam"; attack.power = 26; attack.accuracy = 98; run = false; break; case "h": attack.type = "Piledriver"; attack.power = 60; attack.accuracy = 60; run = false; break; case "i": attack.type = "Slap"; attack.power = 10; attack.accuracy = 98; run = false; break; case "j": attack.type = "Spit"; attack.power = 15; attack.accuracy = 90; run = false; break; case "k": attack.type = "Punch"; attack.power = 10; attack.accuracy = 93; run = false; break; case "l": attack.type = "Kick"; attack.power = 20; attack.accuracy = 80; run = false; break; case "m": attack.type = "Hug"; attack.power = 15; attack.accuracy = 90; run = false; break; case "n": attack.type = "Lick"; attack.power = 10; attack.accuracy = 93; run = false; break; case "o": attack.type = "Headbutt"; attack.power = 30; attack.accuracy = 90; run = false; break; case "p": attack.type = "Stampede"; attack.power = 45; attack.accuracy = 97; run = false; break; case "q": attack.type = "Stare"; attack.power = 0; attack.accuracy = 100; run = false; break; case "r": attack.type = "Dance"; attack.power = 100; attack.accuracy = 100; run = false; break; default: Console.Clear(); Console.WriteLine("Please enter the letter corresponding to the attack."); break; } }while (run); return(attack); }