public static CalculatedMonsterValues GenerateRandomGuard(UserInput userInput) { var monsters = MonsterFactory.ListMonsters(); var rnd = new Random((int)DateTime.Now.Ticks); var towns = userInput.TownZoneCounts.Where(tzc => tzc.Value > 0).Select(tzc => tzc.Key).ToList(); towns.Add(Town.Neutral); int monsterStrengthMap = userInput.SelectedMonsterStrengthMap?.Value ?? 0; int monsterStrengthZone = userInput.SelectedMonsterStrengthZone?.Value ?? 0; var protectionIndex = monsterStrengthMap + monsterStrengthZone; var aiValues = CalculateAiValues(userInput, protectionIndex); CalculatedMonsterValues monsterValues = new CalculatedMonsterValues(); Monster monster; while (monsterValues.Monster == null || !towns.Contains(monsterValues.Monster.Town) || monsterValues.AverageMonsterCount > 100 || monsterValues.AverageMonsterCount == 0) { var ix = rnd.Next(0, monsters.Count - 1); monster = monsters[ix]; monsterValues = CalculatedMonsterValues(aiValues.TotalAiValue, monster); monsters.RemoveAt(ix); if (monsters.Count == 0) { return(null); } } return(monsterValues); }
private static List <Monster> LoadMonsters() { return(MonsterFactory.ListMonsters()); }