Beispiel #1
0
        public static Enchant Health(int amount, params RelaCondition[] list)
        {
            var relaConditions = new List <RelaCondition>
            {
                RelaCondition.IsNotSelf
            };

            relaConditions.AddRange(list);
            var result = new Enchant
            {
                EnableConditions = new List <SelfCondition>
                {
                    SelfCondition.IsInZone(Zone.PLAY),
                    SelfCondition.IsNotSilenced
                },
                ApplyConditions = relaConditions,
                Effects         = new Dictionary <GameTag, int>()
                {
                    [GameTag.HEALTH] = amount
                },
                // Health Retention task ...
                RemovalTask = ComplexTask.Create(
                    new IncludeTask(EntityType.MINIONS, new [] { EntityType.SOURCE }),
                    new FilterStackTask(EntityType.SOURCE, relaConditions.ToArray()),
                    new HealthRetentionTask(amount, EntityType.STACK))
            };

            list.ToList().ForEach(p => result.ApplyConditions.Add(p));
            return(result);
        }
Beispiel #2
0
        public OrderedDictionary Vector()
        {
            var v = new OrderedDictionary();

            if (Aura != null)
            {
                v.AddRange(Aura.Vector(), Prefix());
            }
            //v.AddRange(Aura != null ? Aura.Vector : Auras.Aura.NullVector, Prefix);

            if (Enchant != null)
            {
                v.AddRange(Enchant.Vector(), Prefix());
            }
            //v.AddRange(Enchant != null ? Enchant.Vector : Enchant.NullVector, Prefix);

            if (Trigger != null)
            {
                v.AddRange(Trigger.Vector(), Prefix());
            }
            //v.AddRange(Trigger != null ? Trigger.Vector : Trigger.GetNullVector(), Prefix);

            if (PowerTask != null)
            {
                v.AddRange(PowerTask.Vector(), Prefix());
            }
            //v.AddRange(PowerTask != null ? SimpleTask.GetVector(PowerTask) : SimpleTask.GetNullVector("NullPowerTask."), Prefix);

            if (DeathrattleTask != null)
            {
                v.AddRange(DeathrattleTask.Vector(), Prefix());
            }
            //v.AddRange(DeathrattleTask != null ? SimpleTask.GetVector(DeathrattleTask) : SimpleTask.GetNullVector("NullDeathrattleTask."), Prefix);

            if (ComboTask != null)
            {
                v.AddRange(ComboTask.Vector(), Prefix());
            }
            //v.AddRange(ComboTask != null ? SimpleTask.GetVector(ComboTask) : SimpleTask.GetNullVector("NullComboTask."), Prefix);

            if (TopDeckTask != null)
            {
                v.AddRange(TopDeckTask.Vector(), Prefix());
            }
            //v.AddRange(TopDeckTask != null ? SimpleTask.GetVector(TopDeckTask) : SimpleTask.GetNullVector("NullTopDeckTask."), Prefix);

            if (OverkillTask != null)
            {
                v.AddRange(OverkillTask.Vector(), Prefix());
            }
            //v.AddRange(OverkillTask != null ? SimpleTask.GetVector(OverkillTask) : SimpleTask.GetNullVector("NullOverkillTask."), Prefix);

            return(v);
        }
Beispiel #3
0
        public static Enchant Immune(params RelaCondition[] list)
        {
            var result = new Enchant
            {
                EnableConditions = new List <SelfCondition>
                {
                    SelfCondition.IsThisWeaponEquiped
                },
                Effects = new Dictionary <GameTag, int>()
                {
                    [GameTag.IMMUNE] = 1
                }
            };

            list.ToList().ForEach(p => result.ApplyConditions.Add(p));
            return(result);
        }
Beispiel #4
0
        public static Enchant WeaponAttack(int amount, params RelaCondition[] list)
        {
            var result = new Enchant
            {
                EnableConditions = new List <SelfCondition>
                {
                    SelfCondition.IsThisWeaponEquiped
                },
                Effects = new Dictionary <GameTag, int>()
                {
                    [GameTag.ATK] = amount
                }
            };

            list.ToList().ForEach(p => result.ApplyConditions.Add(p));
            return(result);
        }
Beispiel #5
0
        public static Enchant SimpleInclSelf(Dictionary <GameTag, int> effects, params RelaCondition[] list)
        {
            // health is only allowed with the HealthRetentionTask
            if (effects.Keys.Contains(GameTag.HEALTH))
            {
                throw new NotSupportedException();
            }

            var result = new Enchant
            {
                EnableConditions = new List <SelfCondition>
                {
                    SelfCondition.IsInZone(Zone.PLAY),
                    SelfCondition.IsNotSilenced
                },
                Effects = effects
            };

            list.ToList().ForEach(p => result.ApplyConditions.Add(p));
            return(result);
        }
