Esempio n. 1
0
        protected override void Execute()
        {
            var spell = card.ConstructSpell();

            this.CastedSpell = spell;
            int index = 0;

            if (IllegalManaUsed())
            {
                throw new ManaMismatchException(card, castingPlayer, selectedMana);
            }
            else
            {
                if (selectedMana.Length > 0)
                {
                    this.castingPlayer.ManaStorage.Spend(selectedMana);
                }

                foreach (IEnumerable <object> targetList in targets)
                {
                    spell.SetTarget(index, targetList.ToArray());
                    index++;
                }
                this.EventManager.Raise(new EnqueueAbilityEvent(spell));
                this.RunAction(new ResetPrioritiesAction());

                Trigger <DequeueAbilityEvent> trig   = null;
                Action <DequeueAbilityEvent>  action = evt =>
                {
                    this.card.Owner.Library.AddBottom(this.CastedCard);
                    this.EventManager.Deregister(trig);
                };
                trig = new Trigger <DequeueAbilityEvent>(evt => evt.Ability == spell, action);
                this.EventManager.Register(trig);
            }
        }