示例#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 void OnSendOption(KettleSendOption sendOption)
        {
            Console.WriteLine("simulator OnSendOption called");

            PowerAllOptions allOptions = _game.AllOptionsMap[sendOption.Id];

            SendPowerHistory(_game.PowerHistory.Last);
            SendChoicesOrOptions();
        }
示例#3
0
        public KettleOptionsBlock(PowerAllOptions options, int playerID)
        {
            Id       = options.Index;
            Options  = new List <KettleOption>();
            PlayerId = playerID;

            foreach (var option in options.PowerOptionList)
            {
                Options.Add(new KettleOption(option));
            }
        }
        public void Start()
        {
            Log.Info($"[_gameId:{_gameId}] Game creation is happening in a few seconds!!!");
            var newGame = new Game(new GameConfig
            {
                //StartPlayer = 1,
                FormatType       = FormatType.FT_STANDARD,
                Player1HeroClass = Cards.HeroClasses[_random.Next(9)],
                Player1Deck      = new List <Card>(),
                Player2HeroClass = Cards.HeroClasses[_random.Next(9)],
                Player2Deck      = new List <Card>(),
                SkipMulligan     = true,
                Shuffle          = true,
                FillDecks        = true,
                Logging          = true,
                History          = true
            });

            if (_game == null)
            {
                _game = newGame;
                Log.Info($"[_gameId:{_gameId}] Game creation done!");
                _game.StartGame();

                ProcessPowerHistoryData(1, _player1, _game.PowerHistory.Last);

                _powerAllOptionsPlayer1 = PowerOptionsBuilder.AllOptions(_game, _game.Player1.Options());

                ProcessPowerOptionsData(1, _player1, _powerAllOptionsPlayer1);

                ProcessPowerHistoryData(2, _player2, _game.PowerHistory.Last);

                _powerAllOptionsPlayer2 = PowerOptionsBuilder.AllOptions(_game, _game.Player2.Options());

                ProcessPowerOptionsData(2, _player2, _powerAllOptionsPlayer2);

                foreach (var historyEntry in _game.PowerHistory.Last)
                {
                    //Log.Info($"{historyEntry.Print()}");
                }
            }
        }
示例#5
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);
            }
        }
示例#6
0
        public void SendOptionsOrChoicesToPlayers()
        {
            if (_game.Player1.Choice != null)
            {
                //Log.Debug($"sending Choices to player 1");
                SendGameData(Player1, MsgType.InGame, true, GameDataType.PowerChoices, JsonConvert.SerializeObject(new PowerChoices()
                {
                    ChoiceType = _game.Player1.Choice.ChoiceType, Entities = _game.Player1.Choice.Choices
                }));
            }
            else
            {
                _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");
                SendGameData(Player2, MsgType.InGame, true, GameDataType.PowerChoices, JsonConvert.SerializeObject(new PowerChoices()
                {
                    ChoiceType = _game.Player2.Choice.ChoiceType, Entities = _game.Player2.Choice.Choices
                }));
            }
            else
            {
                _powerAllOptionsPlayer2 = PowerOptionsBuilder.AllOptions(_game, _game.Player2.Options());
                SendGameData(Player2, MsgType.InGame, true, GameDataType.PowerOptions, JsonConvert.SerializeObject(new PowerOptions()
                {
                    Index = _powerAllOptionsPlayer2.Index, PowerOptionList = _powerAllOptionsPlayer2.PowerOptionList
                }));
            }
        }
示例#7
0
 private void SendOptions(PowerAllOptions options)
 {
     Console.WriteLine($"SendOptions => {options.Print()}");
     Adapter.SendMessage(new KettleOptionsBlock(options, Game.CurrentPlayer.PlayerId));
 }
        public void OnOptionsBlock(KettleOptionsBlock optionsBlock)
        {
            // convert that option
            Console.WriteLine("AI OnOptionsBlock called.");
            if (optionsBlock.PlayerId != PlayerId)
            {
                return;
            }

            List <PlayerTask> options = Session.Game.CurrentPlayer.Options();

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

            // Convert it to poweroptions
            PowerAllOptions poweroptions = PowerOptionsBuilder.AllOptions(Session.Game, new List <PlayerTask> {
                option
            });

            // And create a kettle block for it
            KettleOption chosenoption = new KettleOptionsBlock(poweroptions, Session.Game.CurrentPlayer.PlayerId).Options[0];

            int mainOptionIndex = 0;
            int subOptionIndex  = 0;
            int target          = 0;
            int position        = 0;

            // Then we try and find the kettle option that matches
            foreach (KettleOption koption in optionsBlock.Options)
            {
                if (koption.Type != chosenoption.Type)
                {
                    continue;
                }

                if (!OptionsMatch(chosenoption.MainOption, koption.MainOption))
                {
                    continue;
                }

                if ((chosenoption.SubOptions == null || chosenoption.SubOptions.Count == 0) != (koption.SubOptions == null || koption.SubOptions.Count == 0))
                {
                    continue;
                }

                if (chosenoption.SubOptions != null)
                {
                    foreach (KettleSubOption suboption in chosenoption.SubOptions)
                    {
                        if (OptionsMatch(chosenoption.SubOptions[0], suboption))
                        {
                            subOptionIndex = koption.SubOptions.IndexOf(suboption);
                            break;
                        }
                    }
                }

                mainOptionIndex = optionsBlock.Options.IndexOf(koption);

                if (chosenoption.MainOption != null && chosenoption.MainOption.Targets != null)
                {
                    target = chosenoption.MainOption.Targets[0];
                }
                break;
            }

            if (option is PlayCardTask)
            {
                position = ((PlayerTask)option).ZonePosition;
            }

            KettleSendOption sendoption = new KettleSendOption();

            sendoption.Id         = optionsBlock.Id;
            sendoption.MainOption = mainOptionIndex;
            sendoption.SubOption  = subOptionIndex;
            sendoption.Target     = target;
            sendoption.Position   = position;

            Adapter.SendMessage(sendoption);
        }
 private void ProcessPowerOptionsData(int playerId, UserInfoData userInfoData, PowerAllOptions allOptions)
 {
     userInfoData.Connection.Send(DataPacketBuilder.RequestServerGamePowerOptions(_id, _token, _gameId, playerId, allOptions.Index, allOptions.PowerOptionList), Encoding.UTF8);
 }
示例#10
0
 private void SendOptions(PowerAllOptions options)
 {
     Adapter.SendMessage(new KettleOptionsBlock(options, _game.CurrentPlayer.PlayerId));
 }
        //public static List<PowerHistoryStruct> Serialize(List<IPowerHistoryEntry> PowerHistoryEntries)
        //{
        //    var powerHistoryStructs = new List<PowerHistoryStruct>();
        //    foreach (var powerHistoryEntry in PowerHistoryEntries)
        //    {
        //        powerHistoryStructs.Add(
        //            new PowerHistoryStruct
        //            {
        //                PowerType = powerHistoryEntry.PowerType,
        //                PowerHistoryString = Serialize(powerHistoryEntry)
        //            });
        //    }
        //    return powerHistoryStructs;
        //}

        public static string Serialize(PowerAllOptions powerAllOptions)
        {
            return("");
        }