override public void fight(Hero opponent) { int damage = base.getAttackDamage(); Console.WriteLine(name + " attacks " + opponent.getName() + " dealing " + damage + " damage!"); opponent.defend(this, damage); }
public void start() { Console.WriteLine("## LETS BEGIN! ##"); Console.WriteLine("## FIGHT! ## \n"); while (true) { Console.WriteLine("## TURN " + turnsCount + " ##"); if (isFirstHeroTurn == true) { heroOne.fight(heroTwo); isFirstHeroTurn = false; } else { heroTwo.fight(heroOne); isFirstHeroTurn = true; } Console.WriteLine("\nResults: "); Console.WriteLine(heroOne.getName() + "'s Health: " + heroOne.getHealth()); Console.WriteLine(heroTwo.getName() + "'s Health: " + heroTwo.getHealth()); Console.WriteLine(); if (heroOne.isDead()) { Console.WriteLine("GAME ENDS!"); Console.WriteLine("Hero " + heroTwo.getName() + " WINS in " + turnsCount + " turns!"); break; } else if (heroTwo.isDead()) { Console.WriteLine("GAME ENDS!"); Console.WriteLine("Hero " + heroOne.getName() + " WINS in " + turnsCount + " turns!"); break; } turnsCount += 1; } }
override public void fight(Hero opponent) { int damage = base.getAttackDamage(); Random random = new Random(); if (random.Next(1, 101) <= 10) { damage += damage * 200 / 100; } Console.WriteLine(name + " attacks " + opponent.getName() + " dealing " + damage + " damage!"); opponent.defend(this, damage); }
public override void fight(Hero opponent) { int damage = base.getAttackDamage(); // There's a 25% chance to deal 250% damage Random random = new Random(); if (random.Next(1, 101) <= 25) { damage += damage * 250 / 100; } Console.WriteLine(name + " attacks " + opponent.getName() + " dealing " + damage + " damage!"); opponent.defend(this, damage); }