예제 #1
0
            public override TaskState Process()
            {
                // get a new class
                CardClass randClass = 0;

                do
                {
                    randClass = (CardClass)Random.Next(2, 11);
                } while (randClass == CardClass.WARLOCK);

                // replace Hero Power
                Card heroPowerCard = null;

                switch (randClass)
                {
                case CardClass.DRUID:
                    heroPowerCard = Cards.FromId("CS2_017");
                    break;

                case CardClass.HUNTER:
                    heroPowerCard = Cards.FromId("DS1h_292");
                    break;

                case CardClass.MAGE:
                    heroPowerCard = Cards.FromId("CS2_034");
                    break;

                case CardClass.PALADIN:
                    heroPowerCard = Cards.FromId("CS2_101");
                    break;

                case CardClass.PRIEST:
                    heroPowerCard = Cards.FromId("CS1h_001");
                    break;

                case CardClass.ROGUE:
                    heroPowerCard = Cards.FromId("CS2_083b");
                    break;

                case CardClass.SHAMAN:
                    heroPowerCard = Cards.FromId("CS2_049");
                    break;

                case CardClass.WARRIOR:
                    heroPowerCard = Cards.FromId("CS2_102");
                    break;
                }
                HeroPower heroPower =
                    (HeroPower)Entity.FromCard(Controller, heroPowerCard, new EntityData.Data
                {
                    { GameTag.CREATOR, Source.Id },
                    { GameTag.ZONE, (int)Zone.PLAY }
                });

                Controller.SetasideZone.Add(Controller.Hero.HeroPower);
                Controller.Hero.HeroPower = heroPower;

                var cards = Cards.FormatTypeClassCards(Game.FormatType)[randClass].Where(p => p.Class == randClass && !p.IsQuest).ToArray();

                // replace cards in hand
                for (int i = 0; i < Controller.HandZone.Count; i++)
                {
                    IPlayable entity = Controller.HandZone[i];
                    if (entity.Card.Class != CardClass.WARLOCK)
                    {
                        continue;
                    }
                    Controller.HandZone.Remove(entity);
                    Controller.SetasideZone.Add(entity);
                    var tags = new EntityData.Data
                    {
                        { GameTag.ZONE_POSITION, i + 1 },
                    };
                    if (Game.History)
                    {
                        tags.Add(GameTag.CREATOR, Source.Id);
                    }
                    IPlayable newEntity = Entity.FromCard(Controller, Util.Choose(cards), tags, Controller.HandZone, -1, i);
                    newEntity.NativeTags.Add(GameTag.DISPLAYED_CREATOR, Source.Id);
                    CostReduceEffect.Apply(newEntity.AuraEffects);
                }

                // replace cards in deck
                for (int i = Controller.DeckZone.Count - 1; i >= 0; i--)
                {
                    IPlayable entity = Controller.DeckZone[i];
                    if (entity.Card.Class != CardClass.WARLOCK)
                    {
                        continue;
                    }

                    Card      randCard  = Util.Choose(cards);
                    IPlayable newEntity = Entity.FromCard(Controller, randCard, null, Controller.DeckZone);
                    newEntity.NativeTags.Add(GameTag.DISPLAYED_CREATOR, Source.Id);

                    //Enchantment.GetInstance(Controller, (IPlayable) Source, newEntity, EnchantmentCard);

                    Controller.DeckZone.Remove(entity);
                    Controller.SetasideZone.Add(entity);

                    CostReduceEffect.Apply(newEntity.AuraEffects);
                }

                Game.OnRandomHappened(true);

                return(TaskState.COMPLETE);
            }
