-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathDoubleAttackSpell.java
38 lines (32 loc) · 1.51 KB
/
DoubleAttackSpell.java
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
29
30
31
32
33
34
35
36
37
38
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;
import net.demilich.metastone.game.targeting.EntityReference;
import net.demilich.metastone.game.cards.Attribute;
import java.util.Map;
/**
* Doubles the {@code target} {@link Actor}'s total attack.
* <p>
* If some amount of the actor's current attack is temporary (stored in {@link Attribute#TEMPORARY_ATTACK_BONUS}), the
* portion of the attack doubling that came from temporary attack is temporary too.
*/
public class DoubleAttackSpell extends Spell {
public static SpellDesc create() {
return create(null);
}
public static SpellDesc create(EntityReference target) {
Map<SpellArg, Object> arguments = new SpellDesc(DoubleAttackSpell.class);
arguments.put(SpellArg.TARGET, target);
return new SpellDesc(arguments);
}
@Override
protected void onCast(GameContext context, Player player, SpellDesc desc, Entity source, Entity target) {
Actor targetActor = (Actor) target;
targetActor.modifyAttribute(Attribute.ATTACK_BONUS, targetActor.getAttributeValue(Attribute.ATTACK) + targetActor.getAttributeValue(Attribute.ATTACK_BONUS));
targetActor.modifyAttribute(Attribute.TEMPORARY_ATTACK_BONUS, targetActor.getAttributeValue(Attribute.TEMPORARY_ATTACK_BONUS));
}
}