public static void startBattle(Warrior warrior1, Warrior warrior2) { while (warrior1.IsAlive && warrior2.IsAlive) { if (rng.Next(0, 10) < 5) { warrior1.Attack(warrior2); } else { warrior2.Attack(warrior1); } Thread.Sleep(150); } }
static void Main(string[] args) { Warrior goodGuy = new Warrior("Conan", Faction.GoodGuy); Warrior badGuy = new Warrior("Krul", Faction.BadGuy); // Fill up randomly the warriors List for (int i = 0; i < 20; i++) { if (rng.Next(0, 10) < 5) { // warriors[i] = new Warrior("Conan" + i, Faction.GoodGuy); warriors.Add(new Warrior("Beast" + i, Faction.GoodGuy)); } else { // warriors[i] = new Warrior("Grull" + i, Faction.BadGuy); warriors.Add(new Warrior("Grull" + i, Faction.BadGuy)); } } // IDK some advanced technique to simplify the code var goodguya = warriors.Where(w => w.IsAlive && w.FACTION == Faction.GoodGuy).ToList(); var badguya = (from w in warriors where w.IsAlive == true && w.FACTION == Faction.BadGuy select w).ToList(); while ((goodGuy.IsAlive && badGuy.IsAlive)) { // Between 0-10, so 50% chance if (rng.Next(0, 10) < 5) { goodGuy.Attack(badGuy); } // if its bigger than 5 the bad guy attack else { badGuy.Attack(goodGuy); } Thread.Sleep(100); } System.Console.ReadLine(); }
static void Main(string[] args) { Warrior goodGuy = new Warrior("Harry", Faction.GoodGuy); Warrior badGuy = new Warrior("Voldemort", Faction.BadGuy); while (goodGuy.IsAlive && badGuy.IsAlive) { if (rng.Next(0, 10) < 5) { goodGuy.Attack(badGuy); } else { badGuy.Attack(goodGuy); } } }
// randomly select an action for the cpu to take // returns the attack value or defend value static int CPUChoice(Warrior cpu, string action) { int randNum = new Random().Next(0, 2); if (string.Equals(action, "offense")) { return((randNum == 0) ? cpu.Attack() : cpu.PowerfulStrike()); } else if (string.Equals(action, "defense")) { return((randNum == 0) ? cpu.Defend() : cpu.Counter()); } else { return(-1); } }
static void Main(string[] args) { Warrior goodGuy = new Warrior("Dunka", Enum.Faction.GoodBoy); Warrior badGuy = new Warrior("Dunty", Enum.Faction.BadBoy); while (goodGuy.IsAlive && badGuy.IsAlive) { if (rnd.Next(0, 10) < 5) { goodGuy.Attack(badGuy); } else { badGuy.Attack(goodGuy); } } }
static void Main() { Warrior goodGuy = new Warrior("Bob", Faction.GoodGuy); Warrior badGuy = new Warrior("Joe", Faction.BadGuy); while (goodGuy.IsAlive && badGuy.IsAlive) { if (rng.Next(0, 10) < 5) { goodGuy.Attack(badGuy); } else { badGuy.Attack(goodGuy); } } }
static void Main() { Warrior goodGuy = new Warrior("Obi-Wan", Faction.LightSide); Warrior badGuy = new Warrior("Anakin", Faction.DarkSide); while (goodGuy.IsAlive && badGuy.IsAlive) { if (rng.Next(0, 10) < 5) { goodGuy.Attack(badGuy); } else { badGuy.Attack(goodGuy); } } }
static void Main(string[] args) { Warrior goodGuy = new Warrior("Bob", Faction.GoodGuy); Warrior badGuy = new Warrior("Joe", Faction.BadGuy); while (goodGuy.IsAlive && badGuy.IsAlive) { if (rng.Next(0, 10) < 5) { goodGuy.Attack(badGuy); } else { badGuy.Attack(goodGuy); } Thread.Sleep(200); } }
static void Main() { Warrior goodGuy = new Warrior("Kamil", Faction.GoodGuy); Warrior badGuy = new Warrior("Michał", Faction.BadGuy); while (goodGuy.IsAlive && badGuy.IsAlive) { if (rnd.Next(0, 10) < 5) { goodGuy.Attack(badGuy); } else { badGuy.Attack(goodGuy); } Thread.Sleep(250); } }
static void Main() { Warrior goodGuy = new Warrior("Eldar", Faction.GoodGuy); Warrior badGuy = new Warrior("Adela", Faction.BadGuy); while (goodGuy.IsAlive && badGuy.IsAlive) { if (rng.Next(0, 10) < 5) { goodGuy.Attack(badGuy); } else { badGuy.Attack(goodGuy); } Thread.Sleep(150); } }
static void Main(string[] args) { Warrior goodGuy = new Warrior("Kirito", Faction.GoodGuy); Warrior badGuy = new Warrior("Heithcliff", Faction.BadGuy); while (goodGuy.IsAlive && badGuy.IsAlive) { if (random.Next(0, 100) < 50) { goodGuy.Attack(badGuy); } else { badGuy.Attack(goodGuy); } Thread.Sleep(200); } }
static void Main() { Warrior goodGuy = new Warrior("Aanand", Faction.GoodGuy); Warrior badGuy = new Warrior("El chapo", Faction.BadGuy); while (goodGuy.IsAlive && badGuy.IsAlive) { if (rand.Next(0, 10) < 5) { goodGuy.Attack(badGuy); } else { badGuy.Attack(goodGuy); } Thread.Sleep(50); } }
static void Main() { Warrior goodGuy = new Warrior("Maximus", Faction.GoodGuy); Warrior badGuy = new Warrior("Delirious", Faction.BadGuy); while (goodGuy.IsAlive && badGuy.IsAlive) { if (rng.Next(0, 10) < 5) { goodGuy.Attack(badGuy); } else { badGuy.Attack(goodGuy); } Thread.Sleep(100); } }
static void Main() { Warrior goodGuy = new Warrior("Low", Enum.Faction.GoodGuy); Warrior badGuy = new Warrior("John", Enum.Faction.BadGuy); while (goodGuy.IsAlive && badGuy.IsAlive) { if (rng.Next(0, 10) < 5) { goodGuy.Attack(badGuy); } else { badGuy.Attack(goodGuy); } System.Threading.Thread.Sleep(100); } }
static void Main() { Warrior goodGuy = new Warrior("Bob", Faction.GoodGuy); Warrior badGuy = new Warrior("Job", Faction.BadGuy); while (goodGuy.IsAlive && badGuy.IsAlive) { if (rng.Next(0, 10) < 5) { goodGuy.Attack(badGuy); } else { badGuy.Attack(goodGuy); } Thread.Sleep(100); } // Keep the console window open in debug mode. Console.WriteLine("Press any key to exit."); Console.ReadKey(); }
static void Main(string[] args) { Random random = new Random(); Warrior goodGuy = new Warrior("Eric", Faction.GoodGuy); Warrior badGuy = new Warrior("John", Faction.BadGuy); while (goodGuy.IsAlive && badGuy.IsAlive) { if (random.Next(1, 10) < 5) { goodGuy.Attack(badGuy); } else { badGuy.Attack(goodGuy); } Thread.Sleep(50); } Tools.ColorfulWriteLine(Construct.text, ConsoleColor.DarkCyan); }
static void Main() { Warrior goodGuy = new Warrior("Bob", Faction.GoodGuy); Warrior badGuy = new Warrior("Joe", Faction.BadGuy); while (goodGuy.IsAlive && badGuy.IsAlive) { /*I THINK the (0,10) means a random number between 1 and 10, the rest should be self explanatory by reading the code*/ if (rng.Next(0, 10) < 5) { goodGuy.Attack(badGuy); } else { badGuy.Attack(goodGuy); } Thread.Sleep(200); } }
static void Main() { Warrior warrior1 = readInName(Enum.Party.Stormtrooper); Warrior warrior2 = readInName(Enum.Party.Resistance); Thread.Sleep(1000); Console.WriteLine("Let the fight begin!"); Console.WriteLine(" "); Thread.Sleep(1000); while (warrior1.Alive && warrior2.Alive) { if (myrandom.Next(0, 10) < 5) { warrior1.Attack(warrior2); } else { warrior2.Attack(warrior1); } Thread.Sleep(200); } }
static void Main() { Console.SetWindowSize(100, 50); Console.WriteLine("Select a class to fight the mighty Monktino! "); Console.WriteLine("1. Weavlock - 50HP, chance to attack again"); Console.WriteLine("2. Pouladin - 60HP, boosted health pool"); Console.WriteLine("3. Hagre - 65HP, highest starting health but is absentminded"); Console.WriteLine("4. Bardston - 40HP chance to steal health from the enemy"); Console.WriteLine("5. KarateCzap - 50HP, chance to paralyze enemy for one turn"); Console.WriteLine("6. Carlsassin - 50HP, slight chance to instantly kill the enemy"); Console.WriteLine("7. Wiserd - 45HP, chance to do blast damage"); Console.WriteLine("8. Jaynger - 50HP, chance to escape battle at low health"); Console.WriteLine("9. Lizard Man - 50HP, chance to regenerate health"); int charClassChoice = int.Parse(Console.ReadLine()); //Faction faction; Warrior goodGuy = new Warrior("GG", Faction.GoodGuy); Warrior badGuy = new Warrior("Monktino", Faction.BadGuy); if (charClassChoice == 1) { goodGuy.name = "Weavlock"; goodGuy.FACTION = Faction.GoodGuy; } else if (charClassChoice == 2) { goodGuy.name = "Pouladin"; goodGuy.FACTION = Faction.Paladin; goodGuy.health = 60; } else if (charClassChoice == 3) { goodGuy.name = "Hagre"; goodGuy.FACTION = Faction.Hagre; } else if (charClassChoice == 4) { goodGuy.name = "Bardston"; goodGuy.FACTION = Faction.Bard; goodGuy.health = 40; } else if (charClassChoice == 5) { goodGuy.name = "KarateCzap"; goodGuy.FACTION = Faction.BlackBelt; } else if (charClassChoice == 6) { goodGuy.name = "Carlsassin"; goodGuy.FACTION = Faction.Assassin; } else if (charClassChoice == 7) { goodGuy.name = "Wiserd"; goodGuy.FACTION = Faction.Wizard; } else if (charClassChoice == 8) { goodGuy.name = "Jaynger"; goodGuy.FACTION = Faction.Ranger; } else if (charClassChoice == 9) { goodGuy.name = "Lizard Man"; goodGuy.FACTION = Faction.LizardMan; } while (goodGuy.IsAlive && badGuy.IsAlive) { if (rng.Next(0, 10) < 5) { goodGuy.Attack(badGuy); if (goodGuy.FACTION == Faction.GoodGuy) { if (rng.Next(0, 100) > 85) { Console.WriteLine("Critical hit! Attack again!"); goodGuy.Attack(badGuy); } } else if (goodGuy.FACTION == Faction.Hagre) { if (rng.Next(0, 100) > 90) { Console.WriteLine($"Hagre forgets what he's doing and gives {badGuy.name} time recover 1 HP!"); badGuy.health += 1; } } else if (goodGuy.FACTION == Faction.Bard) { if (rng.Next(0, 100) > 85) { Console.WriteLine($"Bardston convinces {badGuy.name} to give him 1 HP!"); badGuy.health -= 1; goodGuy.health += 1; } } else if (goodGuy.FACTION == Faction.BlackBelt) { if (rng.Next(0, 100) > 85) { Console.WriteLine("Paralyzing strike! Attack again!"); goodGuy.Attack(badGuy); } } else if (goodGuy.FACTION == Faction.Assassin) { if (rng.Next(0, 100) > 98) { Tools.ColorfulWriteLine("KILL SHOT", ConsoleColor.DarkRed); badGuy.health = 0; goodGuy.AttackResult(badGuy, 0); } } else if (goodGuy.FACTION == Faction.Wizard) { if (rng.Next(0, 100) > 85) { Console.WriteLine($"Wiserd blasts {badGuy.name} for 2 HP!"); badGuy.health -= 2; } } else if ((goodGuy.FACTION == Faction.Ranger) && (goodGuy.health < 5)) { if (rng.Next(0, 100) > 75) { Tools.ColorfulWriteLine("JAYNGER NARROWLY ESCAPES DEATH AND LIVES TO FIGHT ANOTHER DAY!", ConsoleColor.Blue); Console.Read(); Environment.Exit(0); } } else if (goodGuy.FACTION == Faction.LizardMan) { if (rng.Next(0, 100) > 85) { Console.WriteLine($"{goodGuy.name} heals for 1 point!"); goodGuy.health += 1; } } } else { badGuy.Attack(goodGuy); if (badGuy.FACTION == Faction.BadGuy) { if (rng.Next(0, 100) > 85) { Console.WriteLine($"{badGuy.name} heals for 1 point!"); badGuy.health += 1; } } } Thread.Sleep(100); } }
// ask the player what action they want to take // returns the attack value or defend value static int PlayerChoice(Warrior player, string action) { string choice; // continuously ask for a valid offense option if (string.Equals(action, "offense")) { do { Console.ForegroundColor = ConsoleColor.DarkBlue; Console.WriteLine("(A)ttack or (P)owerful Strike?"); Console.ResetColor(); choice = Console.ReadLine().ToUpper(); Console.WriteLine(); if (choice == "A") { return(player.Attack()); } else if (choice == "P") { return(player.PowerfulStrike()); } else { Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("Invalid option\n"); Console.ResetColor(); } } while (true); } // continuously ask for a valid defense option else if (string.Equals(action, "defense")) { do { Console.ForegroundColor = ConsoleColor.DarkBlue; Console.WriteLine("(D)efend or (C)ounter?"); Console.ResetColor(); choice = Console.ReadLine().ToUpper(); Console.WriteLine(); if (choice == "D") { return(player.Defend()); } else if (choice == "C") { return(player.Counter()); } else { Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("Invalid option\n"); Console.ResetColor(); } } while (true); } else { return(-1); } }