Class EnchantmentDesc
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,HasEntrySet<EnchantmentDescArg,java.lang.Object>
,AbstractEnchantmentDesc<Enchantment>
public final class EnchantmentDesc extends java.lang.Object implements java.io.Serializable, java.lang.Cloneable, HasEntrySet<EnchantmentDescArg,java.lang.Object>, AbstractEnchantmentDesc<Enchantment>
EnchantmentDesc
is expected.
In other words, an EnchantmentDesc looks like:
{ "eventTrigger": { An object corresponding to anEventTriggerDesc
} "spell": { An object corresponding to aSpellDesc
} "oneTurn": A boolean indicating that this Enchantment lasts one turn. "maxFires": The maximum number of times this enchantment will fire until it expires. "countUntilCast": The minimum number of times this enchantment must fire until its spell is cast "persistentOwner": SeepersistentOwner
"keepAfterTransform": SeekeepAfterTransform
"countByValue": SeecountByValue
}
This object is used to create an Enchantment
using its create()
function whenever entities like
actors come into play with a CardDesc.trigger
specified.
For example, the following JSON would belong on the CardDesc.trigger
field to describe a minion that draws a card whenever it is damaged, up to 3 times:
{ "eventTrigger": { "class": "DamagedReceivedTrigger", "hostTargetType": "IGNORE_OTHER_TARGETS" }, "spell": { "class": "DrawCardSpell", "targetPlayer": "SELF" }, "maxFires": 3 }Note, this is distinct from an
EventTriggerDesc
or EventTrigger
,
which defines how to react to which events in game.-
Nested Class Summary
Nested classes/interfaces inherited from interface net.demilich.metastone.game.cards.desc.HasEntrySet
HasEntrySet.BfsEnum, HasEntrySet.BfsNode<T extends java.lang.Enum,V>
-
Field Summary
Fields Modifier and Type Field Description protected EventTriggerDesc[]
activationTriggers
protected boolean
countByValue
protected java.lang.Integer
countUntilCast
protected java.lang.String
description
protected EventTriggerDesc
eventTrigger
protected EventTriggerDesc[]
expirationTriggers
protected boolean
keepAfterTransform
protected java.lang.Integer
maxFires
protected java.lang.Integer
maxFiresPerSequence
protected java.lang.String
name
protected boolean
oneTurn
protected boolean
persistentOwner
protected SpellDesc
spell
protected Zones[]
zones
-
Constructor Summary
Constructors Constructor Description EnchantmentDesc()
-
Method Summary
Modifier and Type Method Description Enchantment
create()
Creates an enchantment represented by this configuration.java.util.Set<java.util.Map.Entry<EnchantmentDescArg,java.lang.Object>>
entrySet()
EventTriggerDesc[]
getActivationTriggers()
Triggers that activate this enchantment when they fired.java.lang.Integer
getCountUntilCast()
The number of times anEnchantment
fires until it actually casts its spell.java.lang.String
getDescription()
A description field to use when rendering the enchantment on the client.EventTriggerDesc
getEventTrigger()
The description of which "event trigger" (reacting to which event) this trigger will react toEventTriggerDesc[]
getExpirationTriggers()
When set, these triggers will expire this enchantment when fired.java.lang.Integer
getMaxFires()
The maximum number of times this trigger can fire until it expires.java.lang.Integer
getMaxFiresPerSequence()
The maximum number of times this trigger can fire per sequence.java.lang.String
getName()
A name field to use when rendering the enchantment on the clientSpellDesc
getSpell()
The spell that will be cast by anEnchantment.process(int, SpellDesc, GameEvent)
invocation.Zones[]
getZones()
Zones where this enchantment is activated.boolean
isCountByValue()
Whentrue
, treats theGameContext.getEventValue()
as the amount to increment this enchantment's firing counter.boolean
isKeepAfterTransform()
Whentrue
, thisEnchantment
should not be removed by aGameLogic.transformMinion(SpellDesc, Entity, Minion, Minion, boolean)
orGameLogic.replaceCard(int, Card, Card)
effect.boolean
isOneTurn()
Whentrue
, indicates the enchantment should only last one turn.boolean
isPersistentOwner()
Whentrue
, indicates the owner of the enchantment for the purposes of evaluating theplayer
argument of aSpell.onCast(GameContext, Player, SpellDesc, Entity, Entity)
invocation shouldn't change if the owner of theEnchantment.hostReference
changes.EnchantmentDesc
setActivationTriggers(EventTriggerDesc[] activationTriggers)
EnchantmentDesc
setCountByValue(boolean countByValue)
EnchantmentDesc
setCountUntilCast(java.lang.Integer countUntilCast)
EnchantmentDesc
setDescription(java.lang.String description)
EnchantmentDesc
setEventTrigger(EventTriggerDesc eventTrigger)
EnchantmentDesc
setExpirationTriggers(EventTriggerDesc[] expirationTriggers)
EnchantmentDesc
setKeepAfterTransform(boolean keepAfterTransform)
EnchantmentDesc
setMaxFires(java.lang.Integer maxFires)
EnchantmentDesc
setMaxFiresPerSequence(java.lang.Integer maxFiresPerSequence)
EnchantmentDesc
setName(java.lang.String name)
EnchantmentDesc
setOneTurn(boolean oneTurn)
EnchantmentDesc
setPersistentOwner(boolean persistentOwner)
EnchantmentDesc
setSpell(SpellDesc spell)
EnchantmentDesc
setZones(Zones[] zones)
java.util.Optional<Enchantment>
tryCreate(GameContext context, Player player, Entity effectSource, Card enchantmentSource, Entity host, boolean force)
-
Field Details
-
eventTrigger
-
spell
-
oneTurn
protected boolean oneTurn -
persistentOwner
protected boolean persistentOwner -
keepAfterTransform
protected boolean keepAfterTransform -
maxFires
protected java.lang.Integer maxFires -
maxFiresPerSequence
protected java.lang.Integer maxFiresPerSequence -
countUntilCast
protected java.lang.Integer countUntilCast -
countByValue
protected boolean countByValue -
activationTriggers
-
expirationTriggers
-
name
protected java.lang.String name -
description
protected java.lang.String description -
zones
-
-
Constructor Details
-
EnchantmentDesc
public EnchantmentDesc()
-
-
Method Details
-
entrySet
- Specified by:
entrySet
in interfaceHasEntrySet<EnchantmentDescArg,java.lang.Object>
-
create
Creates an enchantment represented by this configuration.The enchantment's
Trigger.setHostReference(net.demilich.metastone.game.targeting.EntityReference)
call should be applied immediately afterwards to specify the host of this enchantment.Quest
andSecret
enchantments exist in play, and by convention they have unspecified hosts.- Returns:
- The enchantment
-
getEventTrigger
The description of which "event trigger" (reacting to which event) this trigger will react to -
setEventTrigger
-
getSpell
The spell that will be cast by anEnchantment.process(int, SpellDesc, GameEvent)
invocation.- See Also:
for more about enchantments.
-
setSpell
-
isOneTurn
public boolean isOneTurn()Whentrue
, indicates the enchantment should only last one turn. -
setOneTurn
-
isPersistentOwner
public boolean isPersistentOwner()Whentrue
, indicates the owner of the enchantment for the purposes of evaluating theplayer
argument of aSpell.onCast(GameContext, Player, SpellDesc, Entity, Entity)
invocation shouldn't change if the owner of theEnchantment.hostReference
changes.This implements Blessing of Wisdom, Power Word: Glory and other effects whose text would change depending on whose perspective the text is read from.
-
setPersistentOwner
-
isKeepAfterTransform
public boolean isKeepAfterTransform()Whentrue
, thisEnchantment
should not be removed by aGameLogic.transformMinion(SpellDesc, Entity, Minion, Minion, boolean)
orGameLogic.replaceCard(int, Card, Card)
effect.Implements Shifter Zerus, Molten Blade and other in-hand every-turn-replacement effects.
-
setKeepAfterTransform
-
getMaxFires
public java.lang.Integer getMaxFires()The maximum number of times this trigger can fire until it expires.When
null
(the default), the trigger can fire an unlimited number of times. -
setMaxFires
-
getMaxFiresPerSequence
public java.lang.Integer getMaxFiresPerSequence()The maximum number of times this trigger can fire per sequence. This counter is reset at the beginning of the sequence. Does not expire the trigger when exceeded.When
null
(the default), the trigger can fire an unlimited number of times per sequence. -
setMaxFiresPerSequence
-
getCountUntilCast
public java.lang.Integer getCountUntilCast()The number of times anEnchantment
fires until it actually casts its spell.Implements Quests and many other counting behaviours in triggers.
Typically
maxFires
is set to the same value ascountUntilCast
to limit the trigger to casting a spell at most once, as soon as theeventTrigger
has firedcountUntilCast
times. -
setCountUntilCast
-
isCountByValue
public boolean isCountByValue()Whentrue
, treats theGameContext.getEventValue()
as the amount to increment this enchantment's firing counter.Implements spellstones.
-
setCountByValue
-
getActivationTriggers
Triggers that activate this enchantment when they fired.If any triggers are specified, the enchantment will come into play with
Enchantment.isActivated()
set tofalse
.Activation occurs during the queueing phase, and thus you should use a
EventTriggerArg.QUEUE_CONDITION
if the trigger should have a condition to determine whether or not it activates. Activations are NOT evaluated during the firing phase. -
setActivationTriggers
-
getExpirationTriggers
When set, these triggers will expire this enchantment when fired.Expiration triggers are evaluated during the queueing phase. If an expiration trigger queues, the trigger is expired and will not fired. Thus you should use a
EventTriggerArg.QUEUE_CONDITION
if the trigger should have a condition to determine whether or not it expires. -
setExpirationTriggers
-
getName
public java.lang.String getName()A name field to use when rendering the enchantment on the client -
setName
-
getDescription
public java.lang.String getDescription()A description field to use when rendering the enchantment on the client. -
setDescription
-
getZones
Zones where this enchantment is activated. -
setZones
-
tryCreate
@Suspendable public java.util.Optional<Enchantment> tryCreate(GameContext context, Player player, Entity effectSource, Card enchantmentSource, Entity host, boolean force)- Specified by:
tryCreate
in interfaceAbstractEnchantmentDesc<Enchantment>
-