Class Enchantment
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparable<Entity>
,HasCard
,Trigger
- Direct Known Subclasses:
Aftermath
,Aura
,CardCostModifier
,Opener
,Quest
,Secret
,WhereverTheyAreEnchantment
Enchantments live inside GameLogic.getActiveTriggers(EntityReference)
; some enchantments, like Secret
and Quest
, live in their respective zones Spellsource.ZonesMessage.Zones.QUEST
and Spellsource.ZonesMessage.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 notexpired
, andonGameEvent
: Gives the enchantment a chance to look at aGameEvent
, evaluate aEventTrigger
against it, and determine whether itsEnchantmentDesc.getSpell()
should be cast.onRemove
: Expires the enchantment, ensuring it will never fire again.
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.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
protected List<EventTrigger>
protected boolean
protected boolean
protected boolean
protected Integer
protected List<EventTrigger>
protected boolean
protected int
protected EntityReference
protected boolean
protected Integer
protected boolean
protected boolean
protected SpellDesc
protected List<EventTrigger>
protected boolean
protected com.hiddenswitch.spellsource.rpc.Spellsource.ZonesMessage.Zones[]
Fields inherited from class net.demilich.metastone.game.entities.Entity
attributes, effectSource, entityLocation, name, NO_OWNER, sourceCard
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
activate()
protected void
clone()
Clone an entity, including its ID and location.void
Signals to the enchantment that the currently processing sequence is over.void
expire
(GameContext context) Expires the trigger; marks it for removal and prevents it from executing in the future.boolean
Returnstrue
if the trigger fire in response to the givenGameEvent
.getCopy()
static com.hiddenswitch.spellsource.rpc.Spellsource.ZonesMessage.Zones[]
static Set<com.hiddenswitch.spellsource.rpc.Spellsource.ZonesMessage.Zones>
static com.hiddenswitch.spellsource.rpc.Spellsource.ZonesMessage.Zones[]
static com.hiddenswitch.spellsource.rpc.Spellsource.ZonesMessage.Zones[]
static com.hiddenswitch.spellsource.rpc.Spellsource.ZonesMessage.Zones[]
protected EventTriggerDesc[]
protected com.hiddenswitch.spellsource.rpc.Spellsource.ZonesMessage.Zones[]
com.hiddenswitch.spellsource.rpc.Spellsource.EntityTypeMessage.EntityType
Gets the type of entity this is.HasEntrySet<?,
?> int
getFires()
Gets a reference to theEntity
that is "hosting," or owning, the trigger.boolean
getSpell()
Get the triggers that fire this enchantment.boolean
com.hiddenswitch.spellsource.rpc.Spellsource.ZonesMessage.Zones[]
getZones()
protected boolean
innerQueues
(GameEvent event, Entity host) boolean
interestedIn
(com.hiddenswitch.spellsource.rpc.Spellsource.GameEventTypeMessage.GameEventType eventType) Returns true if this trigger is a listener for the givenSpellsource.GameEventTypeMessage.GameEventType
.boolean
boolean
boolean
Indicates that theHasValue.getValue()
of the event should be used to increment the enchantment's counter (typically itsfires
) instead of the value 1 (i.e., every event that causes a trigger to fire increments the number of fires by 1).boolean
Checks if, due to the execution of possibly complex rules inside or outside the trigger, the trigger is expired (no longer should fire).boolean
boolean
Indicates this trigger cannot change owners.void
onAdd
(GameContext context, Player player, Entity source, Entity host) Called when the trigger is added into aGameContext
's state.boolean
Indicates this trigger is only active for the current turn, then it shouldTrigger.expire(GameContext)
.void
onGameEvent
(GameEvent event) Handles an event this triggerTrigger.queues(GameEvent)
for and isTrigger.interestedIn(com.hiddenswitch.spellsource.rpc.Spellsource.GameEventTypeMessage.GameEventType)
.protected boolean
Casts the effects of this enchantment.final boolean
Checks if a trigger should queue in response to a specific event.setActivated
(boolean activated) void
setActivationTriggers
(List<EventTrigger> activationTriggers) setCopyToActor
(boolean giveToActor) void
setCountByValue
(boolean countByValue) void
setCountUntilCast
(Integer countUntilCast) void
setExpirationTriggers
(List<EventTrigger> expirationTriggers) protected Enchantment
setFires
(int fires) void
setHostReference
(EntityReference reference) Sets or changes theEntity
that is the owner / host of this trigger.void
setKeepAfterTransform
(boolean keepAfterTransform) void
setMaxFires
(Integer maxFires) void
setMaxFiresPerSequence
(Integer maxFiresPerSequence) setOneTurn
(boolean oneTurn) void
setPersistentOwner
(boolean persistentOwner) setTriggers
(List<EventTrigger> triggers) void
setUsesSpellTrigger
(boolean usesSpellTrigger) setZones
(com.hiddenswitch.spellsource.rpc.Spellsource.ZonesMessage.Zones[] zones) protected boolean
toString()
Methods inherited from class net.demilich.metastone.game.entities.Entity
compareTo, diedOnBattlefield, evaluateDescriptions, getAttribute, getAttributes, getAttributeValue, getAttributeValue, getCardInventoryId, getCopySource, getDescription, getDescription, getDynamicDescription, getEffectSource, getEntityLocation, getGameTriggers, getId, getIndex, getMaxNumberOfAttacks, getName, getOwner, getRace, getReference, getUserId, getZone, hasAttribute, hasPersistentEffects, isDestroyed, isInPlay, isRemovedPeacefully, modifyAttribute, modifyHpBonus, moveOrAddTo, moveOrAddTo, resetEntityLocations, setAttribute, setAttribute, setAttribute, setDescription, setEffectSource, setEntityLocation, setId, setName, setOwner, setSourceCard, setUserId, transformResolved, transformResolved
-
Field Details
-
triggers
-
expirationTriggers
-
activationTriggers
-
spell
-
hostReference
-
oneTurn
protected boolean oneTurn -
activated
protected boolean activated -
expired
protected boolean expired -
persistentOwner
protected boolean persistentOwner -
keepAfterTransform
protected boolean keepAfterTransform -
countUntilCast
-
countByValue
protected boolean countByValue -
usesSpellTrigger
protected boolean usesSpellTrigger -
maxFiresPerSequence
-
firesThisSequence
protected int firesThisSequence -
copyToActor
protected boolean copyToActor -
zones
protected com.hiddenswitch.spellsource.rpc.Spellsource.ZonesMessage.Zones[] zones -
added
protected boolean added
-
-
Constructor Details
-
Enchantment
public Enchantment() -
Enchantment
-
-
Method Details
-
clone
Description copied from class:Entity
Clone an entity, including its ID and location.Use this method for emulating an "immutable" view on an entity. This kind of cloning is not suitable for most gameplay situations, because using the clone will cause two entities with identical IDs and locations to exist. Instead, a subclass will provide a
getCopy()
method that is more helpful for gameplay. -
getDefaultTriggers
-
getEntityType
public com.hiddenswitch.spellsource.rpc.Spellsource.EntityTypeMessage.EntityType getEntityType()Description copied from class:Entity
Gets the type of entity this is. These will very nearly match up with the classes, but are primarily used for filters that e.g. draw a Spell or destroy all Secrets.- Specified by:
getEntityType
in classEntity
- Returns:
- An
Spellsource.EntityTypeMessage.EntityType
-
expire
Description copied from interface:Trigger
Expires the trigger; marks it for removal and prevents it from executing in the future. -
getHostReference
Description copied from interface:Trigger
Gets a reference to theEntity
that is "hosting," or owning, the trigger.- Specified by:
getHostReference
in interfaceTrigger
- Returns:
- An entity reference. This is typically not null.
-
getSpell
-
isExpired
public boolean isExpired()Description copied from interface:Trigger
Checks if, due to the execution of possibly complex rules inside or outside the trigger, the trigger is expired (no longer should fire). -
onAdd
Description copied from interface:Trigger
Called when the trigger is added into aGameContext
's state. -
process
Casts the effects of this enchantment.- Parameters:
ownerId
-spell
-event
-- Returns:
true
if processing succeeded.
-
cast
-
onGameEvent
Description copied from interface:Trigger
Handles an event this triggerTrigger.queues(GameEvent)
for and isTrigger.interestedIn(com.hiddenswitch.spellsource.rpc.Spellsource.GameEventTypeMessage.GameEventType)
.- Specified by:
onGameEvent
in interfaceTrigger
- Parameters:
event
- The game event this trigger is now processing.
-
shouldNotifyEnchantmentFired
-
setHostReference
Description copied from interface:Trigger
Sets or changes theEntity
that is the owner / host of this trigger.- Specified by:
setHostReference
in interfaceTrigger
- Parameters:
reference
- The hostEntity
/
-
getCopy
-
toString
-
queues
Description copied from interface:Trigger
Checks if a trigger should queue in response to a specific event. -
innerQueues
-
isPersistentOwner
public boolean isPersistentOwner()Description copied from interface:Trigger
Indicates this trigger cannot change owners. For example, aSecret
does not have a persistent owner, because card texts can steal secrets. However, the trigger described by Blessing of Wisdom does have a persistent owner, since the casting player of that spell should always draw the card it receives.- Specified by:
isPersistentOwner
in interfaceTrigger
- Returns:
true
if the trigger'sTrigger.onGameEvent(GameEvent)
should be evaluated from the point of view of the owner when the trigger was created, as opposed to what the owner is right now (which may have changed).
-
setPersistentOwner
public void setPersistentOwner(boolean persistentOwner) -
oneTurnOnly
public boolean oneTurnOnly()Description copied from interface:Trigger
Indicates this trigger is only active for the current turn, then it shouldTrigger.expire(GameContext)
.- Specified by:
oneTurnOnly
in interfaceTrigger
- Returns:
true
if this is a one-turn long trigger.
-
fires
Description copied from interface:Trigger
Returnstrue
if the trigger fire in response to the givenGameEvent
.It is already queued in this situation.
-
getSourceCard
- Specified by:
getSourceCard
in interfaceHasCard
- Overrides:
getSourceCard
in classEntity
-
getFires
public int getFires() -
getMaxFires
-
setMaxFires
-
setKeepAfterTransform
public void setKeepAfterTransform(boolean keepAfterTransform) -
isKeptAfterTransform
public boolean isKeptAfterTransform() -
setCountUntilCast
-
getCountUntilCast
-
setSpell
-
setCountByValue
public void setCountByValue(boolean countByValue) -
isCountByValue
public boolean isCountByValue()Indicates that theHasValue.getValue()
of the event should be used to increment the enchantment's counter (typically itsfires
) instead of the value 1 (i.e., every event that causes a trigger to fire increments the number of fires by 1).- Returns:
true
if the enchantment increases its fires counter by the event's value.
-
getTriggers
Get the triggers that fire this enchantment.- Returns:
- A list of triggers.
-
setMaxFiresPerSequence
-
getMaxFiresPerSequence
-
endOfSequence
public void endOfSequence()Signals to the enchantment that the currently processing sequence is over. -
setTriggers
-
setExpirationTriggers
-
getExpirationTriggers
-
isActivated
public boolean isActivated()- Specified by:
isActivated
in interfaceTrigger
-
activate
public void activate() -
getActivationTriggers
-
setActivationTriggers
-
setActivated
-
getZones
public com.hiddenswitch.spellsource.rpc.Spellsource.ZonesMessage.Zones[] getZones() -
getDefaultZones
protected com.hiddenswitch.spellsource.rpc.Spellsource.ZonesMessage.Zones[] getDefaultZones() -
setOneTurn
-
getOneTurn
public boolean getOneTurn() -
setUsesSpellTrigger
public void setUsesSpellTrigger(boolean usesSpellTrigger) -
getUsesSpellTrigger
public boolean getUsesSpellTrigger() -
setFires
-
getDefaultBattlefieldZones
public static com.hiddenswitch.spellsource.rpc.Spellsource.ZonesMessage.Zones[] getDefaultBattlefieldZones() -
getDefaultPassiveZones
public static com.hiddenswitch.spellsource.rpc.Spellsource.ZonesMessage.Zones[] getDefaultPassiveZones() -
getDefaultGameZones
public static com.hiddenswitch.spellsource.rpc.Spellsource.ZonesMessage.Zones[] getDefaultGameZones() -
getDefaultDeckZones
public static com.hiddenswitch.spellsource.rpc.Spellsource.ZonesMessage.Zones[] getDefaultDeckZones() -
getDefaultBattlefieldZonesSet
public static Set<com.hiddenswitch.spellsource.rpc.Spellsource.ZonesMessage.Zones> getDefaultBattlefieldZonesSet() -
isCopyToActor
public boolean isCopyToActor() -
setCopyToActor
-
getEntrySet
-