/// <summary> /// Run the battle /// </summary> public void Run() { while (complete == false && hero.Alive()) { Thread.Sleep(1000); layout.Arena(hero, enemies); //We need to run random before we check alive status therefore do-while & not while. do { enemiesnr = random.Next(0, enemies.Count()); }while (!enemies[enemiesnr].Alive()); //We will only attack Enemy there is alive. if (hero.Alive()) { hero.Action(enemies[enemiesnr]); } else { complete = true; break; } Thread.Sleep(1000); layout.Arena(hero, enemies); enemyAlive = enemies.Count(); foreach (Enemy enemy in enemies) { if (enemy.Alive()) { enemy.Action(hero); } else { enemyAlive--; if (enemyAlive <= 0) { foreach (Enemy deadEnemy in enemies) { hero.Xp += deadEnemy.XpReward; if (hero.LevelUpCheck()) { hero.LevelUpStats(); } } complete = true; break; } } } } }