Example #1
0
        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);
        }
Example #2
0
        private static CalculatedMonsterValues CalculatedMonsterValues(int totalAiValue, Monster monster)
        {
            var result = new CalculatedMonsterValues();

            result.AverageMonsterCount   = (int)Math.Round((double)totalAiValue / monster.AiValue);
            result.MonsterCountDeviation = result.AverageMonsterCount >= 4 ? result.AverageMonsterCount / 4 : 0;
            result.Monster = monster;

            return(result);
        }
Example #3
0
 public CalculatedValues()
 {
     AiValues      = new CalculatedAiValues();
     MonsterValues = new CalculatedMonsterValues();
 }