[ELD] Fix Once and Future. Remove unused Player.putInHand method

This commit is contained in:
Alex W. Jackson 2022-10-20 00:51:54 -04:00
parent f5f17cc73e
commit 7c1e823deb
5 changed files with 18 additions and 52 deletions

View file

@ -9,6 +9,8 @@ import mage.cards.*;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.predicate.other.AnotherTargetPredicate;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import mage.target.Target; import mage.target.Target;
@ -21,6 +23,12 @@ import java.util.UUID;
*/ */
public final class OnceAndFuture extends CardImpl { 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) { public OnceAndFuture(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{G}"); 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. // 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()); 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); target.setTargetTag(1);
this.getSpellAbility().addTarget(target); 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); target.setTargetTag(2);
this.getSpellAbility().addTarget(target); this.getSpellAbility().addTarget(target);
@ -75,26 +83,16 @@ class OnceAndFutureEffect extends OneShotEffect {
} }
Card card1 = game.getCard(source.getFirstTarget()); Card card1 = game.getCard(source.getFirstTarget());
Card card2 = game.getCard(source.getTargets().get(1).getFirstTarget()); Card card2 = game.getCard(source.getTargets().get(1).getFirstTarget());
if (card1 == null) { if (getCondition().apply(game, source)) {
card1 = card2; Cards cards = new CardsImpl(card1);
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);
cards.add(card2); cards.add(card2);
player.moveCards(cards, Zone.HAND, source, game); 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); game.getState().processAction(game);
player.putCardsOnTopOfLibrary(new CardsImpl(card2), game, source, false);
return new ExileSpellEffect().apply(game, source); return new ExileSpellEffect().apply(game, source);
} }

View file

@ -2948,11 +2948,6 @@ public class TestPlayer implements Player {
computerPlayer.discardToMax(game); computerPlayer.discardToMax(game);
} }
@Override
public boolean putInHand(Card card, Game game) {
return computerPlayer.putInHand(card, game);
}
@Override @Override
public boolean removeFromHand(Card card, Game game) { public boolean removeFromHand(Card card, Game game) {
return computerPlayer.removeFromHand(card, game); return computerPlayer.removeFromHand(card, game);

View file

@ -550,11 +550,6 @@ public class PlayerStub implements Player {
return false; return false;
} }
@Override
public boolean putInHand(Card card, Game game) {
return false;
}
@Override @Override
public boolean removeFromHand(Card card, Game game) { public boolean removeFromHand(Card card, Game game) {
return false; return false;

View file

@ -425,8 +425,6 @@ public interface Player extends MageItem, Copyable<Player> {
*/ */
SpellAbility chooseAbilityForCast(Card card, Game game, boolean noMana); SpellAbility chooseAbilityForCast(Card card, Game game, boolean noMana);
boolean putInHand(Card card, Game game);
boolean removeFromHand(Card card, Game game); boolean removeFromHand(Card card, Game game);
boolean removeFromBattlefield(Permanent permanent, Ability source, Game game); boolean removeFromBattlefield(Permanent permanent, Ability source, Game game);

View file

@ -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 @Override
public boolean removeFromHand(Card card, Game game) { public boolean removeFromHand(Card card, Game game) {
return hand.remove(card.getId()); return hand.remove(card.getId());