Beispiel #6
0
        public static Enchant Attack(int amount, params RelaCondition[] list)
        {
            var result = new Enchant
            {
                EnableConditions = new List <SelfCondition>
                {
                    SelfCondition.IsInZone(Zone.PLAY),
                    SelfCondition.IsNotSilenced
                },
                ApplyConditions = new List <RelaCondition>
                {
                    RelaCondition.IsNotSelf
                },
                Effects = new Dictionary <GameTag, int>()
                {
                    [GameTag.ATK] = amount
                }
            };

            list.ToList().ForEach(p => result.ApplyConditions.Add(p));
            return(result);
        }
Beispiel #7
0
        public void Activate(Controller controller, IPlayable source, IPlayable target = null)
        {
            // execute task straight over
            if (SingleTask != null)
            {
                // clone task here
                var clone = SingleTask.Clone();
                clone.Game       = controller.Game;
                clone.Controller = controller;
                clone.Source     = source;
                clone.Target     = target;

                controller.Game.TaskQueue.Enqueue(clone);
            }

            // only apply enchant and triggers if there is ...
            if (Enchant == null && Trigger == null)
            {
                return;
            }

            switch (Area)
            {
            case EnchantmentArea.TARGET:
                if (target != null)
                {
                    Enchant?.Activate(source.Card.Id, target.Enchants, target);
                    Trigger?.Activate(source.Card.Id, target.Triggers, target);
                }
                break;

            case EnchantmentArea.HAND:
                Enchant?.Activate(source.Card.Id, controller.Hand.Enchants, source);
                Trigger?.Activate(source.Card.Id, controller.Hand.Triggers, source);
                break;

            case EnchantmentArea.OP_HAND:
                Enchant?.Activate(source.Card.Id, controller.Opponent.Hand.Enchants, source);
                Trigger?.Activate(source.Card.Id, controller.Opponent.Hand.Triggers, source);
                break;

            case EnchantmentArea.HANDS:
                Enchant?.Activate(source.Card.Id, controller.Hand.Enchants, source);
                Trigger?.Activate(source.Card.Id, controller.Hand.Triggers, source);
                Enchant?.Activate(source.Card.Id, controller.Opponent.Hand.Enchants, source);
                Trigger?.Activate(source.Card.Id, controller.Opponent.Hand.Triggers, source);
                break;

            case EnchantmentArea.HAND_AND_BOARD:
                Enchant?.Activate(source.Card.Id, controller.Board.Enchants, source);
                Trigger?.Activate(source.Card.Id, controller.Board.Triggers, source);
                Enchant?.Activate(source.Card.Id, controller.Hand.Enchants, source);
                Trigger?.Activate(source.Card.Id, controller.Hand.Triggers, source);
                break;

            case EnchantmentArea.BOARD:
                Enchant?.Activate(source.Card.Id, controller.Board.Enchants, source);
                Trigger?.Activate(source.Card.Id, controller.Board.Triggers, source);
                break;

            case EnchantmentArea.OP_BOARD:
                Enchant?.Activate(source.Card.Id, controller.Opponent.Board.Enchants, source);
                Trigger?.Activate(source.Card.Id, controller.Opponent.Board.Triggers, source);
                break;

            case EnchantmentArea.OP_BOARD_AND_OP_HERO:
                Enchant?.Activate(source.Card.Id, controller.Opponent.Board.Enchants, source);
                Trigger?.Activate(source.Card.Id, controller.Opponent.Board.Triggers, source);
                Enchant?.Activate(source.Card.Id, controller.Opponent.Hero.Enchants, source);
                Trigger?.Activate(source.Card.Id, controller.Opponent.Hero.Triggers, source);
                break;

            case EnchantmentArea.BOARDS:
                Enchant?.Activate(source.Card.Id, controller.Board.Enchants, source);
                Trigger?.Activate(source.Card.Id, controller.Board.Triggers, source);
                Enchant?.Activate(source.Card.Id, controller.Opponent.Board.Enchants, source);
                Trigger?.Activate(source.Card.Id, controller.Opponent.Board.Triggers, source);
                break;

            case EnchantmentArea.SECRET:
                Enchant?.Activate(source.Card.Id, controller.Secrets.Enchants, source);
                Trigger?.Activate(source.Card.Id, controller.Secrets.Triggers, source);
                break;

            case EnchantmentArea.HERO:
                Enchant?.Activate(source.Card.Id, controller.Hero.Enchants, source);
                Trigger?.Activate(source.Card.Id, controller.Hero.Triggers, source);
                break;

            case EnchantmentArea.HEROES:
                Enchant?.Activate(source.Card.Id, controller.Hero.Enchants, source);
                Trigger?.Activate(source.Card.Id, controller.Hero.Triggers, source);
                Enchant?.Activate(source.Card.Id, controller.Opponent.Hero.Enchants, source);
                Trigger?.Activate(source.Card.Id, controller.Opponent.Hero.Triggers, source);
                break;

            case EnchantmentArea.SELF:
                Enchant?.Activate(source.Card.Id, source.Enchants, source);
                Trigger?.Activate(source.Card.Id, source.Triggers, source);
                break;

            case EnchantmentArea.CONTROLLER:
                Enchant?.Activate(source.Card.Id, controller.Enchants, source);
                Trigger?.Activate(source.Card.Id, controller.Triggers, source);
                break;

            case EnchantmentArea.OP_CONTROLLER:
                Enchant?.Activate(source.Card.Id, controller.Opponent.Enchants, source);
                Trigger?.Activate(source.Card.Id, controller.Opponent.Triggers, source);
                break;

            case EnchantmentArea.CONTROLLERS:
                Enchant?.Activate(source.Card.Id, controller.Enchants, source);
                Trigger?.Activate(source.Card.Id, controller.Triggers, source);
                Enchant?.Activate(source.Card.Id, controller.Opponent.Enchants, source);
                Trigger?.Activate(source.Card.Id, controller.Opponent.Triggers, source);
                break;

            case EnchantmentArea.GAME:
                Enchant?.Activate(source.Card.Id, controller.Game.Enchants, source);
                Trigger?.Activate(source.Card.Id, controller.Game.Triggers, source);
                break;

            case EnchantmentArea.BOARDS_HEROES:
                Enchant?.Activate(source.Card.Id, controller.Hero.Enchants, source);
                Trigger?.Activate(source.Card.Id, controller.Hero.Triggers, source);
                Enchant?.Activate(source.Card.Id, controller.Opponent.Hero.Enchants, source);
                Trigger?.Activate(source.Card.Id, controller.Opponent.Hero.Triggers, source);
                Enchant?.Activate(source.Card.Id, controller.Board.Enchants, source);
                Trigger?.Activate(source.Card.Id, controller.Board.Triggers, source);
                Enchant?.Activate(source.Card.Id, controller.Opponent.Board.Enchants, source);
                Trigger?.Activate(source.Card.Id, controller.Opponent.Board.Triggers, source);
                break;

            default:
                throw new NotImplementedException();
            }
        }
