Exemplo n.º 1
0
        internal void SetPowerChoice(int playerId, PowerChoices powerChoices)
        {
            var choiceTask = SabberStoneConverter.CreatePlayerTaskChoice(_originalGame, playerId, powerChoices.ChoiceType, powerChoices.Entities);

            _originalGame.Process(choiceTask);

            _poGame = CreatePartiallyObservableGame(_originalGame);
        }
Exemplo n.º 2
0
        internal void ProcessGameData(GameData gameData)
        {
            UserClient userInfoData = UserById(gameData.PlayerId);

            if (userInfoData == null)
            {
                Stop();
                return;
            }

            switch (gameData.GameDataType)
            {
            case GameDataType.PowerOption:
                PowerOptionChoice powerOptionChoice = JsonConvert.DeserializeObject <PowerOptionChoice>(gameData.GameDataObject);
                PlayerTask        optionTask        = SabberStoneConverter.CreatePlayerTaskOption(_game, powerOptionChoice.PowerOption, powerOptionChoice.Target, powerOptionChoice.Position, powerOptionChoice.SubOption);

                _game.Process(optionTask);

                //if (powerOptionChoice.PowerOption.OptionType == OptionType.END_TURN)
                //{
                //    Log.Info($"State[{_game.State}]-T[{_game.Turn}] Hero1: {_game.Player1.Hero.Health} HP // Hero2: {_game.Player2.Hero.Health} HP");
                //}

                SendActionToPlayers(gameData.PlayerId, gameData.GameDataType, gameData.GameDataObject);
                SendHistoryToPlayers();

                if (_game.State == State.RUNNING)
                {
                    SendOptionsOrChoicesToPlayers();
                }
                else
                {
                    Stop();
                }
                break;

            case GameDataType.PowerChoice:
                var powerChoices = JsonConvert.DeserializeObject <PowerChoices>(gameData.GameDataObject);
                var choiceTask   = SabberStoneConverter.CreatePlayerTaskChoice(_game, gameData.PlayerId, powerChoices.ChoiceType, powerChoices.Entities);

                _game.Process(choiceTask);

                // if mulligan has been finished!
                if (_game.Step == Step.BEGIN_MULLIGAN &&
                    _game.Player1.MulliganState == Mulligan.DONE &&
                    _game.Player2.MulliganState == Mulligan.DONE)
                {
                    _game.MainBegin();
                }

                SendActionToPlayers(gameData.PlayerId, gameData.GameDataType, gameData.GameDataObject);
                SendHistoryToPlayers();

                if (_game.State == State.RUNNING)
                {
                    SendOptionsOrChoicesToPlayers();
                }
                else
                {
                    Stop();
                }
                break;

            case GameDataType.Concede:
                break;

            default:
                break;
            }
        }