/// <summary> /// Plays a spell /// </summary> /// <param name="spell">The spell to play</param> /// <param name="subTarget">The sub target for this spell card if applicable</param> /// <param name="cardEffect">The card effect to use</param> public void PlaySpell(BaseSpell spell, IDamageableEntity subTarget = null, CardEffect cardEffect = CardEffect.NONE) { if (subTarget != null && subTarget is BaseMinion) { if (((BaseMinion)subTarget).IsImmuneToSpellTarget || ((BaseMinion)subTarget).IsStealthed) { throw new InvalidOperationException("Can't target minion that is immune to spell targeting or is stealthed"); } } // Remove it from the player's hand this.hand.Remove(spell); // Remove mana from the player this.Mana -= spell.CurrentManaCost; // Fire spell casting event bool shouldAbort; GameEventManager.SpellCasting(spell, subTarget, out shouldAbort); // Check if we need to abort the spell or redirect if (!shouldAbort) { spell.Activate(subTarget, cardEffect); } // Fire spell casted event (if we need to) }