示例#1
0
        private void SendChoicesOrOptions()
        {
            // getting choices mulligan choices for players ...
            var entityChoicesPlayer1 = PowerChoicesBuilder.EntityChoices(Game, Game.Player1.Choice);
            var 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);
            }
        }
示例#2
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;
        }
示例#3
0
        public void SendOptionsOrChoicesToPlayers()
        {
            if (_game.Player1.Choice != null)
            {
                //Log.Debug($"sending Choices to player 1");
                var powerChoicesPlayer1 = PowerChoicesBuilder.EntityChoices(_game, _game.Player1.Choice);
                SendGameData(Player1, MsgType.InGame, true, GameDataType.PowerChoices, JsonConvert.SerializeObject(new PowerChoices()
                {
                    Index = powerChoicesPlayer1.Index, ChoiceType = powerChoicesPlayer1.ChoiceType, Entities = powerChoicesPlayer1.Entities
                }));
            }
            else
            {
                var powerAllOptionsPlayer1 = PowerOptionsBuilder.AllOptions(_game, _game.Player1.Options());
                SendGameData(Player1, MsgType.InGame, true, GameDataType.PowerOptions, JsonConvert.SerializeObject(new PowerOptions()
                {
                    Index = powerAllOptionsPlayer1.Index, PowerOptionList = powerAllOptionsPlayer1.PowerOptionList
                }));
            }

            if (_game.Player2.Choice != null)
            {
                //Log.Debug($"sending Choices to player 2");
                var powerChoicesPlayer2 = PowerChoicesBuilder.EntityChoices(_game, _game.Player2.Choice);
                SendGameData(Player2, MsgType.InGame, true, GameDataType.PowerChoices, JsonConvert.SerializeObject(new PowerChoices()
                {
                    Index = powerChoicesPlayer2.Index, ChoiceType = powerChoicesPlayer2.ChoiceType, Entities = powerChoicesPlayer2.Entities
                }));
            }
            else
            {
                var powerAllOptionsPlayer2 = PowerOptionsBuilder.AllOptions(_game, _game.Player2.Options());
                SendGameData(Player2, MsgType.InGame, true, GameDataType.PowerOptions, JsonConvert.SerializeObject(new PowerOptions()
                {
                    Index = powerAllOptionsPlayer2.Index, PowerOptionList = powerAllOptionsPlayer2.PowerOptionList
                }));
            }
        }
示例#4
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);
            }
        }
示例#5
0
        private static void PowerHistoryTest()
        {
            var game =
                new Game(new GameConfig
            {
                StartPlayer      = 1,
                Player1HeroClass = CardClass.DRUID,
                //DeckPlayer1 = new List<Card>
                //{
                //    Cards.FromName("Raven Idol")
                //},
                Player2HeroClass = CardClass.MAGE,
                SkipMulligan     = false,
                Shuffle          = false,
                FillDecks        = true
            });

            game.StartGame();

            //List<PlayerTask> options;
            //options = game.CurrentPlayer.Options();
            //Console.WriteLine($" *** - {game.CurrentPlayer.Name} options on {game.Turn}. - ***");
            //options.ForEach(p => Console.WriteLine(p.FullPrint()));

            //Console.WriteLine("*** - START GAME - ***");
            //Console.WriteLine(game.PowerHistory.Print(false));
            //Console.WriteLine("*** - MULLIGAN PLAYER 1 - ***");
            //Console.WriteLine(PowerChoicesBuilder.EntityChoices(game, game.Player1.Choice).Print());
            //Console.WriteLine("*** - MULLIGAN PLAYER 2 - ***");
            //Console.WriteLine(PowerChoicesBuilder.EntityChoices(game, game.Player2.Choice).Print());

            game.Process(ChooseTask.Mulligan(game.Player1, new List <int>(game.Player1.Choice.Choices)));

            //options = game.CurrentPlayer.Options();
            //Console.WriteLine($" *** - {game.CurrentPlayer.Name} options on {game.Turn}. - ***");
            //options.ForEach(p => Console.WriteLine(p.FullPrint()));
            //Console.WriteLine(game.PowerHistory.Print(false));

            game.Process(ChooseTask.Mulligan(game.Player2, new List <int> {
            }));

            //options = game.CurrentPlayer.Options();
            //Console.WriteLine($" *** - {game.CurrentPlayer.Name} options on {game.Turn}. - ***");
            //options.ForEach(p => Console.WriteLine(p.FullPrint()));

            //Console.WriteLine(game.PowerHistory.Print(false));

            game.MainReady();

            //options = game.CurrentPlayer.Options();
            //Console.WriteLine($" *** - {game.CurrentPlayer.Name} options on {game.Turn}. - ***");
            //options.ForEach(p => Console.WriteLine(p.FullPrint()));

            //Console.WriteLine(game.PowerHistory.Print(false));

            //game.Process(ConcedeTask.Any(game.CurrentPlayer));
            //Console.Write("*** - CONCEDE - ***");
            //Console.Write(game.PowerHistory.Print(false));
            //ShowLog(game, LogLevel.VERBOSE);
            //Console.WriteLine(PowerOptionsBuilder.AllOptions(game.CurrentPlayer.Id, game.CurrentPlayer.Options()).Print());
            //game.Process(EndTurnTask.Any(game.CurrentPlayer));
            //ShowLog(game, LogLevel.VERBOSE);
            //Console.WriteLine(PowerOptionsBuilder.AllOptions(game.CurrentPlayer.Id, game.CurrentPlayer.Options()).Print());

            while (game.State != State.COMPLETE)
            {
                var options = game.CurrentPlayer.Options();
                Console.WriteLine($" *** - {game.CurrentPlayer.Name} options on {game.Turn}. - ***");
                options.ForEach(p => Console.WriteLine(p.FullPrint()));

                Console.WriteLine(PowerOptionsBuilder.AllOptions(game, options)?.Print());
                PowerChoicesBuilder.EntityChoices(game, game.CurrentPlayer.Choice);

                var option = options[Rnd.Next(options.Count)];
                game.Process(option);
            }

            //foreach (var powerAllOptionse in game.AllOptionsMap)
            //    Console.WriteLine($"{powerAllOptionse.Key} => {powerAllOptionse.Value.Print()}");

            //foreach (var entityChoice in game.EntityChoicesMap)
            //    Console.WriteLine($"{entityChoice.Key} => {entityChoice.Value.Print()}");

            //foreach (var playables in game.IdEntityDic)
            //{
            //    Console.WriteLine($"{playables.Key} => {playables.Value}");
            //}

            ShowLog(game, LogLevel.VERBOSE);
        }