Esempio n. 1
0
        public void PlayTurn(Card c, Minion caster, TriggerItem target)
        {
            if (c.effect != null && c.effect is Effect_Rewind)
            {
                if (gameStates.Count <= 1)
                    return;
                // rewind isn't really a spell like everything else
                gameStates.RemoveAt(gameStates.Count - 1);
                gameStateOnSkip = gameStates.Last().GetGameStateOnSkip();
                selectionState = new UISelectionState(gameStates.Last());
            }
            else
            {
                GameState oldGameState = gameStates.Last();
                if (oldGameState.CanPlayCard(c, target))
                {
                    nextGameState = new GameState(gameStates.Last());

                    animation.Clear();
                    if (caster == null)
                        caster = nextGameState.wizard;

                    nextGameState.PlayCard(c, caster, nextGameState.Adapt(target), animation);
                    nextGameState.TurnEffects(animation);

                    gameStateOnSkip = nextGameState.GetGameStateOnSkip();
                }
            }
        }
        public bool CanPlayCard(Card card, TriggerItem target)
        {
            switch (card.targetType)
            {
                case TargetType.numeric_spell:
                    if (!target.card.HasANumber())
                        return false;
                    break;
                case TargetType.area_spell:
                    if (!target.card.HasAnArea())
                        return false;
                    break;
                case TargetType.empty:
                case TargetType.path:
                    if(target.permanent != null)
                        return false;
                    break;
                case TargetType.minion:
                    if (target.permanent == null)
                        return false;
                    break;
                case TargetType.friend:
                    if (target.permanent == null || target.permanent.isEnemy)
                        return false;
                    break;
                case TargetType.enemy:
                    if (target.permanent == null)
                    {
                        return false;
                    }
                    else
                    {
                        if (!target.permanent.isEnemy)
                            return false;
                    }
                    break;
            }

            if (card.targetTest != null && !card.targetTest.Test(target, new EffectContext(this, wizard, null, null)))
                return false;

            if (target.card == null && levelScript.Blocks(target.position, card.targetType))
                return false;

            return CanPlayCard(card);
        }
        public void PlayCard(Card c, Minion caster, TriggerItem target, MinionAnimationSequence animation)
        {
            PayCost(c.cost);

            HandleTriggers(new TriggerEvent(TriggerType.beforeSpells));
            if(Card.get("wait") != c)
                HandleTriggers(new TriggerEvent(TriggerType.beforeActualSpell, c));

            ApplyCardEffect(c, caster, target, animation);

            HandleTriggers(new TriggerEvent(TriggerType.afterSpells));
            if (c.effect != null || c.ongoingType != null)
                HandleTriggers(new TriggerEvent(TriggerType.afterActualSpell, c));
        }
 public TriggerItem Adapt(TriggerItem item)
 {
     if (item.card != null)
     {
         return item;
     }
     else
     {
         return getItemAt(item.position);
     }
 }
        public void ApplyCardEffect(Card c, Minion caster, TriggerItem target, MinionAnimationSequence animation)
        {
            TextChanges changes = null;
            if (cardTextChanges.ContainsKey(c))
                changes = cardTextChanges[c];

            ApplyEffect(c.effect, new EffectContext(this, changes, caster, target, new TriggerEvent(TriggerType.onSpell, caster, target.permanent), animation));

            if (c.ongoingType != null)
            {
                Point pos = target.position;
                ongoingEffects[pos] = new Ongoing(c, pos);
            }
        }
Esempio n. 6
0
 public override bool Test(TriggerItem item, EffectContext context)
 {
     return item.permanent == context.self;
 }
Esempio n. 7
0
 public override bool Test(TriggerItem item, EffectContext context)
 {
     return item.position == context.target.position;
 }
Esempio n. 8
0
 public override bool Test(TriggerItem item, EffectContext context)
 {
     return item.permanent.isEnemy != context.self.isEnemy;
 }
Esempio n. 9
0
 public override bool Test(TriggerItem item, EffectContext context)
 {
     foreach(Property_TriggerItem mtype in mtypes)
     {
         if (item.minionType == mtype.get(context).minionType)
             return true;
     }
     return false;
 }
Esempio n. 10
0
 public abstract bool Test(TriggerItem item, EffectContext context);
Esempio n. 11
0
 public override bool Test(TriggerItem item, EffectContext context)
 {
     return item.minionType != null && item.minionType.awakenType != null;
 }
Esempio n. 12
0
 public TriggerEvent(TriggerType type, Point a, Point b)
 {
     this.type = type;
     this.source = TriggerItem.create(a);
     this.target = TriggerItem.create(b);
 }
Esempio n. 13
0
 public TriggerEvent(TriggerType type, Point a)
 {
     this.type = type;
     this.source = TriggerItem.create(a);
 }
Esempio n. 14
0
 public TriggerEvent(TriggerType type, Card c, TriggerItem target)
 {
     this.type = type;
     this.source = TriggerItem.create(c);
     this.target = target;
 }
Esempio n. 15
0
 public TriggerEvent(TriggerType type, Card c)
 {
     this.type = type;
     this.source = TriggerItem.create(c);
 }
Esempio n. 16
0
 public Property_Literal_TriggerItem(TriggerItem value)
 {
     this.value = value;
 }