From 4dbf8f2ca5cb26b943c88e93b006b56738b7cde7 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Fri, 29 Jan 2016 23:09:46 +0100 Subject: [PATCH] * Oath of Lieges - Fixed that wrongly the controller was always able to choose to use the search effect instead of only the active player. --- .../src/mage/sets/exodus/OathOfLieges.java | 61 +++++++++++++------ 1 file changed, 44 insertions(+), 17 deletions(-) diff --git a/Mage.Sets/src/mage/sets/exodus/OathOfLieges.java b/Mage.Sets/src/mage/sets/exodus/OathOfLieges.java index 6a2c3279357..bc512f06d1b 100644 --- a/Mage.Sets/src/mage/sets/exodus/OathOfLieges.java +++ b/Mage.Sets/src/mage/sets/exodus/OathOfLieges.java @@ -31,6 +31,7 @@ import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.effects.Effect; +import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.search.SearchLibraryPutInPlayTargetPlayerEffect; import mage.cards.CardImpl; import mage.constants.CardType; @@ -54,22 +55,21 @@ import mage.target.targetpointer.FixedTarget; */ public class OathOfLieges extends CardImpl { - private final UUID originalId; - private static final FilterPlayer filter = new FilterPlayer("player who controls more lands than you do and is his your opponent"); + private static final FilterPlayer FILTER = new FilterPlayer("player who controls more lands than you do and is your opponent"); static { - filter.add(new OathOfLiegesPredicate()); + FILTER.add(new OathOfLiegesPredicate()); } + private final UUID originalId; + public OathOfLieges(UUID ownerId) { super(ownerId, 11, "Oath of Lieges", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}"); this.expansionSetCode = "EXO"; // At the beginning of each player's upkeep, that player chooses target player who controls more lands than he or she does and is his or her opponent. The first player may search his or her library for a basic land card, put that card onto the battlefield, then shuffle his or her library. - Effect effect = new SearchLibraryPutInPlayTargetPlayerEffect(new TargetCardInLibrary(new FilterBasicLandCard()), false, true, Outcome.PutLandInPlay, true); - effect.setText("that player chooses target player who controls more lands than he or she does and is his or her opponent. The first player may search his or her library for a basic land card, put that card onto the battlefield, then shuffle his or her library"); - Ability ability = new BeginningOfUpkeepTriggeredAbility(effect, TargetController.ANY, true); - ability.addTarget(new TargetPlayer(1, 1, false, filter)); + Ability ability = new BeginningOfUpkeepTriggeredAbility(new OathOfLiegesEffect(), TargetController.ANY, false); + ability.addTarget(new TargetPlayer(1, 1, false, FILTER)); originalId = ability.getOriginalId(); this.addAbility(ability); } @@ -85,14 +85,9 @@ public class OathOfLieges extends CardImpl { Player activePlayer = game.getPlayer(game.getActivePlayerId()); if (activePlayer != null) { ability.getTargets().clear(); - TargetPlayer target = new TargetPlayer(1, 1, false, filter); + TargetPlayer target = new TargetPlayer(1, 1, false, FILTER); target.setTargetController(activePlayer.getId()); ability.getTargets().add(target); - for (Effect effect : ability.getEffects()) { - if (effect instanceof SearchLibraryPutInPlayTargetPlayerEffect) { - effect.setTargetPointer(new FixedTarget(activePlayer.getId())); - } - } } } } @@ -103,9 +98,41 @@ public class OathOfLieges extends CardImpl { } } +class OathOfLiegesEffect extends OneShotEffect { + + public OathOfLiegesEffect() { + super(Outcome.Benefit); + this.staticText = "that player chooses target player who controls more lands than he or she does and is his or her opponent. The first player may search his or her library for a basic land card, put that card onto the battlefield, then shuffle his or her library"; + } + + public OathOfLiegesEffect(final OathOfLiegesEffect effect) { + super(effect); + } + + @Override + public OathOfLiegesEffect copy() { + return new OathOfLiegesEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player activePlayer = game.getPlayer(game.getActivePlayerId()); + if (activePlayer != null) { + if (activePlayer.chooseUse(outcome, "Search your library for a basic land card, put that card onto the battlefield, then shuffle your library?", source, game)) { + Effect effect = new SearchLibraryPutInPlayTargetPlayerEffect(new TargetCardInLibrary(new FilterBasicLandCard()), false, true, Outcome.PutLandInPlay, true); + effect.setTargetPointer(new FixedTarget(game.getActivePlayerId())); + return effect.apply(game, source); + } + return true; + } + + return false; + } +} + class OathOfLiegesPredicate implements ObjectSourcePlayerPredicate> { - private static final FilterLandPermanent filter = new FilterLandPermanent(); + private static final FilterLandPermanent FILTER = new FilterLandPermanent(); @Override public boolean apply(ObjectSourcePlayer input, Game game) { @@ -115,11 +142,11 @@ class OathOfLiegesPredicate implements ObjectSourcePlayerPredicate countActivePlayer; }