Class SummonSpell

java.lang.Object
net.demilich.metastone.game.spells.Spell
net.demilich.metastone.game.spells.SummonSpell
All Implemented Interfaces:
Serializable, HasDesc<SpellDesc>
Direct Known Subclasses:
DestroyAndSummonInPlaceSpell, DoubleSummonSpell, ManaCrystalToMinionSpell, SummonMinionWithMostCopiesInDeckSpell

public class SummonSpell extends Spell
Summons minions specified by cards; summons random minions from card filters; or copies minions according to targets.

When a SpellArg.CARD or SpellArg.CARDS are specified, all the specified cards are summoned SpellArg.VALUE times. When SpellArg.RANDOM_TARGET is also set to true instead of its default, false, a random card from the SpellArg.CARDS is chosen. Choices are made with replacement. SpellArg.VALUE (default 1) choices will be made, summoning a total of SpellArg.VALUE minions.

If a SpellArg.CARD_FILTER or SpellArg.CARD_SOURCE is specified, SpellArg.VALUE minions will be summoned from the generated cards, without replacement. Any SpellArg.CARD or SpellArg.CARDS that are also specified when a filter/card source is specified will be append to the possible choices of cards to summon.

If SpellArg.CARD, SpellArg.CARDS, SpellArg.CARD_FILTER, and SpellArg.CARD_SOURCE are all omitted, the spell will try to summon a copy of target. If the target is a Card, it is used as the card to Card.minion() from; otherwise, if the target is a Minion, the target is copied with Actor.getCopy(), its enchantments are removed, it is summoned, and then the enchantments are copied.

This effect will summon SpellArg.VALUE copies of whatever is specified, defaulting to 1.

All of the successfully summoned minions will get the SpellArg.SPELL subspell cast on each of them, where EntityReference.OUTPUT will reference each summoned minion.

The minions will be summoned in the last spot on the Spellsource.ZonesMessage.Zones.BATTLEFIELD unless the SpellArg.BOARD_POSITION_RELATIVE argument is set. When set to BoardPositionRelative.RIGHT, and the source of the spell is a Minion, the summoned minion will appear to the right of the source.

If SpellArg.EXCLUSIVE is specified, the spell will not summon minions whose card IDs are already on the battlefield.

Many minions summon tokens to their side in their OpenerDesc.spell argument. For example:

     {
         "class": "SummonSpell",
         "card": "token_ooze",
         "boardPositionRelative": "RIGHT",
         "targetPlayer": "SELF"
     }
 
You can summon multiple Oozes by specifying a SpellArg.VALUE:
     {
         "class": "SummonSpell",
         "card": "token_ooze",
         "boardPositionRelative": "RIGHT",
         "targetPlayer": "SELF",
         "value": 2
     }
 
Other minions commonly summon a copy of themselves in their Battlecries:
     {
         "class": "SummonSpell",
         "target": "SELF"
     }
 
To summon a 1/1 copy of itself (notice that the SpellArg.TARGET is changed to EntityReference.OUTPUT):
     {
         "class": "SummonSpell",
         "target": "SELF",
         "spell": {
             "class": "MetaSpell",
             "target": "OUTPUT",
             "spells": [
                  {
                      "class": "SetAttackSpell",
                      "value": 1
                  },
                  {
                      "class": "SetHpSpell",
                      "value": 1
                  }
             ]
         }
     }
 
To summon a random cost-2 minion for the casting player's opponent:
      {
          "class": "SummonSpell",
          "cardFilter": {
              "class": "CardFilter",
              "cardType": "MINION",
              "manaCost": 2
          },
          "targetPlayer": "OPPONENT"
      }
 
To summon a minion in the opponent's deck:
     {
         "class": "SummonSpell",
         "cardFilter": {
             "class": "CardFilter",
             "cardType": "MINION"
         },
         "cardSource": {
             "class": "DeckSource",
             "targetPlayer": "OPPONENT"
         }
     }
 
To summon one of four minions that don't already exist on the battlefield:
     {
          "class": "SummonSpell",
          "cards": [
              "token_searing_totem",
              "token_healing_totem",
              "token_wrath_of_air_totem",
              "token_stoneclaw_totem"
          ],
          "exclusive": true,
          "randomTarget": true
     }
 

To summon minions from a list of cards without replacement:

     "spell": {
     "class": "SummonSpell",
     "value": 2,
     "cards": [
       "token_bellowing_spirit",
       "token_unearthed_spirit",
       "token_burning_spirit"
     ],
     "randomTarget": true,
     "cardSource": {
       "class": "SummonWithoutReplacementCardSource"
     }
 
See Also:
  • Constructor Details

    • SummonSpell

      public SummonSpell()
  • Method Details

    • create

      public static SpellDesc create(Card... cards)
      Creates this spell to summon the specified minion cards
      Parameters:
      cards - One or more minions to summon. Each will be summoned.
      Returns:
      The spell
    • create

      public static SpellDesc create(BoardPositionRelative relativeBoardPosition, Card... cards)
      Creates this spell to summon the specified minions relative to the source minion (used in a battlecry).
      Parameters:
      relativeBoardPosition - The board position.
      cards - One or more minions to summon. Each will be summoned.
      Returns:
      The spell
    • create

      public static SpellDesc create(String Card)
      Summons the specified minion card ID
      Parameters:
      Card - The String minion card ID
      Returns:
      The spell
    • create

      public static SpellDesc create(String[] minionCards)
      Summons the specified minion cards by their IDs.
      Parameters:
      minionCards - The card IDs to summon.
      Returns:
      The spell
    • create

      public static SpellDesc create(TargetPlayer targetPlayer, Card... cards)
      Summons the specified cards for the specified player.
      Parameters:
      targetPlayer - The player on whose battlefield these minions should be summoned
      cards - The minion cards
      Returns:
      The spell
    • create

      public static SpellDesc create(TargetPlayer targetPlayer, BoardPositionRelative relativeBoardPosition, Card... cards)
      Summons the specified minion cards relative to a given source for the specified player (used for a battlecry).
      Parameters:
      targetPlayer - The player whose battlefield should be the destination for these minions
      relativeBoardPosition - Relative to the source minion (when played as a battlecry), where should these minions be summoned?
      cards - The cards to summon from
      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: