fixed implementation of Liliana of the Dark Realms (fixes #7096)

This commit is contained in:
Evan Kranzler 2020-09-30 17:40:20 -04:00
parent 042376d146
commit 436908fc75

View file

@ -1,27 +1,27 @@
package mage.cards.l; package mage.cards.l;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.LoyaltyAbility; import mage.abilities.LoyaltyAbility;
import mage.abilities.common.PlaneswalkerEntersWithLoyaltyCountersAbility; import mage.abilities.common.PlaneswalkerEntersWithLoyaltyCountersAbility;
import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.GetEmblemEffect; import mage.abilities.effects.common.GetEmblemEffect;
import mage.abilities.effects.common.continuous.BoostTargetEffect;
import mage.abilities.effects.common.search.SearchLibraryPutInHandEffect; import mage.abilities.effects.common.search.SearchLibraryPutInHandEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.*; import mage.constants.*;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.common.FilterLandCard; import mage.filter.common.FilterLandCard;
import mage.filter.common.FilterLandPermanent;
import mage.game.Game; import mage.game.Game;
import mage.game.command.emblems.LilianaOfTheDarkRealmsEmblem; import mage.game.command.emblems.LilianaOfTheDarkRealmsEmblem;
import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetCardInLibrary; import mage.target.common.TargetCardInLibrary;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/** /**
*
* @author North * @author North
*/ */
public final class LilianaOfTheDarkRealms extends CardImpl { public final class LilianaOfTheDarkRealms extends CardImpl {
@ -41,10 +41,12 @@ public final class LilianaOfTheDarkRealms extends CardImpl {
// +1: Search your library for a Swamp card, reveal it, and put it into your hand. Then shuffle your library. // +1: Search your library for a Swamp card, reveal it, and put it into your hand. Then shuffle your library.
this.addAbility(new LoyaltyAbility(new SearchLibraryPutInHandEffect(new TargetCardInLibrary(filter), true), 1)); this.addAbility(new LoyaltyAbility(new SearchLibraryPutInHandEffect(new TargetCardInLibrary(filter), true), 1));
// -3: Target creature gets +X/+X or -X/-X until end of turn, where X is the number of Swamps you control. // -3: Target creature gets +X/+X or -X/-X until end of turn, where X is the number of Swamps you control.
LoyaltyAbility ability = new LoyaltyAbility(new LilianaOfTheDarkRealmsEffect(), -3); Ability ability = new LoyaltyAbility(new LilianaOfTheDarkRealmsEffect(), -3);
ability.addTarget(new TargetCreaturePermanent()); ability.addTarget(new TargetCreaturePermanent());
this.addAbility(ability); this.addAbility(ability);
// -6: You get an emblem with "Swamps you control have '{tap}: Add {B}{B}{B}{B}.'" // -6: You get an emblem with "Swamps you control have '{tap}: Add {B}{B}{B}{B}.'"
this.addAbility(new LoyaltyAbility(new GetEmblemEffect(new LilianaOfTheDarkRealmsEmblem()), -6)); this.addAbility(new LoyaltyAbility(new GetEmblemEffect(new LilianaOfTheDarkRealmsEmblem()), -6));
} }
@ -59,19 +61,18 @@ public final class LilianaOfTheDarkRealms extends CardImpl {
} }
} }
class LilianaOfTheDarkRealmsEffect extends ContinuousEffectImpl { class LilianaOfTheDarkRealmsEffect extends OneShotEffect {
private int amount; private static final FilterPermanent filter = new FilterControlledPermanent(SubType.SWAMP);
public LilianaOfTheDarkRealmsEffect() { LilianaOfTheDarkRealmsEffect() {
super(Duration.EndOfTurn, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, Outcome.BoostCreature); super(Outcome.Neutral);
this.amount = 0; staticText = "Target creature gets +X/+X or -X/-X until end of turn, " +
this.staticText = "Target creature gets +X/+X or -X/-X until end of turn, where X is the number of Swamps you control"; "where X is the number of Swamps you control.";
} }
public LilianaOfTheDarkRealmsEffect(final LilianaOfTheDarkRealmsEffect effect) { private LilianaOfTheDarkRealmsEffect(final LilianaOfTheDarkRealmsEffect effect) {
super(effect); super(effect);
this.amount = effect.amount;
} }
@Override @Override
@ -79,31 +80,25 @@ class LilianaOfTheDarkRealmsEffect extends ContinuousEffectImpl {
return new LilianaOfTheDarkRealmsEffect(this); return new LilianaOfTheDarkRealmsEffect(this);
} }
@Override
public void init(Ability source, Game game) {
super.init(source, game);
FilterLandPermanent filter = new FilterLandPermanent("Swamps");
filter.add(SubType.SWAMP.getPredicate());
filter.add(TargetController.YOU.getControllerPredicate());
this.amount = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
Player player = game.getPlayer(source.getControllerId());
String message = "Should the target creature get -X/-X instead of +X/+X?";
if (player != null && player.chooseUse(Outcome.Neutral, message, source, game)) {
this.amount *= -1;
}
}
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Permanent target = game.getPermanent(source.getFirstTarget()); Player player = game.getPlayer(source.getControllerId());
if (target != null) { if (player == null) {
target.addPower(amount);
target.addToughness(amount);
return true;
}
return false; return false;
} }
int swamps = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
if (swamps < 1) {
return false;
}
String plusMessage = "+" + swamps + "/+" + swamps;
String minusMessage = "-" + swamps + "/-" + swamps;
if (!player.chooseUse(
outcome, "Give " + plusMessage + " or " + minusMessage + "?",
null, plusMessage, minusMessage, source, game
)) {
swamps *= -1;
}
game.addEffect(new BoostTargetEffect(swamps, swamps, Duration.EndOfTurn), source);
return true;
}
} }