Class AddDeathrattleSpell
- All Implemented Interfaces:
Serializable
,HasDesc<SpellDesc>
- Direct Known Subclasses:
AddDeathrattleSecondaryAsTargetSpell
,AnobiiSpell
,CopyDeathrattleSpell
,ElorthaNoShandraSpell
,RafaamThiefSpell
SpellArg.SPELL
to the SpellArg.TARGET
or target
.
If the target is a Card
, the deathrattle will be added to the resulting actor when the minion is brought into
play. To add an effect that occurs when a card is removed from the hand, use an AddEnchantmentSpell
with a
DiscardTrigger
.
Deathrattles are equivalent to an AddEnchantmentSpell
with a MinionDeathTrigger
, TargetType.IGNORE_OTHER_TARGETS
.
Minions removed peacefully with GameLogic.removePeacefully(Entity)
do not trigger deathrattles.
All weapon removals trigger deathrattles, whether by replacement, destruction or by depleting their durability.
Deathrattles resolve from the Spellsource.ZonesMessage.Zones.GRAVEYARD
. However, the SpellArg.BOARD_POSITION_ABSOLUTE
argument
is set to where the minion used to be.
If a SpellArg.VALUE
is specified on this spell, it will be computed at the time the effect is applied and
copied onto the sub-spell.
For example, to give a minion a the deathrattle, "Resummon this minion,":
{ "class": "AddDeathrattleSpell", "spell": { "class": "ReviveMinionSpell", "target": "SELF" } }
Many jail effects, like "Battlecry: Choose a minion. Deathrattle: Summon a copy of it" require "storing" a reference
to an entity. Use AddDeathrattleSecondaryAsTargetSpell
for this effect. Or, to implement it in code, create a
new class that extends Spell
and implement its onCast
method to create a new deathrattle spell. For
example, to implement the text "Battlecry: Choose a minion. Deathrattle: Summon a copy of it:"
SpellDesc summonDesc = new SpellDesc(SummonSpell.class);
// The target is the minion chosen by the battlecry. It gets baked in here.
summonDesc.put(SpellArg.TARGET, target.getReference());
SpellDesc addDeathrattleSpell = AddDeathrattleSpell.create(EntityReference.SELF, summonDesc);
SpellUtils.castChildSpell(context, player, addDeathrattleSpell, source, target);
Observe that the target
reference gets baked in and a deathrattle is added to the casting minion by this
battlecry, as opposed to setting the "deathrattle"
field on the minion's card JSON.-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic SpellDesc
static SpellDesc
create
(EntityReference target, SpellDesc deathrattle) Creates this spell to add the specifieddeathrattle
to the target.protected void
Implementations ofonCast
are the meat-and-bones of a spell's effects.Methods inherited from class net.demilich.metastone.game.spells.Spell
cast, castForPlayer, checkArguments, getDesc, isNativeStateful, setDesc, toString
-
Constructor Details
-
AddDeathrattleSpell
public AddDeathrattleSpell()
-
-
Method Details
-
create
Creates this spell to add the specifieddeathrattle
to the target.- Parameters:
target
- The target entity referencedeathrattle
- The spell to cast when thatActor
dies.- Returns:
- A spell instance.
-
create
-
onCast
protected void onCast(GameContext context, Player player, SpellDesc desc, Entity source, Entity target) Description copied from class:Spell
Implementations ofonCast
are the meat-and-bones of a spell's effects. This should actually call a variety of methods inGameLogic
, generate cards usingSpellUtils.getCards(GameContext, Player, Entity, Entity, SpellDesc)
, interpretSpellArg
keys in thedesc
, etc.Observe that subclasses of
Spell
mostly just need to implement this function. Also, observe that instances ofSpell
are stateless: all the state is provided as arguments to this function.- Specified by:
onCast
in classSpell
- Parameters:
context
- The game contextplayer
- The casting playerdesc
- The collection ofSpellArg
keys and values that are interpreted by the implementation of this function to actually cause effects in a gamesource
- 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:
-