Class ChangeHeroSpell

java.lang.Object
net.demilich.metastone.game.spells.Spell
net.demilich.metastone.game.spells.ChangeHeroSpell
All Implemented Interfaces:
Serializable, HasDesc<SpellDesc>

public class ChangeHeroSpell extends Spell
Changes the hero of SpellArg.TARGET_PLAYER to the specified hero card ID in SpellArg.CARD. If SpellArg.CARDS or SpellArg.CARD_FILTER or SpellArg.CARD_SOURCE are specified, a random hero card will be chosen from the lists of cards.

This spell activates the CardDesc.battlecry by default. To disable it, set SpellArg.EXCLUSIVE to true.

For example, to turn the casting player's hero into Ragnaros:

     {
         "class": "ChangeHeroSpell",
         "card": "hero_ragnaros",
         "targetPlayer": "SELF"
     }
 
Casts the SpellArg.SPELL sub-spell with the EntityReference.OUTPUT set to the new hero.
See Also:
  • Constructor Details

    • ChangeHeroSpell

      public ChangeHeroSpell()
  • Method Details

    • create

      public static SpellDesc create(String heroCardId)
      Changes the casting player's hero to the specified card ID.
      Parameters:
      heroCardId - A hero card (Spellsource.CardTypeMessage.CardType.HERO.
      Returns:
      The spell
    • create

      public static SpellDesc create(TargetPlayer player, String heroCardId)
      Changes the specified player's hero the specified card ID.
      Parameters:
      player - The player whose hero should be changed.
      heroCardId - A hero card (Spellsource.CardTypeMessage.CardType.HERO.
      Returns:
      The spell
    • create

      public static SpellDesc create(TargetPlayer player, String heroCardId, boolean resolveBattlecry)
      Changes the specified player's hero with the specified card ID, resolving the battlecry if specified.
      Parameters:
      player - the player
      heroCardId - the hero card
      resolveBattlecry - true if the hero card should have its battlecry resolved
      Returns:
      the spell
    • 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.

      Specified by:
      onCast in class Spell
      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: