This commit is contained in:
jeffwadsworth 2020-06-29 15:07:47 -05:00
parent b01a1ac3aa
commit fa5cf8b412

View file

@ -1,11 +1,11 @@
package mage.cards.l; package mage.cards.l;
import java.util.HashMap;
import java.util.Map;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.DiesSourceTriggeredAbility; import mage.abilities.common.DiesSourceTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateTokenTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
@ -14,7 +14,6 @@ import mage.constants.SubType;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.token.SquirrelToken; import mage.game.permanent.token.SquirrelToken;
import mage.players.Player; import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
import mage.util.ManaUtil; import mage.util.ManaUtil;
import java.util.UUID; import java.util.UUID;
@ -32,7 +31,8 @@ public final class LiegeOfTheHollows extends CardImpl {
this.toughness = new MageInt(4); this.toughness = new MageInt(4);
// When Liege of the Hollows dies, each player may pay any amount of mana. // When Liege of the Hollows dies, each player may pay any amount of mana.
// Then each player creates a number of 1/1 green Squirrel creature tokens equal to the amount of mana they paid this way. // Then each player creates a number of 1/1 green Squirrel creature tokens
// equal to the amount of mana they paid this way.
this.addAbility(new DiesSourceTriggeredAbility(new LiegeOfTheHollowsEffect())); this.addAbility(new DiesSourceTriggeredAbility(new LiegeOfTheHollowsEffect()));
} }
@ -66,18 +66,25 @@ class LiegeOfTheHollowsEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
Map<UUID, Integer> paidMana = new HashMap<>();
if (controller != null) { if (controller != null) {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
if (player != null) { if (player != null) {
int numSquirrels = ManaUtil.playerPaysXGenericMana(false, "Liege of the Hollows", player, source, game); paidMana.put(player.getId(), ManaUtil.playerPaysXGenericMana(false,
if (numSquirrels > 0) { "Liege of the Hollows", player, source, game));
Effect effect = new CreateTokenTargetEffect(new SquirrelToken(), numSquirrels);
effect.setTargetPointer(new FixedTarget(playerId));
effect.apply(game, source);
} }
} }
// create tokens
SquirrelToken token = new SquirrelToken();
for (Map.Entry<UUID, Integer> entry
: paidMana.entrySet()) {
Player player = game.getPlayer(entry.getKey());
if (player != null) {
token.putOntoBattlefield(entry.getValue(), game, source.getSourceId(), player.getId());
} }
}
game.getState().processAction(game);
// prevent undo // prevent undo
controller.resetStoredBookmark(game); controller.resetStoredBookmark(game);