public void Attack(Trooper enemy) { if (enemy == null || enemy.Health < 1) { Console.WriteLine("Attack Failed"); Console.WriteLine(" "); } else { int damage = Strength * 5; Console.WriteLine($"...Attacking {enemy.Name} with lightsaber..."); enemy.Health -= damage; Console.WriteLine($"Dealt {damage} damage!"); Console.WriteLine(" "); if (enemy.Health > 0) { Console.WriteLine($"{enemy.Name} has {enemy.Health} health remaining"); Console.WriteLine(" "); } else { Console.WriteLine($"{enemy.Name} eliminated from the battlefield"); } Console.WriteLine("Press enter to continue..."); Console.ReadLine(); } }
public void ForcePush(Trooper enemy) { Random rand = new Random(); if (enemy == null || enemy.Health < 1) { Console.WriteLine("Attack Failed"); Console.WriteLine(" "); } else { int damage = rand.Next(10, 25); Console.WriteLine($"...Attacking {enemy.Name} with force push... "); enemy.Health -= damage; Console.WriteLine($"Dealt {damage} damage!"); Console.WriteLine(" "); if (enemy.Health > 0) { Console.WriteLine($"{enemy.Name} has {enemy.Health} health remaining"); Console.WriteLine(" "); } else { Console.WriteLine($"{enemy.Name} eliminated from the battlefield"); } Console.WriteLine("Press enter to continue..."); Console.ReadLine(); } }
public void ThrowLightsaber(Trooper enemy) { if (enemy == null || enemy.Health < 1) { Console.WriteLine("Attack Failed"); } else { int damage = (Intelligence * 2) + Dexterity; Console.WriteLine($"...Attacking {enemy.Name} by throwing lightsaber "); enemy.Health -= damage; Console.WriteLine($"Dealt {damage} damage"); Console.WriteLine(" "); if (enemy.Health > 0) { Console.WriteLine($"{enemy.Name} has {enemy.Health} health remaining"); Console.WriteLine(" "); } else { Console.WriteLine($"{enemy.Name} eliminated from the battlefield"); } Console.WriteLine("Press enter to continue..."); Console.ReadLine(); } }
// create a system for a computer controlled return public static int[] ComputerTurn(Trooper trooper, List <Jedi> jediList) { Random rand = new Random(); Console.WriteLine($"It is now {trooper.Name}'s turn..."); Console.WriteLine(" "); trooper.DisplayStats(); Console.WriteLine(" "); /* create a an array of length 2 with a player probability and action probability * player probability will determine which jedi the computer will attack * action probability will determine which action the computer will take */ int playerProbability = rand.Next(0, jediList.Count); int actionProbability = rand.Next(0, 3); int[] probabilityArr = new int[2] { playerProbability, actionProbability }; return(probabilityArr); }
public void ForceLightning(Trooper enemy) { if (enemy == null || enemy.Health < 1) { Console.WriteLine("Attack Failed"); Console.WriteLine(" "); } else if (enemy != null && enemy.Health >= 50) { Console.WriteLine("Force lignthing failed. Enemy must have less that 50 health."); Attack(enemy); if (enemy.Health > 0) { Console.WriteLine($"{enemy.Name} has {enemy.Health} health remaining"); Console.WriteLine(" "); } else { Console.WriteLine($"{enemy.Name} eliminated from the battlefield"); } } else if (enemy != null && enemy.Health < 50) { Console.WriteLine($"...Attacking {enemy.Name} with force lighnting"); enemy.Health = 0; Console.WriteLine($"The lightning consumed {enemy.Name}"); Console.WriteLine(" "); if (enemy.Health > 0) { Console.WriteLine($"{enemy.Name} has {enemy.Health} health remaining"); Console.WriteLine(" "); } else { Console.WriteLine($"{enemy.Name} eliminated from the battlefield"); } Console.WriteLine("Press enter to continue..."); Console.ReadLine(); } }