Beispiel #1
0
        private void SendChoicesOrOptions()
        {
            // getting choices mulligan choices for players ...
            PowerEntityChoices entityChoicesPlayer1 = PowerChoicesBuilder.EntityChoices(Game, Game.Player1.Choice);
            PowerEntityChoices entityChoicesPlayer2 = PowerChoicesBuilder.EntityChoices(Game, Game.Player2.Choice);

            // getting options for currentPlayer ...
            PowerAllOptions options = null;

            if (!Game.CurrentPlayer.Options().All(p => p.PlayerTaskType != PlayerTaskType.END_TURN))
            {
                options = PowerOptionsBuilder.AllOptions(Game, Game.CurrentPlayer.Options());
            }

            if (entityChoicesPlayer1 != null)
            {
                SendEntityChoices(entityChoicesPlayer1);
            }

            if (entityChoicesPlayer2 != null)
            {
                SendEntityChoices(entityChoicesPlayer2);
            }

            if (options != null)
            {
                SendOptions(options);
            }
        }
Beispiel #2
0
 public KettleEntityChoices(PowerEntityChoices choices)
 {
     ChoiceType = (int)choices.ChoiceType;
     CountMax   = choices.CountMax;
     CountMin   = choices.CountMin;
     Source     = choices.SourceId;
     Entities   = choices.Entities;
     PlayerId   = choices.PlayerId;
     Id         = choices.Index;
 }
Beispiel #3
0
        public static void TestStep1(KettleAdapter adapter)
        {
            // test data source: https://github.com/HearthSim/SabberStone/blob/master/hslogs/GameStates.txt
            _adapter = adapter;

            Console.WriteLine("creating game");
            _game = new Game(new GameConfig
            {
                StartPlayer      = 1,
                Player1HeroClass = CardClass.MAGE,
                Player2HeroClass = CardClass.WARLOCK,
                SkipMulligan     = false,
                FillDecks        = true
            });



            // Start the game and send the following powerhistory to the client
            _game.StartGame();

            List <IPowerHistoryEntry> powerHistory = _game.PowerHistory.Last;

            foreach (IPowerHistoryEntry h in powerHistory)
            {
                QueuePacket(KettleHistoryEntry.From(h));
            }
            SendQueue();

            PowerEntityChoices entityChoices1 = PowerChoicesBuilder.EntityChoices(_game, _game.Player1.Choice);

            SendPacket(new KettleEntityChoices(entityChoices1));

            PowerEntityChoices entityChoices2 = PowerChoicesBuilder.EntityChoices(_game, _game.Player2.Choice);

            SendPacket(new KettleEntityChoices(entityChoices2));

            KettleAdapter.OnChooseEntitiesDelegate handleMulligan = null;
            handleMulligan = (KettleChooseEntities) =>
            {
                // Handle the response to the mulligan (in a dynamic or hardcoded way)
                // this means sending the proper response/history and perhaps a ChosenEntities

                // If both players are handled, we can jump to game phase 2
                if (_game.Step == Step.BEGIN_MULLIGAN &&
                    _game.Player1.MulliganState == Mulligan.DONE &&
                    _game.Player2.MulliganState == Mulligan.DONE)
                {
                    _adapter.OnChooseEntities -= handleMulligan;
                    _game.NextStep             = Step.MAIN_BEGIN;
                    TestStep2();
                }
            };
            _adapter.OnChooseEntities += handleMulligan;
        }
Beispiel #4
0
        public override object VisitHsEntityChoices(HSGrammarParser.HsEntityChoicesContext context)
        {
            PowerEntityChoices powerEntityChoices = new PowerEntityChoices();

            powerEntityChoices.Id         = (int)VisitHsIdAssign(context.hsIdAssign());
            powerEntityChoices.Player     = context.VALUE()[0].GetText();
            powerEntityChoices.ChoiceType = context.VALUE()[1].GetText();
            foreach (var hsEntityChoicesEntities in context.hsEntityChoicesEntities())
            {
                PowerEntity entity = new PowerEntity();
                entity.EntityId = (int)VisitHsEntityChoicesEntities(hsEntityChoicesEntities);
                powerEntityChoices.Entities.Add(entity);
            }
            return(powerEntityChoices);
        }
Beispiel #5
0
        public void OnChooseEntities(KettleChooseEntities chooseEntities)
        {
            Console.WriteLine("simulator OnChooseEntities called");

            PowerEntityChoices entityChoices = Game.EntityChoicesMap[chooseEntities.Id];
            ChooseTask         chooseTask    = entityChoices.ChoiceType == ChoiceType.MULLIGAN
                                ? ChooseTask.Mulligan(entityChoices.PlayerId == 1 ? Game.Player1 : Game.Player2, chooseEntities.Choices)
                                : ChooseTask.Pick(entityChoices.PlayerId == 1 ? Game.Player1 : Game.Player2, chooseEntities.Choices[0]);

            Console.WriteLine($"processing => {chooseTask.FullPrint()}");

            Adapter.SendMessage(new KettleEntitiesChosen
            {
                ChoiceType     = (int)entityChoices.ChoiceType,
                PlayerId       = entityChoices.PlayerId,
                ChooseEntities = chooseEntities,
            });

            Game.Process(chooseTask);
            ShowLog(Game, LogLevel.VERBOSE);

            SendPowerHistory(Game.PowerHistory.Last);
            SendChoicesOrOptions();

            if (Game.Step == Step.BEGIN_MULLIGAN &&
                Game.Player1.MulliganState == Mulligan.DONE &&
                Game.Player2.MulliganState == Mulligan.DONE)
            {
                Game.MainBegin();

                while (Game.Step != Step.MAIN_ACTION)
                {
                    Thread.Sleep(500);
                }

                ShowLog(Game, LogLevel.VERBOSE);

                SendPowerHistory(Game.PowerHistory.Last);
                SendChoicesOrOptions();
            }
        }
Beispiel #6
0
        private void SendChoicesOrOptions()
        {
            // getting choices mulligan choices for players ...
            PowerEntityChoices entityChoicesPlayer1 = PowerChoicesBuilder.EntityChoices(_game, _game.Player1.Choice);
            PowerEntityChoices entityChoicesPlayer2 = PowerChoicesBuilder.EntityChoices(_game, _game.Player2.Choice);

            // getting options for currentPlayer ...
            PowerAllOptions options = PowerOptionsBuilder.AllOptions(_game, _game.CurrentPlayer.Options());

            if (entityChoicesPlayer1 != null)
            {
                SendEntityChoices(entityChoicesPlayer1);
            }

            if (entityChoicesPlayer2 != null)
            {
                SendEntityChoices(entityChoicesPlayer2);
            }

            if (options != null)
            {
                SendOptions(options);
            }
        }
Beispiel #7
0
 private void SendEntityChoices(PowerEntityChoices choices)
 {
     Console.WriteLine($"SendEntityChoices => {choices.Print()}");
     Adapter.SendMessage(new KettleEntityChoices(choices));
 }
Beispiel #8
0
 private void SendEntityChoices(PowerEntityChoices choices)
 {
     Adapter.SendMessage(new KettleEntityChoices(choices));
 }
 public void AddPowerEntityChoices(PowerEntityChoices entityChoices)
 {
     _powerEntityChoices = entityChoices;
 }