Class Aura
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparable<Entity>
,HasDesc<AuraDesc>
,HasCard
,Trigger
- Direct Known Subclasses:
EffectlessAura
,SpellAura
Because auras evaluate which entities they affect on board changes and sequence endings, they aren't affecting
entities the moment they "come into play" (are attached to a host that is Entity.isInPlay()
). However, since
a BoardChangedEvent
is fired right after a minion is put on the Spellsource.ZonesMessage.Zones.BATTLEFIELD
during a GameLogic.summon(int, Minion, Entity, int, boolean)
call, in practice auras come
into play immediately. Specifically, a minion with an aura written on it will not be affecting entities by the BeforeSummonEvent
event, but only by the first BoardChangedEvent
(which
comes before any battlecries are resolved or before control is given back to the player).
Auras have the following format (corresponding to AuraDesc
):
{ "class": An Aura class. When the class is Aura, the apply and remove effects below are used. Otherwise, for classes like BuffAura, the apply and remove effects are provided by the class. "target": AnEntityReference
for all the entities affected by this aura "filter": A filter on those entities. Evaluated against everytarget
entity in the"target"
specified. "applyEffect": ASpellDesc
that corresponds to the spell to cast on a given entity when it transitions from being unaffected to affected by this aura. Thetarget
is the entity newly under the influence of the aura andsource
is theEntityReference.TRIGGER_HOST
/ host of the aura. "removeEffect": ASpellDesc
that corresponds to the spell to cast on an entity when it was previously affected and it is now transitioning into not being affected. Thetarget
is the entity newly under the influence of the aura andsource
is theEntityReference.TRIGGER_HOST
/ host of the aura. "condition": A condition that is evaluated whenever theBoardChangedEvent
is raised; theWillEndSequenceEvent
is raised; or "secondaryTrigger" is fired, against every entity that could be or currently is affected by this aura. When the condition is true, the entity that is affected remains affected; the entity that could not be affected is affected. When false, the entity that is affected stops being affected, and an entity that is not yet affected will still not be affected.target
in the condition will be the entity, andsource
will be theEntityReference.TRIGGER_HOST
/ host of the aura. "secondaryTrigger": Another trigger that, when fired, will cause this aura to reevaluate which entities are affected.EntityReference.EVENT_TARGET
will correspond to theGameEvent.getTarget()
processed by that trigger. }
An aura is not an abstract
class; it can be directly specified using an AuraDesc
with a specific
AuraArg.APPLY_EFFECT
and AuraArg.REMOVE_EFFECT
. The remove effect should reverse the consequences of
the add effect. Since this is challenging to come up with without a background in software engineering, the BuffAura
and AttributeAura
should cover most cases of ongoing effects correctly.
The onGameEvent(GameEvent)
method actually implements the evaluation of the condition, the filter, the
target and the add/remove effects. Observe that unlike an Enchantment
, which it inherits, auras do not
respect configuration features like Enchantment.getMaxFires()
. It is unclear how such features should be interpreted.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static EventTriggerDesc[]
protected static EventTriggerDesc[]
Fields inherited from class net.demilich.metastone.game.spells.trigger.Enchantment
activated, activationTriggers, added, copyToActor, countByValue, countUntilCast, expirationTriggers, expired, firesThisSequence, hostReference, keepAfterTransform, maxFiresPerSequence, oneTurn, persistentOwner, spell, triggers, usesSpellTrigger, 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 TypeMethodDescriptionprotected boolean
protected boolean
protected void
applyAuraEffect
(GameContext context, Entity target) protected void
clone()
Clone an entity, including its ID and location.void
expire
(GameContext context) Expires the trigger; marks it for removal and prevents it from executing in the future.getCopy()
protected EventTriggerDesc[]
getDesc()
Gets the possibly modified description of the entity to render to the end user.getName()
Gets the name of the entity (typically the name of the card that created this entity).protected EntityReference
boolean
Indicates this trigger cannot change owners.protected boolean
notApplied
(Entity target) void
onAdd
(GameContext context, Player player, Entity source, Entity host) Called when the trigger is added into aGameContext
's state.void
onGameEvent
(GameEvent event) Handles an event this triggerTrigger.queues(GameEvent)
for and isTrigger.interestedIn(com.hiddenswitch.spellsource.rpc.Spellsource.GameEventTypeMessage.GameEventType)
.protected void
removeAuraEffect
(GameContext context, Entity target) void
Methods inherited from class net.demilich.metastone.game.spells.trigger.Enchantment
activate, endOfSequence, fires, getActivationTriggers, getCountUntilCast, getDefaultBattlefieldZones, getDefaultBattlefieldZonesSet, getDefaultDeckZones, getDefaultGameZones, getDefaultPassiveZones, getDefaultZones, getEntityType, getEntrySet, getExpirationTriggers, getFires, getHostReference, getMaxFires, getMaxFiresPerSequence, getOneTurn, getSourceCard, getSpell, getTriggers, getUsesSpellTrigger, getZones, innerQueues, interestedIn, isActivated, isCopyToActor, isCountByValue, isExpired, isKeptAfterTransform, oneTurnOnly, process, queues, setActivated, setActivationTriggers, setCopyToActor, setCountByValue, setCountUntilCast, setExpirationTriggers, setFires, setHostReference, setKeepAfterTransform, setMaxFires, setMaxFiresPerSequence, setOneTurn, setPersistentOwner, setSpell, setTriggers, setUsesSpellTrigger, setZones, shouldNotifyEnchantmentFired, toString
Methods inherited from class net.demilich.metastone.game.entities.Entity
compareTo, diedOnBattlefield, evaluateDescriptions, getAttribute, getAttributes, getAttributeValue, getAttributeValue, getCardInventoryId, getCopySource, getDescription, getDynamicDescription, getEffectSource, getEntityLocation, getGameTriggers, getId, getIndex, getMaxNumberOfAttacks, 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
-
DEFAULT_TRIGGERS
-
EMPTY_TRIGGERS
-
-
Constructor Details
-
Aura
-
-
Method Details
-
getDefaultTriggers
- Overrides:
getDefaultTriggers
in classEnchantment
-
getName
Description copied from class:Entity
Gets the name of the entity (typically the name of the card that created this entity). Or, overridden by theAttribute.NAME
attribute set in this entity's attributes. -
getCopy
- Overrides:
getCopy
in classEnchantment
-
getDescription
Description copied from class:Entity
Gets the possibly modified description of the entity to render to the end user.- Overrides:
getDescription
in classEntity
- Returns:
- The
Entity.getSourceCard()
'sCard.getDescription()
field, or the value specified inAttribute.DESCRIPTION
.
-
affects
protected boolean affects(GameContext context, Player player, Entity target, List<Entity> resolvedTargets) -
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.- Specified by:
clone
in interfaceTrigger
- Overrides:
clone
in classEnchantment
- Returns:
- An exact clone.
-
onAdd
Description copied from interface:Trigger
Called when the trigger is added into aGameContext
's state.- Specified by:
onAdd
in interfaceTrigger
- Overrides:
onAdd
in classEnchantment
- Parameters:
context
- The game context.
-
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
- Overrides:
onGameEvent
in classEnchantment
- Parameters:
event
- The game event this trigger is now processing.
-
getTargets
-
applied
-
notApplied
-
removeAuraEffect
-
applyAuraEffect
-
expire
Description copied from interface:Trigger
Expires the trigger; marks it for removal and prevents it from executing in the future.- Specified by:
expire
in interfaceTrigger
- Overrides:
expire
in classEnchantment
-
getEntityFilter
-
getCondition
-
getDesc
-
setDesc
-
getAffectedEntities
-
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
- Overrides:
isPersistentOwner
in classEnchantment
- 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).
-
getSecondaryTarget
-
getApplyAuraEffect
-
getRemoveAuraEffect
-
cast
- Overrides:
cast
in classEnchantment
-