public void Battle(List <string> heroNames, BattleView battleView) { var firstHero = dbContext.Heroes.FirstOrDefault(h => h.Name == heroNames[0]); var secondHero = dbContext.Heroes.FirstOrDefault(h => h.Name == heroNames[1]); var thirdHero = dbContext.Heroes.FirstOrDefault(h => h.Name == heroNames[2]); while (firstHero.Hp > 0 && secondHero.Hp > 0 && thirdHero.Hp > 0 && bossHealth > 0) { switch (battleView.GetNextHeroToAttack()) { case "D1": BossTakeDamage(firstHero); BossDealDamage(firstHero); battleView.UpdateStatus(bossHealth, firstHero, secondHero, thirdHero); break; case "D2": BossTakeDamage(firstHero); BossDealDamage(firstHero); battleView.UpdateStatus(bossHealth, firstHero, secondHero, thirdHero); break; case "D3": BossTakeDamage(firstHero); BossDealDamage(firstHero); battleView.UpdateStatus(bossHealth, firstHero, secondHero, thirdHero); break; } } if (bossHealth <= 0) { battleView.Success(); } else { battleView.Failiure(); } if (dbContext.Heroes.FirstOrDefault(h => h.Hp <= 0) != null) { dbContext.Heroes.Remove(dbContext.Heroes.FirstOrDefault(h => h.Hp <= 0)); dbContext.SaveChanges(); } }