Esempio n. 1
0
        private Tuple <Decision, int> ChooseYesOrNo(Duel duel, int numberOfChoicesMade, List <Tuple <Decision, int> > decisions, YesNoChoice yesNo)
        {
            var options = new List <bool> {
                true, false
            };

            foreach (var option in options)
            {
                var currentChoice = new YesNoDecision(option);
                using var duelCopy = new Duel(duel);
                var newChoice = duelCopy.Continue(currentChoice);
                _optionsRemaining -= options.Count;
                decisions.Add(new Tuple <Decision, int>(currentChoice, Choose(newChoice, duelCopy, currentChoice, numberOfChoicesMade + 1).Item2));
            }
            return(Choose(yesNo, decisions));
        }
Esempio n. 2
0
        private Tuple <Decision, int> ChooseGuid(Duel duel, int numberOfChoicesMade, List <Tuple <Decision, int> > decisions, GuidSelection selection)
        {
            List <IEnumerable <Guid> > options = new();

            for (int i = selection.MinimumSelection; i <= selection.MaximumSelection; ++i)
            {
                options.AddRange(GetCombinations(new List <Guid>(), selection.Options, i));
            }
            foreach (var option in options)
            {
                var newDecision = new GuidDecision(option);
                using var duelCopy = new Duel(duel);
                var newChoice = duelCopy.Continue(newDecision);
                _optionsRemaining -= options.Count;
                decisions.Add(new Tuple <Decision, int>(newDecision, Choose(newChoice, duelCopy, newDecision, numberOfChoicesMade + 1).Item2));
            }
            return(Choose(selection, decisions));
        }
Esempio n. 3
0
        private Tuple <Decision, int> ChooseAttacker(Duel duel, int numberOfChoicesMade, List <Tuple <Decision, int> > decisions, AttackerChoice attackerChoice)
        {
            var options = attackerChoice.Options.SelectMany(attacker => attacker.SelectMany(target => target.Select(x => new Tuple <Guid, Guid>(attacker.Key, x)))).ToList();

            if (!attackerChoice.MustAttack)
            {
                options.Add(null);
            }
            foreach (var option in options)
            {
                var currentChoice = new AttackerDecision(option);
                using var duelCopy = new Duel(duel);
                var newChoice = duelCopy.Continue(currentChoice);
                _optionsRemaining -= options.Count;
                decisions.Add(new Tuple <Decision, int>(currentChoice, Choose(newChoice, duelCopy, currentChoice, numberOfChoicesMade + 1).Item2));
            }
            return(Choose(attackerChoice, decisions));
        }
Esempio n. 4
0
        private Tuple <Decision, int> ChooseCardToUse(Duel duel, int numberOfChoicesMade, List <Tuple <Decision, int> > decisions, CardUsageChoice usage)
        {
            //var options = usage.Options.SelectMany(toUse => toUse.SelectMany(target => target.Select(x => new UseCardContainer { ToUse = toUse.Key, Manas = x } ))).ToList();
            //var options = usage.Options.SelectMany(toUse => toUse.SelectMany(target => target.Take(2).Select(x => new UseCardContainer { ToUse = toUse.Key, Manas = x }))).ToList();
            var options = usage.Options.SelectMany(toUse => toUse.SelectMany(manaCombs => manaCombs.OrderByDescending(manaComb => PointsForUnleftMana(manaComb, duel, usage.Player)).Take(1).Select(x => new UseCardContainer {
                ToUse = toUse.Key, Manas = x
            }))).ToList();

            options.Add(null);
            foreach (var option in options)
            {
                var currentChoice = new CardUsageDecision(option);
                using var duelCopy = new Duel(duel);
                var newChoice = duelCopy.Continue(currentChoice);
                _optionsRemaining -= options.Count;
                decisions.Add(new Tuple <Decision, int>(currentChoice, Choose(newChoice, duelCopy, currentChoice, numberOfChoicesMade + 1).Item2));
            }
            return(Choose(usage, decisions));
        }
Esempio n. 5
0
        private Tuple <Decision, int> ChooseEnum(Duel duel, int numberOfChoicesMade, List <Tuple <Decision, int> > decisions, EnumChoice choice)
        {
            //TODO: Atm only Petrova is supported.
            var options = duel.GetPlayer(choice.Player).BattleZone.Cards.SelectMany(x => x.Subtypes).Except(choice.Excluded.Cast <Subtype>());

            if (!options.Any())
            {
                options = duel.GetPlayer(choice.Player).AllCards.SelectMany(x => x.Subtypes).Except(choice.Excluded.Cast <Subtype>());
            }
            foreach (var option in options)
            {
                var currentChoice = new EnumDecision(option);
                using var duelCopy = new Duel(duel);
                var newChoice = duelCopy.Continue(currentChoice);
                _optionsRemaining -= options.Count();
                var foo = Choose(newChoice, duelCopy, currentChoice, numberOfChoicesMade + 1);
                decisions.Add(new Tuple <Decision, int>(currentChoice, foo.Item2));
            }
            return(Choose(choice, decisions));
        }