Class SetHpSpell
- All Implemented Interfaces:
Serializable,HasDesc<SpellDesc>
Actor or Card's hitpoints to the specified SpellArg.VALUE, overriding any existing
bonuses stored in Attribute.HP_BONUS.
When an actor is targeted, the actor's hitpoints and maximum hitpoints are both increased or decreased down to the new value.
When a card is targeted, the client will correctly render the change in hitpoints, and the summoned minion will have a silenceable enchantment that sets its hitpoints to the value specified.
If SpellArg.EXCLUSIVE is true (the default), the effect can be silenced. If it is false, the
effect changes the Attribute.BASE_HP of the actor or card, and therefore cannot be silenced. Use a
false exclusive argument in order to create minions on the fly.
For example, to set a minion's hitpoints to its attack:
{
"class": "SetHpSpell",
"value": {
"class": "AttributeValueProvider",
"attribute": "ATTACK"
}
}
Suppose we wanted to implement the text, "At the start of your turn, summon a Penguin. The next Penguin has +1/+1
compared to the last." The idea is that Penguins, like Jade Golems, do not have a silenceable buff but a permanent
number of hitpoints. Here will will use the SpellArg.EXCLUSIVE argument and set it to false:
"trigger": {
"eventTrigger": {
"class": "TurnStartTrigger",
"targetPlayer": "SELF"
},
"spell": {
"class": "MetaSpell",
"spells": [
{
"class": "SummonSpell",
"card": "minion_snowflipper_penguin",
"spell": {
"class": "MetaSpell",
"spells": [
{
"class": "SetHpSpell",
"target": "OUTPUT",
"exclusive": false,
"value": {
"class": "AttributeValueProvider",
"attribute": "RESERVED_INTEGER_1",
"target": "TRIGGER_HOST"
}
},
{
"class": "SetAttackSpell",
"target": "OUTPUT",
"exclusive": false,
"value": {
"class": "AttributeValueProvider",
"attribute": "RESERVED_INTEGER_1",
"target": "TRIGGER_HOST"
}
}
]
}
},
{
"class": "ModifyAttributeSpell",
"target": "TRIGGER_HOST",
"attribute": "RESERVED_INTEGER_1",
"value": 1
}
]
}
}
The complex example above also uses Attribute.RESERVED_INTEGER_1 as a counter; the special target EntityReference.OUTPUT to cast a spell on the minion that was summoned by a
SummonSpell; and the special target EntityReference.TRIGGER_HOST
to modify the host of the trigger instead of the GameEvent.getTarget() entity, the default target of
spells cast by triggers.-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class net.demilich.metastone.game.spells.Spell
cast, castForPlayer, checkArguments, getDesc, isNativeStateful, setDesc, toString
-
Constructor Details
-
SetHpSpell
public SetHpSpell()
-
-
Method Details
-
create
-
create
-
onCast
protected void onCast(GameContext context, Player player, SpellDesc desc, Entity source, Entity target) Description copied from class:SpellImplementations ofonCastare 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), interpretSpellArgkeys in thedesc, etc.Observe that subclasses of
Spellmostly just need to implement this function. Also, observe that instances ofSpellare stateless: all the state is provided as arguments to this function.- Specified by:
onCastin classSpell- Parameters:
context- The game contextplayer- The casting playerdesc- The collection ofSpellArgkeys 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:
-