예제 #2
0
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

        public override TaskState Process()
        {
            if (Controller.BoardZone.IsFull)
            {
                return(TaskState.STOP);
            }

            IList <IPlayable> entities = IncludeTask.GetEntities(Type, Controller, Source, Target, Playables).ToList();

            if (entities.Count < 1)
            {
                return(TaskState.STOP);
            }

            // shuffle list randomly if needed
            entities = RandomFlag ? entities.OrderBy(x => Util.Random.Next()).ToList() : entities;

            if (RandomFlag)
            {
                Game.OnRandomHappened(true);
            }

            int space = Controller.BoardZone.MaxSize - Controller.BoardZone.Count;

            space = entities.Count > space ? space : entities.Count;

            if (entities[0].Zone == null || entities[0].Zone.Type != Enums.Zone.PLAY)
            {
                for (int i = 0; i < space; i++)
                {
                    // clone task here
                    var task = new SummonTask(_side, entities[i].Card)
                    {
                        Game       = Controller.Game,
                        Controller = Controller,
                        Source     = Source as IPlayable,
                        Target     = Target as IPlayable
                    };

                    Controller.Game.TaskQueue.Enqueue(task);
                }
            }
            else
            {
                for (int i = 0; i < entities.Count; i++)
                {
                    if (Controller.BoardZone.IsFull)
                    {
                        break;
                    }

                    Minion target = (Minion)entities[i];

                    var tags = new EntityData.Data((EntityData.Data)target.NativeTags);

                    if (target.Controller != Controller)
                    {
                        tags[GameTag.CONTROLLER] = Controller.PlayerId;
                    }

                    IPlayable copy = Entity.FromCard(Controller, target.Card, tags, Controller.BoardZone);

                    target.AppliedEnchantments?.ForEach(e =>
                    {
                        Enchantment instance = Enchantment.GetInstance(Controller, copy, copy, e.Card);
                        if (e[GameTag.TAG_SCRIPT_DATA_NUM_1] > 0)
                        {
                            instance[GameTag.TAG_SCRIPT_DATA_NUM_1] = e[GameTag.TAG_SCRIPT_DATA_NUM_1];
                            if (e[GameTag.TAG_SCRIPT_DATA_NUM_2] > 0)
                            {
                                instance[GameTag.TAG_SCRIPT_DATA_NUM_2] = e[GameTag.TAG_SCRIPT_DATA_NUM_2];
                            }
                        }
                    });

                    if (target.OngoingEffect != null && copy.OngoingEffect == null)
                    {
                        target.OngoingEffect.Clone(copy);
                    }

                    if (_addToStack)
                    {
                        Playables.Add(copy);
                    }
                }
            }



            return(TaskState.COMPLETE);
        }
예제 #3
0
        public override TaskState Process()
        {
            Minion target = (Minion)Target;

            if (target == null)
            {
                return(TaskState.STOP);
            }

            Minion source = (Minion)Source;

            if (source.Zone?.Type != Zone.PLAY)
            {
                return(TaskState.STOP);
            }

            var tags = new EntityData.Data
            {
                { GameTag.CREATOR, Source.Id },
            };

            if (Game.History)
            {
                tags.Add(GameTag.PREMIUM, target[GameTag.PREMIUM]);
            }

            Minion copy = (Minion)Entity.FromCard(Controller, target.Card, tags);

            Trigger trigger = target.ActivatedTrigger;
            IAura   aura    = target.OngoingEffect;

            // LINKED_ENTITY
            if (source == Game.CurrentEventData.EventSource)
            {
                Game.CurrentEventData.EventSource = copy;
            }
            source.Controller.BoardZone.Replace(source, copy);

            // Copy Enchantments
            if (target.AppliedEnchantments != null)
            {
                foreach (Enchantment e in target.AppliedEnchantments)
                {
                    Enchantment instance = Enchantment.GetInstance(Controller, copy, copy, e.Card);
                    if (e[GameTag.TAG_SCRIPT_DATA_NUM_1] > 0)
                    {
                        instance[GameTag.TAG_SCRIPT_DATA_NUM_1] = e[GameTag.TAG_SCRIPT_DATA_NUM_1];
                        if (e[GameTag.TAG_SCRIPT_DATA_NUM_2] > 0)
                        {
                            instance[GameTag.TAG_SCRIPT_DATA_NUM_2] = e[GameTag.TAG_SCRIPT_DATA_NUM_2];
                        }
                    }
                }
            }

            foreach (KeyValuePair <GameTag, int> kvp in target._data.Tags)
            {
                switch (kvp.Key)
                {
                case GameTag.ENTITY_ID:
                case GameTag.CONTROLLER:
                case GameTag.ZONE:
                case GameTag.ZONE_POSITION:
                case GameTag.CREATOR:
                case GameTag.PREMIUM:
                case GameTag.EXHAUSTED:
                    continue;

                default:
                    copy._data.Tags.Add(kvp.Key, kvp.Value);
                    break;
                }
            }

            if (aura != null && copy.OngoingEffect == null)
            {
                aura.Clone(copy);
            }

            if (!target.HasCharge)
            {
                copy.IsExhausted = true;
            }

            if (_addToStack)
            {
                Playables = new List <IPlayable> {
                    copy
                }
            }
            ;

            return(TaskState.COMPLETE);
        }