-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathChooseAndReshuffleSpell.java
More file actions
30 lines (27 loc) · 1.31 KB
/
ChooseAndReshuffleSpell.java
File metadata and controls
30 lines (27 loc) · 1.31 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
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.desc.SpellArg;
import net.demilich.metastone.game.spells.desc.SpellDesc;
import net.demilich.metastone.game.spells.desc.source.HandSource;
import net.demilich.metastone.game.spells.desc.valueprovider.PlayerAttributeValueProvider;
/**
* Prompts the player to choose among cards in their hand. Then, the choice is shuffled into their deck.
* <p>
* Implements Timeweaver's Reshuffle keyword.
*/
public final class ChooseAndReshuffleSpell extends Spell {
@Override
protected void onCast(GameContext context, Player player, SpellDesc desc, Entity source, Entity target) {
int times = desc.getValue(SpellArg.VALUE, context, player, target, source, 1);
SpellDesc discover = new SpellDesc(DiscoverSpell.class);
discover.put(SpellArg.EXCLUSIVE, true);
discover.put(SpellArg.CARD_SOURCE, HandSource.create());
discover.put(SpellArg.HOW_MANY, PlayerAttributeValueProvider.create(PlayerAttribute.HAND_COUNT));
discover.put(SpellArg.SPELL, new SpellDesc(ShuffleOriginalToDeckSpell.class));
for (int i = 0; i < times; i++) {
SpellUtils.castChildSpell(context, player, discover, source, target);
}
}
}