-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathConditionalAttackBonusSpell.java
More file actions
54 lines (48 loc) · 1.86 KB
/
ConditionalAttackBonusSpell.java
File metadata and controls
54 lines (48 loc) · 1.86 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package net.demilich.metastone.game.spells;
import net.demilich.metastone.game.GameContext;
import net.demilich.metastone.game.Player;
import net.demilich.metastone.game.entities.Entity;
import net.demilich.metastone.game.spells.aura.BuffAura;
import net.demilich.metastone.game.spells.desc.SpellArg;
import net.demilich.metastone.game.spells.desc.SpellDesc;
import net.demilich.metastone.game.spells.desc.valueprovider.ValueProvider;
import net.demilich.metastone.game.targeting.EntityReference;
import net.demilich.metastone.game.cards.Attribute;
import java.util.Map;
/**
* @deprecated Use a {@link BuffAura} instead. For example, to give a minion +1 attack only if the friendly player has
* more than 3 cards:
* <pre>
* "aura": {
* "class": "BuffAura",
* "attackBonus": 1,
* "hpBonus": 0,
* "target": "SELF",
* "condition": {
* "class": "CardCountCondition",
* "targetPlayer": "SELF",
* "operation": "GREATER",
* "value": 3
* }
* }
* </pre>
* <p>
* Gives a minion an attack bonus with a given condition.
*/
@Deprecated
public class ConditionalAttackBonusSpell extends Spell {
public static SpellDesc create(EntityReference target, ValueProvider valueProvider) {
Map<SpellArg, Object> arguments = new SpellDesc(ConditionalAttackBonusSpell.class);
arguments.put(SpellArg.VALUE, valueProvider);
arguments.put(SpellArg.TARGET, target);
return new SpellDesc(arguments);
}
public static SpellDesc create(ValueProvider valueProvider) {
return create(null, valueProvider);
}
@Override
protected void onCast(GameContext context, Player player, SpellDesc desc, Entity source, Entity target) {
int attackBonus = desc.getValue(SpellArg.VALUE, context, player, target, source, 0);
target.setAttribute(Attribute.CONDITIONAL_ATTACK_BONUS, attackBonus);
}
}