Ejemplo n.º 1
0
 public Playable(SabberStoneCore.Model.Entities.IPlayable playable, bool hand)
 {
     cardId_ = playable.Card.AssetId;
     cost_   = playable.Cost;
     if (playable is SabberStoneCore.Model.Entities.Character c)
     {
         atk_        = c.AttackDamage;
         baseHealth_ = c.BaseHealth;
     }
     if (hand)
     {
         ghostly_ = playable[SabberStoneCore.Enums.GameTag.GHOSTLY] == 1;
     }
 }
Ejemplo n.º 2
0
        public void NerubianEgg_FP1_007()
        {
            var game = new Game(new GameConfig
            {
                StartPlayer          = 1,
                Player1HeroClass     = CardClass.MAGE,
                Player2HeroClass     = CardClass.MAGE,
                FillDecks            = true,
                FillDecksPredictably = true
            });

            game.StartGame();
            game.Player1.BaseMana = 10;
            game.Player2.BaseMana = 10;
            SabberStoneCore.Model.Entities.IPlayable testCard = Generic.DrawCard(game.CurrentPlayer, Cards.FromName("Nerubian Egg"));
            game.Process(PlayCardTask.Minion(game.CurrentPlayer, testCard));
            game.Process(EndTurnTask.Any(game.CurrentPlayer));
            SabberStoneCore.Model.Entities.IPlayable spell = Generic.DrawCard(game.CurrentPlayer, Cards.FromName("Fireball"));
            game.Process(PlayCardTask.SpellTarget(game.CurrentPlayer, spell, testCard));
            Assert.Equal(1, game.CurrentOpponent.BoardZone.Count);
            Assert.Equal("FP1_007t", game.CurrentOpponent.BoardZone[0].Card.Id);
        }
Ejemplo n.º 3
0
        public Playable(SabberEntities.IPlayable playable, bool hand)
        {
            CardId = playable.Card.AssetId;
            Cost   = playable.Cost;
            if (playable is SabberEntities.Character c)
            {
                ATK        = c.AttackDamage;
                BaseHealth = c.BaseHealth;
            }
            else
            {
                ATK        = 0;
                BaseHealth = 0;
            }

            if (hand)
            {
                Ghostly = playable[SabberStoneCore.Enums.GameTag.GHOSTLY] == 1;
            }
            else
            {
                Ghostly = false;
            }
        }
Ejemplo n.º 4
0
        internal void ProcessPlayerAction()
        {
            foreach (var playerAction in _playerActions)
            {
                _isProcessingTask = true;
                _randomController.RandomHappened = false;
                if (playerAction.ActionType == ActionType.PLAYCARD && playerAction.Player == 2)
                {
                    STCEntities.IPlayable toBePlayed = STCEntities.Entity.FromCard(_game.Player2, STC.Cards.FromAssetId(playerAction.Source.Card.DbfIf));
                    _game.Player2.HandZone.Replace(_game.Player2.HandZone[0], toBePlayed);
                    _entityIdMapping.Add(playerAction.Source.Id, toBePlayed.Id);
                }
                List <PlayerTask> allOptions      = playerAction.Player == 1 ? _game.Player1.Options(true) : _game.Player2.Options(true);
                List <PlayerTask> filteredOptions = new List <PlayerTask>();
                allOptions.ForEach(option =>
                {
                    try
                    {
                        switch (playerAction.ActionType)
                        {
                        case ActionType.HEROPOWER:
                            if (option is HeroPowerTask)
                            {
                                filteredOptions.Add(option);
                            }
                            break;

                        case ActionType.PLAYCARD:
                            if (option is PlayCardTask)
                            {
                                if (option.Source.Id == _entityIdMapping[playerAction.Source.Id])
                                {
                                    filteredOptions.Add(option);
                                }
                            }
                            break;

                        case ActionType.MINIONATTACK:
                            if (option is MinionAttackTask)
                            {
                                if (option.Source.Id == _entityIdMapping[playerAction.AttackInfo.Attacker.Id])
                                {
                                    filteredOptions.Add(option);
                                }
                            }
                            if (option is HeroAttackTask)
                            {
                                if (option.Controller.HeroId == _entityIdMapping[playerAction.AttackInfo.Attacker.Id])
                                {
                                    filteredOptions.Add(option);
                                }
                            }
                            break;
                        }
                    }
                    catch (Exception e)
                    {
                        throw e;
                    }
                });

                if (filteredOptions.Count > 0)
                {
                    if (filteredOptions.Count == 1)
                    {
                        _game.Process(filteredOptions[0]);
                        _game.MainCleanUp();
                    }
                    else
                    {
                        STC.Game nextGame = null;
                        List <List <string> > errorsList = new List <List <string> >();
                        foreach (PlayerTask task in filteredOptions)
                        {
                            STC.Game clonedGame = _game.Clone(false, false, _randomController.Clone());
                            clonedGame.Process(task);
                            clonedGame.MainCleanUp();
                            var errors = Converter.AreGamesInSync(clonedGame, Core.Game);
                            if (errors.Count == 0)
                            {
                                nextGame = clonedGame;
                                break;
                            }
                            else
                            {
                                errorsList.Add(errors);
                            }
                        }
                        if (nextGame == null)
                        {
                            System.Diagnostics.Debugger.Break();
                        }
                        _game             = nextGame;
                        _randomController = (RandomController)nextGame.RandomController;
                    }
                    Converter.SyncEntityIds(ref _entityIdMapping, _game, Core.Game);
                    _game.Step = Step.MAIN_ACTION;
                    _randomController.Reset();
                    if (_randomController.RandomHappened)
                    {
                        launchAgent();
                    }
                }
                else
                {
                    System.Diagnostics.Debugger.Break();
                    var foo = playerAction.Player == 1 ? _game.Player1.Options(true) : _game.Player2.Options(true);
                }
            }
            _isProcessingTask = false;
            _randomController.RandomHappened = false;
            _playerActions = new List <PlayerAction>();
        }