-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathExcessHealSpell.java
More file actions
28 lines (25 loc) · 1.16 KB
/
ExcessHealSpell.java
File metadata and controls
28 lines (25 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package net.demilich.metastone.game.spells;
import net.demilich.metastone.game.GameContext;
import net.demilich.metastone.game.Player;
import net.demilich.metastone.game.entities.Actor;
import net.demilich.metastone.game.entities.Entity;
import net.demilich.metastone.game.spells.desc.SpellArg;
import net.demilich.metastone.game.spells.desc.SpellDesc;
/**
* Performs a {@link HealSpell} effect. If a {@link SpellArg#SPELL} is specified, cast it. For the duration of that
* execution context, put the excess healing into the {@link net.demilich.metastone.game.spells.desc.valueprovider.EventValueProvider}
* value.
*/
public final class ExcessHealSpell extends HealSpell {
@Override
protected void onCast(GameContext context, Player player, SpellDesc desc, Entity source, Entity target) {
var healing = getHealing(context, player, desc, source, target);
var res = context.getLogic().heal(player, (Actor) target, Math.max(0, healing), source);
if (res.getExcess() > 0) {
var spell = desc.getSpell();
context.getEventValueStack().push(res.getExcess());
SpellUtils.castChildSpell(context, player, spell, source, target);
context.getEventValueStack().pop();
}
}
}