public void startGame(Hero hero, Hero oponent) { int count = 1; while (hero.HealthPoints > 0 && oponent.HealthPoints > 0) { Console.WriteLine("Raw " + count++); hero.Attack(oponent); if (oponent.HealthPoints < 0 || hero.HealthPoints < 0) { break; } oponent.Attack(hero); Console.WriteLine("-----------------------------------------------"); } if (hero.HealthPoints <= 0) { Console.WriteLine("Winner " + oponent.Name); } else { Console.WriteLine("Winner " + hero.Name); } }
public void Run() { while (true) { player1.Attack(player2); if (player1.IsDead()) { PrintWinner(player2); break; } player2.Attack(player1); if (player2.IsDead()) { PrintWinner(player1); break; } } }
static void Main(string[] args) { string command = string.Empty; int meters = 0; Hero svetiGeorgi = new Hero(new SmallSword(), new Walking()); Console.WriteLine("Hello Goshe"); Console.WriteLine(string.Format("Second level: after {0} meters", METERS_REQUIRED_LEVEL_2)); Console.WriteLine(string.Format("Third level: after {0} meters", METERS_REQUIRED_LEVEL_3)); Console.WriteLine(string.Format("God level: after {0} meters", FAR_FAR_AWAY)); while (!command.Equals(QUIT_COMMAND)) { command = Console.ReadLine(); switch (command) { case MOVE_COMMAND: meters += svetiGeorgi.Move(); ChooseGear(meters, svetiGeorgi); Console.WriteLine(string.Format("Current distance: {0} meters", meters)); break; case ATTACK_COMMAND: svetiGeorgi.Attack(); break; case INFO_COMMAND: Console.WriteLine(svetiGeorgi.Preview()); break; } } Console.WriteLine("The game is over."); Console.ReadLine(); }