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 aEventTriggeragainst 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 booleanprotected List<EventTrigger>protected booleanprotected booleanprotected booleanprotected Integerprotected List<EventTrigger>protected booleanprotected intprotected EntityReferenceprotected booleanprotected Integerprotected booleanprotected booleanprotected SpellDescprotected List<EventTrigger>protected booleanprotected 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 TypeMethodDescriptionvoidactivate()protected voidclone()Clone an entity, including its ID and location.voidSignals to the enchantment that the currently processing sequence is over.voidexpire(GameContext context) Expires the trigger; marks it for removal and prevents it from executing in the future.booleanReturnstrueif 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.EntityTypeGets the type of entity this is.HasEntrySet<?,?> intgetFires()Gets a reference to theEntitythat is "hosting," or owning, the trigger.booleangetSpell()Get the triggers that fire this enchantment.booleancom.hiddenswitch.spellsource.rpc.Spellsource.ZonesMessage.Zones[]getZones()protected booleaninnerQueues(GameEvent event, Entity host) booleaninterestedIn(com.hiddenswitch.spellsource.rpc.Spellsource.GameEventTypeMessage.GameEventType eventType) Returns true if this trigger is a listener for the givenSpellsource.GameEventTypeMessage.GameEventType.booleanbooleanbooleanIndicates 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).booleanChecks if, due to the execution of possibly complex rules inside or outside the trigger, the trigger is expired (no longer should fire).booleanbooleanIndicates this trigger cannot change owners.voidonAdd(GameContext context, Player player, Entity source, Entity host) Called when the trigger is added into aGameContext's state.booleanIndicates this trigger is only active for the current turn, then it shouldTrigger.expire(GameContext).voidonGameEvent(GameEvent event) Handles an event this triggerTrigger.queues(GameEvent)for and isTrigger.interestedIn(com.hiddenswitch.spellsource.rpc.Spellsource.GameEventTypeMessage.GameEventType).protected booleanCasts the effects of this enchantment.final booleanChecks if a trigger should queue in response to a specific event.setActivated(boolean activated) voidsetActivationTriggers(List<EventTrigger> activationTriggers) setCopyToActor(boolean giveToActor) voidsetCountByValue(boolean countByValue) voidsetCountUntilCast(Integer countUntilCast) voidsetExpirationTriggers(List<EventTrigger> expirationTriggers) protected EnchantmentsetFires(int fires) voidsetHostReference(EntityReference reference) Sets or changes theEntitythat is the owner / host of this trigger.voidsetKeepAfterTransform(boolean keepAfterTransform) voidsetMaxFires(Integer maxFires) voidsetMaxFiresPerSequence(Integer maxFiresPerSequence) setOneTurn(boolean oneTurn) voidsetPersistentOwner(boolean persistentOwner) setTriggers(List<EventTrigger> triggers) voidsetUsesSpellTrigger(boolean usesSpellTrigger) setZones(com.hiddenswitch.spellsource.rpc.Spellsource.ZonesMessage.Zones[] zones) protected booleantoString()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:EntityClone 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:EntityGets 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:
getEntityTypein classEntity- Returns:
- An
Spellsource.EntityTypeMessage.EntityType
-
expire
Description copied from interface:TriggerExpires the trigger; marks it for removal and prevents it from executing in the future. -
getHostReference
Description copied from interface:TriggerGets a reference to theEntitythat is "hosting," or owning, the trigger.- Specified by:
getHostReferencein interfaceTrigger- Returns:
- An entity reference. This is typically not null.
-
getSpell
-
isExpired
public boolean isExpired()Description copied from interface:TriggerChecks 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:TriggerCalled when the trigger is added into aGameContext's state. -
process
Casts the effects of this enchantment.- Parameters:
ownerId-spell-event-- Returns:
trueif processing succeeded.
-
cast
-
onGameEvent
Description copied from interface:TriggerHandles an event this triggerTrigger.queues(GameEvent)for and isTrigger.interestedIn(com.hiddenswitch.spellsource.rpc.Spellsource.GameEventTypeMessage.GameEventType).- Specified by:
onGameEventin interfaceTrigger- Parameters:
event- The game event this trigger is now processing.
-
shouldNotifyEnchantmentFired
-
setHostReference
Description copied from interface:TriggerSets or changes theEntitythat is the owner / host of this trigger.- Specified by:
setHostReferencein interfaceTrigger- Parameters:
reference- The hostEntity/
-
getCopy
-
toString
-
queues
Description copied from interface:TriggerChecks if a trigger should queue in response to a specific event. -
innerQueues
-
isPersistentOwner
public boolean isPersistentOwner()Description copied from interface:TriggerIndicates this trigger cannot change owners. For example, aSecretdoes 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:
isPersistentOwnerin interfaceTrigger- Returns:
trueif 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:TriggerIndicates this trigger is only active for the current turn, then it shouldTrigger.expire(GameContext).- Specified by:
oneTurnOnlyin interfaceTrigger- Returns:
trueif this is a one-turn long trigger.
-
fires
Description copied from interface:TriggerReturnstrueif the trigger fire in response to the givenGameEvent.It is already queued in this situation.
-
getSourceCard
- Specified by:
getSourceCardin interfaceHasCard- Overrides:
getSourceCardin 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:
trueif 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:
isActivatedin 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
-