Class Enchantment

java.lang.Object
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<Entity>, HasCard, Trigger
Direct Known Subclasses:
Aftermath, Aura, CardCostModifier, Opener, Quest, Secret, WhereverTheyAreEnchantment

public class Enchantment
extends Entity
implements Trigger
An enchantment is a type of entity that reacts to certain events using a trigger by casting a spell.

Enchantments live inside GameLogic.getActiveTriggers(EntityReference); some enchantments, like Secret and Quest, live in their respective zones Zones.QUEST and Zones.SECRET.

Enchantments consistent of two important features: a EventTrigger built from an EventTriggerDesc, and a SpellDesc indicating which spell should be cast when the enchantment's EventTrigger and its conditions EventTrigger.innerQueues(GameEvent, Enchantment, Entity).

Enchantments are specified by a EnchantmentDesc in the card JSON. They can also be specified as fields in e.g., AddEnchantmentSpell.

The lifecycle of an enchantment looks like the following:

  • onAdd: Called when the enchantment comes into play. At this moment, the number of times the enchantment has been fired is set to zero; it is not expired, and
  • onGameEvent: Gives the enchantment a chance to look at a GameEvent, evaluate a EventTrigger against it, and determine whether its EnchantmentDesc.getSpell() should be cast.
  • onRemove: Expires the enchantment, ensuring it will never fire again.
An enchantment's lifecycle matches the entity it is hosted by, like an Actor, the Player entity (when e.g. AddEnchantmentSpell has a SpellArg.TARGET of EntityReference.FRIENDLY_PLAYER) or itself (in the case of a quest and secret). This means that EntityReference.FRIENDLY_PLAYER is a natural host for Enchantment objects that should not be removed for any reason like minion death.
See Also:
for a description of the format of an enchantment., Serialized Form