public bool DoRound(bool abortIfAnElfDies = false) { var allFighters = Goblins.Cast <Fighter>() .Concat(Elves.Cast <Fighter>()) .Where(f => !f.IsDead) .OrderBy(f => f.Y) .ThenBy(f => f.X).ToList(); foreach (var fighter in allFighters) { if (Goblins.All(g => g.IsDead) || Elves.All(e => e.IsDead)) { return(true); } if (abortIfAnElfDies && Elves.Any(e => e.IsDead)) { return(true); } if (fighter.IsDead) { continue; } if (fighter is Elf) { var asElf = (Elf)fighter; if (!TryToFight(asElf)) { MoveToClosestEnemy(asElf); TryToFight(asElf); } } else { var asGoblin = (Goblin)fighter; if (!TryToFight(asGoblin)) { MoveToClosestEnemy(asGoblin); TryToFight(asGoblin); } } } return(false); }