Beispiel #1
0
        public int SimToVictory(bool abortIfAnElfDies = false)
        {
            var round = 0;

            while (true)
            {
                if (DoRound(abortIfAnElfDies))
                {
                    if (abortIfAnElfDies && Elves.Any(e => e.IsDead))
                    {
                        return(-1);
                    }

                    if (Goblins.All(g => g.IsDead))
                    {
                        var hpLeft = Elves.Where(e => !e.IsDead).Sum(e => e.HP);
                        return(round * hpLeft);
                    }

                    if (Elves.All(e => e.IsDead))
                    {
                        var hpLeft = Goblins.Where(e => !e.IsDead).Sum(e => e.HP);
                        return(round * hpLeft);
                    }
                }

                round++;
            }
        }