public static bool SimulateBattle(int elvenPower = 3) { lstUnits = new List <Unit>(); FinishGame = false; string[] linesInput = File.ReadAllLines(Util.ReadFromInputFolder(15)); int Height = linesInput.Count(); int Width = linesInput.OrderByDescending(r => r.Length).First().Length; grid = new char[Width, Height]; int j = 0; int ID = 1; foreach (string line in linesInput) { for (int w = 0; w < line.Count(); w++) { if (line[w] == 'G' || line[w] == 'E') { grid[w, j] = '.'; if (line[w] == 'G') { lstUnits.Add(new Unit(ID, new Point(w, j), Faction.Goblin)); } else { lstUnits.Add(new Unit(ID, new Point(w, j), Faction.Elf, elvenPower)); } ID++; } else { grid[w, j] = line[w]; } } j++; } int originalAmountOfElves = lstUnits.Where(r => r.faction == Faction.Elf).Count(); int Round = 0; PrintMap(Width, Height, grid); while (FinishGame == false) { var orderedUnits = lstUnits.OrderBy(r => r.Position.Y).ThenBy(r => r.Position.X); foreach (Unit soldier in orderedUnits) { if (soldier.HP <= 0) { continue; } Logic(soldier); if (FinishGame == true) { break; } } PrintMap(Width, Height, grid); if (FinishGame == false) { Round++; } } if (lstUnits.Where(r => r.faction == Faction.Elf).Count() == originalAmountOfElves) { Console.WriteLine("TRUE: " + lstUnits.Sum(r => r.HP) * Round + " | ElvenPower=" + elvenPower); return(true); } else { Console.WriteLine("FALSE: " + lstUnits.Sum(r => r.HP) * Round + " | ElvenPower=" + elvenPower); return(false); } }