public void Attack(WarriorClass enemy) { //int damage = weapon.Damage / enemy.armor.ArmorPoints; int damage = weapon.Damage; enemy.health -= damage; AttackResult(enemy, damage); }
private void AttackResult(WarriorClass enemy, int damage) { if (enemy.health <= 0) { enemy.isAlive = false; //Console.WriteLine($"{enemy.name} has fainted. \n{name} has won the battle."); Tools.ColorfulWriteLine($"{enemy.name} has fainted.", ConsoleColor.Red); Tools.ColorfulWriteLine($"{name} has won the battle.", ConsoleColor.Green); } else { Console.WriteLine($"{name} attacked {enemy.name}. Dealt {damage} damage, {enemy.name} remaining health is {enemy.health}"); } }
static void Main(string[] args) { WarriorClass goodGuy = new WarriorClass("Chris", Faction.Goodguy); WarriorClass badGuy = new WarriorClass("Bob", Faction.Badguy); while (goodGuy.IsAlive && badGuy.IsAlive) { if (rng.Next(0, 10) < 5) { goodGuy.Attack(badGuy); } else { badGuy.Attack(goodGuy); } Thread.Sleep(100); } }