Class EnchantmentDesc

java.lang.Object
net.demilich.metastone.game.spells.desc.trigger.EnchantmentDesc
All Implemented Interfaces:
Serializable, Cloneable, HasEntrySet<EnchantmentDescArg,Object>, AbstractEnchantmentDesc<Enchantment>

public final class EnchantmentDesc extends Object implements Serializable, Cloneable, HasEntrySet<EnchantmentDescArg,Object>, AbstractEnchantmentDesc<Enchantment>
Data specifying a trigger, including what event it reacts to, what spell it casts, and various options. Each field in this class corresponds directly to a field that appears in the JSON whenever an EnchantmentDesc is expected. In other words, an EnchantmentDesc looks like:
   {
    "eventTrigger": { An object corresponding to an EventTriggerDesc }
    "spell": { An object corresponding to a SpellDesc }
    "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": See persistentOwner
    "keepAfterTransform": See keepAfterTransform
    "countByValue": See countByValue
   }
 

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.
See Also:
  • Field Details

    • eventTrigger

      protected EventTriggerDesc eventTrigger
    • spell

      protected SpellDesc spell
    • oneTurn

      protected boolean oneTurn
    • persistentOwner

      protected boolean persistentOwner
    • keepAfterTransform

      protected boolean keepAfterTransform
    • maxFires

      protected Integer maxFires
    • maxFiresPerSequence

      protected Integer maxFiresPerSequence
    • countUntilCast

      protected Integer countUntilCast
    • countByValue

      protected boolean countByValue
    • activationTriggers

      protected EventTriggerDesc[] activationTriggers
    • expirationTriggers

      protected EventTriggerDesc[] expirationTriggers
    • name

      protected String name
    • description

      protected String description
    • zones

      protected com.hiddenswitch.spellsource.rpc.Spellsource.ZonesMessage.Zones[] zones
  • Constructor Details

    • EnchantmentDesc

      public EnchantmentDesc()
  • Method Details

    • entrySet

      public Set<Map.Entry<EnchantmentDescArg,Object>> entrySet()
      Specified by:
      entrySet in interface HasEntrySet<EnchantmentDescArg,Object>
    • create

      public Enchantment 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 and Secret enchantments exist in play, and by convention they have unspecified hosts.

      Returns:
      The enchantment
    • getEventTrigger

      public EventTriggerDesc getEventTrigger()
      The description of which "event trigger" (reacting to which event) this trigger will react to
    • setEventTrigger

      public EnchantmentDesc setEventTrigger(EventTriggerDesc eventTrigger)
    • getSpell

      public SpellDesc getSpell()
      The spell that will be cast by an Enchantment.process(int, SpellDesc, GameEvent) invocation.
      See Also:
    • setSpell

      public EnchantmentDesc setSpell(SpellDesc spell)
    • isOneTurn

      public boolean isOneTurn()
      When true, indicates the enchantment should only last one turn.
    • setOneTurn

      public EnchantmentDesc setOneTurn(boolean oneTurn)
    • isPersistentOwner

      public boolean isPersistentOwner()
      When true, indicates the owner of the enchantment for the purposes of evaluating the player argument of a Spell.onCast(GameContext, Player, SpellDesc, Entity, Entity) invocation shouldn't change if the owner of the Enchantment.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

      public EnchantmentDesc setPersistentOwner(boolean persistentOwner)
    • isKeepAfterTransform

      public boolean isKeepAfterTransform()
      When true, this Enchantment should not be removed by a GameLogic.transformMinion(SpellDesc, Entity, Minion, Minion, boolean) or GameLogic.replaceCard(int, Card, Card) effect.

      Implements Shifter Zerus, Molten Blade and other in-hand every-turn-replacement effects.

    • setKeepAfterTransform

      public EnchantmentDesc setKeepAfterTransform(boolean keepAfterTransform)
    • getMaxFires

      public 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

      public EnchantmentDesc setMaxFires(Integer maxFires)
    • getMaxFiresPerSequence

      public 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

      public EnchantmentDesc setMaxFiresPerSequence(Integer maxFiresPerSequence)
    • getCountUntilCast

      public Integer getCountUntilCast()
      The number of times an Enchantment fires until it actually casts its spell.

      Implements Quests and many other counting behaviours in triggers.

      Typically maxFires is set to the same value as countUntilCast to limit the trigger to casting a spell at most once, as soon as the eventTrigger has fired countUntilCast times.

    • setCountUntilCast

      public EnchantmentDesc setCountUntilCast(Integer countUntilCast)
    • isCountByValue

      public boolean isCountByValue()
      When true, treats the GameContext.getEventValue() as the amount to increment this enchantment's firing counter.

      Implements spellstones.

    • setCountByValue

      public EnchantmentDesc setCountByValue(boolean countByValue)
    • getActivationTriggers

      public EventTriggerDesc[] getActivationTriggers()
      Triggers that activate this enchantment when they fired.

      If any triggers are specified, the enchantment will come into play with Enchantment.isActivated() set to false.

      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

      public EnchantmentDesc setActivationTriggers(EventTriggerDesc[] activationTriggers)
    • getExpirationTriggers

      public EventTriggerDesc[] 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

      public EnchantmentDesc setExpirationTriggers(EventTriggerDesc[] expirationTriggers)
    • getName

      public String getName()
      A name field to use when rendering the enchantment on the client
    • setName

      public EnchantmentDesc setName(String name)
    • getDescription

      public String getDescription()
      A description field to use when rendering the enchantment on the client.
    • setDescription

      public EnchantmentDesc setDescription(String description)
    • getZones

      public com.hiddenswitch.spellsource.rpc.Spellsource.ZonesMessage.Zones[] getZones()
      Zones where this enchantment is activated.
    • setZones

      public EnchantmentDesc setZones(com.hiddenswitch.spellsource.rpc.Spellsource.ZonesMessage.Zones[] zones)
    • tryCreate

      public Optional<Enchantment> tryCreate(GameContext context, Player player, Entity effectSource, Card enchantmentSource, Entity host, boolean force)
      Specified by:
      tryCreate in interface AbstractEnchantmentDesc<Enchantment>