From 7c1e823debf0f8ab3624bb4b81cac9ae30c73940 Mon Sep 17 00:00:00 2001 From: "Alex W. Jackson" Date: Thu, 20 Oct 2022 00:51:54 -0400 Subject: [PATCH] [ELD] Fix Once and Future. Remove unused Player.putInHand method --- Mage.Sets/src/mage/cards/o/OnceAndFuture.java | 38 +++++++++---------- .../java/org/mage/test/player/TestPlayer.java | 5 --- .../java/org/mage/test/stub/PlayerStub.java | 5 --- Mage/src/main/java/mage/players/Player.java | 2 - .../main/java/mage/players/PlayerImpl.java | 20 ---------- 5 files changed, 18 insertions(+), 52 deletions(-) diff --git a/Mage.Sets/src/mage/cards/o/OnceAndFuture.java b/Mage.Sets/src/mage/cards/o/OnceAndFuture.java index 146003b013..12278a7235 100644 --- a/Mage.Sets/src/mage/cards/o/OnceAndFuture.java +++ b/Mage.Sets/src/mage/cards/o/OnceAndFuture.java @@ -9,6 +9,8 @@ import mage.cards.*; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Zone; +import mage.filter.FilterCard; +import mage.filter.predicate.other.AnotherTargetPredicate; import mage.game.Game; import mage.players.Player; import mage.target.Target; @@ -21,6 +23,12 @@ import java.util.UUID; */ public final class OnceAndFuture extends CardImpl { + private static final FilterCard filter = new FilterCard("other card from your graveyard"); + + static { + filter.add(new AnotherTargetPredicate(2)); + } + public OnceAndFuture(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{G}"); @@ -28,11 +36,11 @@ public final class OnceAndFuture extends CardImpl { // Adamant — If at least three green mana was spent to cast this spell, instead return those cards to your hand and exile Once and Future. this.getSpellAbility().addEffect(new OnceAndFutureEffect()); - Target target = new TargetCardInYourGraveyard().withChooseHint("To put in your hand"); + Target target = new TargetCardInYourGraveyard().withChooseHint("to put in your hand"); target.setTargetTag(1); this.getSpellAbility().addTarget(target); - target = new TargetCardInYourGraveyard(0, 1).withChooseHint("To put on top of your library"); + target = new TargetCardInYourGraveyard(0, 1, filter).withChooseHint("to put on top of your library"); target.setTargetTag(2); this.getSpellAbility().addTarget(target); @@ -75,26 +83,16 @@ class OnceAndFutureEffect extends OneShotEffect { } Card card1 = game.getCard(source.getFirstTarget()); Card card2 = game.getCard(source.getTargets().get(1).getFirstTarget()); - if (card1 == null) { - card1 = card2; - card2 = null; - } - if (card1 == null) { - return false; - } - if (card2 == null) { - player.putInHand(card1, game); - return new ExileSpellEffect().apply(game, source); - } - if (AdamantCondition.GREEN.apply(game, source)) { - Cards cards = new CardsImpl(); - cards.add(card1); + if (getCondition().apply(game, source)) { + Cards cards = new CardsImpl(card1); cards.add(card2); player.moveCards(cards, Zone.HAND, source, game); - return new ExileSpellEffect().apply(game, source); + } else { + player.moveCards(card1, Zone.HAND, source, game); + game.getState().processAction(game); + player.putCardsOnTopOfLibrary(card2, game, source, true); } - player.putInHand(card1, game); - player.putCardsOnTopOfLibrary(new CardsImpl(card2), game, source, false); + game.getState().processAction(game); return new ExileSpellEffect().apply(game, source); } @@ -102,4 +100,4 @@ class OnceAndFutureEffect extends OneShotEffect { public Condition getCondition() { return AdamantCondition.GREEN; } -} \ No newline at end of file +} diff --git a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java index df6f9a66a0..8cd9ac7073 100644 --- a/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java +++ b/Mage.Tests/src/test/java/org/mage/test/player/TestPlayer.java @@ -2948,11 +2948,6 @@ public class TestPlayer implements Player { computerPlayer.discardToMax(game); } - @Override - public boolean putInHand(Card card, Game game) { - return computerPlayer.putInHand(card, game); - } - @Override public boolean removeFromHand(Card card, Game game) { return computerPlayer.removeFromHand(card, game); diff --git a/Mage.Tests/src/test/java/org/mage/test/stub/PlayerStub.java b/Mage.Tests/src/test/java/org/mage/test/stub/PlayerStub.java index 05b735cf0b..5af173b539 100644 --- a/Mage.Tests/src/test/java/org/mage/test/stub/PlayerStub.java +++ b/Mage.Tests/src/test/java/org/mage/test/stub/PlayerStub.java @@ -550,11 +550,6 @@ public class PlayerStub implements Player { return false; } - @Override - public boolean putInHand(Card card, Game game) { - return false; - } - @Override public boolean removeFromHand(Card card, Game game) { return false; diff --git a/Mage/src/main/java/mage/players/Player.java b/Mage/src/main/java/mage/players/Player.java index e89d1fd037..cafd9f0ff7 100644 --- a/Mage/src/main/java/mage/players/Player.java +++ b/Mage/src/main/java/mage/players/Player.java @@ -425,8 +425,6 @@ public interface Player extends MageItem, Copyable { */ SpellAbility chooseAbilityForCast(Card card, Game game, boolean noMana); - boolean putInHand(Card card, Game game); - boolean removeFromHand(Card card, Game game); boolean removeFromBattlefield(Permanent permanent, Ability source, Game game); diff --git a/Mage/src/main/java/mage/players/PlayerImpl.java b/Mage/src/main/java/mage/players/PlayerImpl.java index b51709b10e..d0065d1530 100644 --- a/Mage/src/main/java/mage/players/PlayerImpl.java +++ b/Mage/src/main/java/mage/players/PlayerImpl.java @@ -696,26 +696,6 @@ public abstract class PlayerImpl implements Player, Serializable { } } - /** - * Don't use this in normal card code, it's for more internal use. Always - * use the [Player].moveCards methods if possible for card movement of card - * code. - * - * @param card - * @param game - * @return - */ - @Override - public boolean putInHand(Card card, Game game) { - if (card.isOwnedBy(playerId)) { - card.setZone(Zone.HAND, game); - this.hand.add(card); - } else { - return game.getPlayer(card.getOwnerId()).putInHand(card, game); - } - return true; - } - @Override public boolean removeFromHand(Card card, Game game) { return hand.remove(card.getId());