Ejemplo n.º 1
0
        public static KettleEntityChoices EntityChoicesTest(int choiceType, int countMax, int countMin, int source, List <int> entities, int playerId, int index)
        {
            var k = new KettleEntityChoices
            {
                ChoiceType = choiceType,
                CountMax   = countMax,
                CountMin   = countMin,
                Source     = source,
                Entities   = entities,
                PlayerId   = playerId,
                Id         = index,
            };

            return(k);
        }
Ejemplo n.º 2
0
        public void OnEntityChoices(KettleEntityChoices entityChoices)
        {
            Console.WriteLine("AI EntityChoices called.");
            if (entityChoices.PlayerId != PlayerId)
            {
                return;
            }

            SabberStoneCore.Model.Entities.Controller player = PlayerId == 1 ? Session.Game.Player1 : Session.Game.Player2;
            Choice            Choice  = player.Choice;
            List <PlayerTask> options = new List <PlayerTask>();

            switch (Choice.ChoiceType)
            {
            case ChoiceType.GENERAL:
                Choice.Choices.ToList().ForEach(p => options.Add(ChooseTask.Pick(player, p)));
                break;

            case ChoiceType.MULLIGAN:
                IEnumerable <IEnumerable <int> > choices = SabberStoneCore.Model.Util.GetPowerSet(Choice.Choices);
                choices.ToList().ForEach(p => options.Add(ChooseTask.Mulligan(player, p.ToList())));
                break;

            default:
                throw new NotImplementedException();
            }

            // Do AI shit
            PlayerTask option = DoAI(options);

            // Convert it to a kettle choices
            KettleChooseEntities chooseEntities = new KettleChooseEntities();

            chooseEntities.Id      = entityChoices.Id;
            chooseEntities.Choices = ((ChooseTask)option).Choices;

            Adapter.SendMessage(chooseEntities);
        }
Ejemplo n.º 3
0
        public void OnEntityChoices(KettleEntityChoices entityChoices)
        {
            Console.WriteLine("AI EntityChoices called.");
            if (entityChoices.PlayerId != PlayerId)
            {
                return;
            }

            var pickList = new List <int>();

            switch ((ChoiceType)entityChoices.ChoiceType)
            {
            case ChoiceType.MULLIGAN:
                var picks = Rand.Next(0, entityChoices.Entities.Count);
                pickList.AddRange(entityChoices.Entities);
                for (var i = 0; i < picks; i++)
                {
                    pickList.Remove(pickList[Rand.Next(0, pickList.Count)]);
                }
                break;

            case ChoiceType.GENERAL:
                pickList.Add(entityChoices.Entities[Rand.Next(0, entityChoices.Entities.Count)]);
                break;

            case ChoiceType.INVALID:
            default:
                throw new NotImplementedException();
            }

            Adapter.SendMessage(new KettleChooseEntities()
            {
                Id      = entityChoices.Id,
                Choices = pickList
            });
        }