Beispiel #8
0
        /// <summary>
        /// Generate proper <see cref="Enchant"/> from the text of the given card.
        /// </summary>
        /// <param name="cardId"></param>
        /// <returns></returns>
        public static Enchant GetAutoEnchantFromText(string cardId)
        {
            Card   card    = Cards.FromId(cardId);
            string text    = card.Text;
            var    effects = new List <IEffect>();
            bool   oneTurn = false;
            bool   mod     = false;

            Match attackHealth = AttackHealth.Match(text);
            Match attack       = Attack.Match(text);
            Match health       = Health.Match(text);
            Match set          = SetAttackHealth.Match(text);

            if (attackHealth.Success)
            {
                effects.Add(Effects.Attack_N(Int32.Parse(attackHealth.Groups[1].Value)));
                effects.Add(Effects.Health_N(Int32.Parse(attackHealth.Groups[2].Value)));
            }
            else if (attack.Success)
            {
                effects.Add(Effects.Attack_N(Int32.Parse(attack.Groups[1].Value)));
            }
            else if (health.Success)
            {
                effects.Add(Effects.Health_N(Int32.Parse(health.Groups[1].Value)));
            }
            else if
            (set.Success)
            {
                effects.Add(Effects.SetAttack(Int32.Parse(set.Groups[1].Value)));
                effects.Add(Effects.SetMaxHealth(Int32.Parse(set.Groups[2].Value)));
            }
            // generate magnetic enchants
            else if (card[GameTag.MODULAR] == 1)
            {
                effects.AddRange(Effects.AttackHealth_N(0));
                mod = true;
            }

            if (text.Contains(@"<b>Taunt</b>"))
            {
                effects.Add(Effects.TauntEff);
            }

            if (text.Contains(@"<b>Windfury</b>"))
            {
                effects.Add(Effects.Windfury);
            }

            if (text.Contains(@"<b>Charge</b>"))
            {
                effects.Add(Effects.Charge);
            }

            if (text.Contains(@"<b>Immune</b>"))
            {
                effects.Add(Effects.Immune);
            }

            if (text.Contains(@"<b>Divine Shield</b>"))
            {
                effects.Add(new Effect(GameTag.DIVINE_SHIELD, EffectOperator.SET, 1));
            }

            if (text.Contains(@"<b>Poisonous</b>"))
            {
                effects.Add(new Effect(GameTag.POISONOUS, EffectOperator.SET, 1));
            }

            if (text.Contains(@"<b>Lifesteal</b>"))
            {
                effects.Add(Effects.Lifesteal);
            }

            if (text.Contains(@"<b>Rush</b>"))
            {
                effects.Add(Effects.Rush);
            }

            if (text.Contains("this turn"))
            {
                oneTurn = true;
            }

            var output = new Enchant(effects.ToArray())
            {
                IsOneTurnEffect = oneTurn
            };

            if (mod)
            {
                output.UseScriptTag = true;
            }

            return(output);
        }