Class WhereverTheyAreSpell

All Implemented Interfaces:
Serializable, HasDesc<SpellDesc>

public final class WhereverTheyAreSpell extends MetaSpell
Casts a spell on a target and its copies "wherever they are" in the player (casting player's) zones.

The underlying implementation uses enchantments to apply the effects for all the non-removed game zones (Spellsource.ZonesMessage.Zones.BATTLEFIELD, Spellsource.ZonesMessage.Zones.DECK, Spellsource.ZonesMessage.Zones.HAND, Spellsource.ZonesMessage.Zones.HERO, Spellsource.ZonesMessage.Zones.HERO_POWER and Spellsource.ZonesMessage.Zones.WEAPON). IF SpellArg.ZONES is specified, use those instead.

If the Spellsource.ZonesMessage.Zones.GRAVEYARD is included, which ordinarily wipes enchantments and buffs, an enchantment is put into play that will cast the specified spell on minions entering the owner's battlefield. This will include minions summoned by all other effects, like discovers or battlecries or from the hand.

If the SpellArg.TARGET is EntityReference.OUTPUT in any of the sub-spells, the output is resolved now rather than at the time the spell is cast.

A card is considered a copy "wherever they are" if they are the same card ID.

To implement a buff, like "Give a minion and all its copies +1/+1 (wherever they are):"

   {
     "class": "WhereverTheyAreSpell",
     "spell": {
       "class": "BuffSpell",
       "value": 1
     },
     "zones": ["BATTLEFIELD", "GRAVEYARD"]
   }
 
Observe that the zones are specified to just be Spellsource.ZonesMessage.Zones.BATTLEFIELD and Spellsource.ZonesMessage.Zones.GRAVEYARD. This indicates that the spell should be cast on all the existing copies of the target on the caster's battlefield; then, an enchantment will ensure that minions summoned from the hand, deck, graveyard, discovers, etc. will also get this bonus cast on them.

The client communications code special-cases the enchantment provided here to look for buffs to render in the client's hand.

See Also:
  • Constructor Details

    • WhereverTheyAreSpell

      public WhereverTheyAreSpell()
  • Method Details

    • onCast

      protected void onCast(GameContext context, Player player, SpellDesc desc, Entity source, Entity target)
      Description copied from class: Spell
      Implementations of onCast are the meat-and-bones of a spell's effects. This should actually call a variety of methods in GameLogic, generate cards using SpellUtils.getCards(GameContext, Player, Entity, Entity, SpellDesc), interpret SpellArg keys in the desc, etc.

      Observe that subclasses of Spell mostly just need to implement this function. Also, observe that instances of Spell are stateless: all the state is provided as arguments to this function.

      Overrides:
      onCast in class MetaSpell
      Parameters:
      context - The game context
      player - The casting player
      desc - The collection of SpellArg keys and values that are interpreted by the implementation of this function to actually cause effects in a game
      source - The entity from which this effect is happening (typically a card or a minion if it's a battlecry).
      target - The particular target of this invocation of the spell. When a spell hits multiple targets, like an AoE damage effect, this method is called once for each target in the list of targets.
      See Also: