From 2f4232476ea227c972ada2f787f5506d6110863c Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Mon, 11 Apr 2016 17:00:28 +0200 Subject: [PATCH] * Changing some Target inheritance to fix AI Target handling (e.g. Loaming Shaman). --- .../StreamOfConsciousness.java | 15 ++-- .../mage/sets/coldsnap/JestersScepter.java | 68 +------------------ .../mage/sets/dissension/LoamingShaman.java | 13 ++-- .../mage/sets/gatecrash/BaneAlleyBroker.java | 8 +-- .../mage/sets/innistrad/MemorysJourney.java | 17 +++-- .../mage/sets/judgment/KrosanReclamation.java | 8 +-- .../src/mage/sets/magic2010/MirrorOfFate.java | 5 +- .../mage/sets/timeshifted/GaeasBlessing.java | 19 +++--- .../src/mage/sets/torment/DwellOnThePast.java | 6 +- 9 files changed, 46 insertions(+), 113 deletions(-) diff --git a/Mage.Sets/src/mage/sets/betrayersofkamigawa/StreamOfConsciousness.java b/Mage.Sets/src/mage/sets/betrayersofkamigawa/StreamOfConsciousness.java index 3ddbb3b8b5..b74d647f0a 100644 --- a/Mage.Sets/src/mage/sets/betrayersofkamigawa/StreamOfConsciousness.java +++ b/Mage.Sets/src/mage/sets/betrayersofkamigawa/StreamOfConsciousness.java @@ -29,19 +29,19 @@ package mage.sets.betrayersofkamigawa; import java.util.List; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Outcome; -import mage.constants.Rarity; -import mage.constants.Zone; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.cards.Card; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.Zone; import mage.filter.FilterCard; import mage.game.Game; import mage.players.Player; -import mage.target.TargetCard; import mage.target.TargetPlayer; +import mage.target.common.TargetCardInGraveyard; /** * @@ -54,7 +54,6 @@ public class StreamOfConsciousness extends CardImpl { this.expansionSetCode = "BOK"; this.subtype.add("Arcane"); - // Target player shuffles up to four target cards from his or her graveyard into his or her library. this.getSpellAbility().addEffect(new StreamOfConsciousnessEffect()); this.getSpellAbility().addTarget(new TargetPlayer()); @@ -113,10 +112,10 @@ class StreamOfConsciousnessEffect extends OneShotEffect { } } -class StreamOfConsciousnessTarget extends TargetCard { +class StreamOfConsciousnessTarget extends TargetCardInGraveyard { public StreamOfConsciousnessTarget() { - super(0, 4, Zone.GRAVEYARD, new FilterCard("cards from target player's graveyard")); + super(0, 4, new FilterCard("cards from target player's graveyard")); } public StreamOfConsciousnessTarget(final StreamOfConsciousnessTarget target) { diff --git a/Mage.Sets/src/mage/sets/coldsnap/JestersScepter.java b/Mage.Sets/src/mage/sets/coldsnap/JestersScepter.java index aa447e4ccb..639fa1c44e 100644 --- a/Mage.Sets/src/mage/sets/coldsnap/JestersScepter.java +++ b/Mage.Sets/src/mage/sets/coldsnap/JestersScepter.java @@ -27,7 +27,6 @@ */ package mage.sets.coldsnap; -import java.util.HashSet; import java.util.Set; import java.util.UUID; import mage.MageObject; @@ -56,7 +55,6 @@ import mage.game.ExileZone; import mage.game.Game; import mage.game.stack.Spell; import mage.players.Player; -import mage.target.TargetCard; import mage.target.TargetPlayer; import mage.target.TargetSpell; import mage.target.common.TargetCardInExile; @@ -137,66 +135,6 @@ class JestersScepterEffect extends OneShotEffect { } } -class TargetCardInJestersScepterExile extends TargetCard { - - public TargetCardInJestersScepterExile(UUID CardId) { - super(1, 1, Zone.EXILED, new FilterCard("card exiled with Jester's Scepter")); - } - - public TargetCardInJestersScepterExile(final TargetCardInJestersScepterExile target) { - super(target); - } - - @Override - public Set possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) { - Set possibleTargets = new HashSet<>(); - Card sourceCard = game.getCard(sourceId); - if (sourceCard != null) { - UUID exileId = CardUtil.getCardExileZoneId(game, sourceId); - ExileZone exile = game.getExile().getExileZone(exileId); - if (exile != null && exile.size() > 0) { - possibleTargets.addAll(exile); - } - } - return possibleTargets; - } - - @Override - public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) { - Card sourceCard = game.getCard(sourceId); - if (sourceCard != null) { - UUID exileId = CardUtil.getCardExileZoneId(game, sourceId); - ExileZone exile = game.getExile().getExileZone(exileId); - if (exile != null && exile.size() > 0) { - return true; - } - } - return false; - } - - @Override - public boolean canTarget(UUID id, Ability source, Game game) { - Card card = game.getCard(id); - if (card != null && game.getState().getZone(card.getId()) == Zone.EXILED) { - ExileZone exile = null; - Card sourceCard = game.getCard(source.getSourceId()); - if (sourceCard != null) { - UUID exileId = CardUtil.getCardExileZoneId(game, source); - exile = game.getExile().getExileZone(exileId); - } - if (exile != null && exile.contains(id)) { - return filter.match(card, source.getControllerId(), game); - } - } - return false; - } - - @Override - public TargetCardInJestersScepterExile copy() { - return new TargetCardInJestersScepterExile(this); - } -} - class JestersScepterLookAtCardEffect extends AsThoughEffectImpl { public JestersScepterLookAtCardEffect() { @@ -261,8 +199,8 @@ class JestersScepterCost extends CostImpl { if (controller.moveCardToGraveyardWithInfo(card, sourceId, game, Zone.EXILED)) { // Split Card check if (card instanceof SplitCard) { - game.getState().setValue(sourceId + "_nameOfExiledCardPayment", ((SplitCard)card).getLeftHalfCard().getName()); - game.getState().setValue(sourceId + "_nameOfExiledCardPayment2", ((SplitCard)card).getRightHalfCard().getName()); + game.getState().setValue(sourceId + "_nameOfExiledCardPayment", ((SplitCard) card).getLeftHalfCard().getName()); + game.getState().setValue(sourceId + "_nameOfExiledCardPayment2", ((SplitCard) card).getRightHalfCard().getName()); paid = true; return paid; } @@ -307,7 +245,7 @@ class JestersScepterCounterEffect extends OneShotEffect { String nameOfExiledCardPayment2 = (String) game.getState().getValue(source.getSourceId() + "_nameOfExiledCardPayment2"); if (nameOfExiledCardPayment != null) { if (nameOfExiledCardPayment.matches(spell.getName()) - || nameOfExiledCardPayment2.matches(spell.getName())) { + || nameOfExiledCardPayment2.matches(spell.getName())) { return game.getStack().counter(targetPointer.getFirst(game, source), source.getSourceId(), game); } } diff --git a/Mage.Sets/src/mage/sets/dissension/LoamingShaman.java b/Mage.Sets/src/mage/sets/dissension/LoamingShaman.java index cd000b50aa..2fa55378f2 100644 --- a/Mage.Sets/src/mage/sets/dissension/LoamingShaman.java +++ b/Mage.Sets/src/mage/sets/dissension/LoamingShaman.java @@ -41,8 +41,8 @@ import mage.constants.Zone; import mage.filter.FilterCard; import mage.game.Game; import mage.players.Player; -import mage.target.TargetCard; import mage.target.TargetPlayer; +import mage.target.common.TargetCardInGraveyard; /** * @@ -109,10 +109,10 @@ class LoamingShamanEffect extends OneShotEffect { } } -class LoamingShamanTargetCardsInGraveyard extends TargetCard { +class LoamingShamanTargetCardsInGraveyard extends TargetCardInGraveyard { public LoamingShamanTargetCardsInGraveyard(int minNumTargets, int maxNumTargets, FilterCard filter) { - super(minNumTargets, maxNumTargets, Zone.GRAVEYARD, filter); + super(minNumTargets, maxNumTargets, filter); this.targetName = filter.getMessage(); } @@ -131,15 +131,12 @@ class LoamingShamanTargetCardsInGraveyard extends TargetCard { || !card.getOwnerId().equals(targetCard.getOwnerId())) { return false; } - } else { - if (targetCard == null || !targetCard.getOwnerId().equals(targetPlayerId)) { - return false; - } + } else if (targetCard == null || !targetCard.getOwnerId().equals(targetPlayerId)) { + return false; } return super.canTarget(id, source, game); } - @Override public LoamingShamanTargetCardsInGraveyard copy() { return new LoamingShamanTargetCardsInGraveyard(this); diff --git a/Mage.Sets/src/mage/sets/gatecrash/BaneAlleyBroker.java b/Mage.Sets/src/mage/sets/gatecrash/BaneAlleyBroker.java index 864368f97c..be4f5a8d5d 100644 --- a/Mage.Sets/src/mage/sets/gatecrash/BaneAlleyBroker.java +++ b/Mage.Sets/src/mage/sets/gatecrash/BaneAlleyBroker.java @@ -53,7 +53,7 @@ import mage.game.ExileZone; import mage.game.Game; import mage.players.Player; import mage.target.Target; -import mage.target.TargetCard; +import mage.target.common.TargetCardInExile; import mage.target.common.TargetCardInHand; import mage.util.CardUtil; @@ -160,10 +160,10 @@ class BaneAlleyBrokerDrawExileEffect extends OneShotEffect { } } -class TargetCardInBaneAlleyBrokerExile extends TargetCard { +class TargetCardInBaneAlleyBrokerExile extends TargetCardInExile { - public TargetCardInBaneAlleyBrokerExile(UUID CardId) { - super(1, 1, Zone.EXILED, new FilterCard("card exiled with Bane Alley Broker")); + public TargetCardInBaneAlleyBrokerExile(UUID cardId) { + super(1, 1, new FilterCard("card exiled with Bane Alley Broker"), null); } public TargetCardInBaneAlleyBrokerExile(final TargetCardInBaneAlleyBrokerExile target) { diff --git a/Mage.Sets/src/mage/sets/innistrad/MemorysJourney.java b/Mage.Sets/src/mage/sets/innistrad/MemorysJourney.java index 2bc4ea3ef5..0623b6d913 100644 --- a/Mage.Sets/src/mage/sets/innistrad/MemorysJourney.java +++ b/Mage.Sets/src/mage/sets/innistrad/MemorysJourney.java @@ -29,22 +29,22 @@ package mage.sets.innistrad; import java.util.List; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Outcome; -import mage.constants.Rarity; -import mage.constants.TimingRule; -import mage.constants.Zone; import mage.abilities.Ability; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.OneShotEffect; import mage.abilities.keyword.FlashbackAbility; import mage.cards.Card; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.TimingRule; +import mage.constants.Zone; import mage.filter.FilterCard; import mage.game.Game; import mage.players.Player; -import mage.target.TargetCard; import mage.target.TargetPlayer; +import mage.target.common.TargetCardInGraveyard; /** * @@ -56,7 +56,6 @@ public class MemorysJourney extends CardImpl { super(ownerId, 66, "Memory's Journey", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{1}{U}"); this.expansionSetCode = "ISD"; - // Target player shuffles up to three target cards from his or her graveyard into his or her library. this.getSpellAbility().addEffect(new MemorysJourneyEffect()); this.getSpellAbility().addTarget(new TargetPlayer()); @@ -116,10 +115,10 @@ class MemorysJourneyEffect extends OneShotEffect { } } -class MemorysJourneyTarget extends TargetCard { +class MemorysJourneyTarget extends TargetCardInGraveyard { public MemorysJourneyTarget() { - super(0, 3, Zone.GRAVEYARD, new FilterCard()); + super(0, 3, new FilterCard()); } public MemorysJourneyTarget(final MemorysJourneyTarget target) { diff --git a/Mage.Sets/src/mage/sets/judgment/KrosanReclamation.java b/Mage.Sets/src/mage/sets/judgment/KrosanReclamation.java index 28f4ee0b65..9ebf84658f 100644 --- a/Mage.Sets/src/mage/sets/judgment/KrosanReclamation.java +++ b/Mage.Sets/src/mage/sets/judgment/KrosanReclamation.java @@ -43,8 +43,8 @@ import mage.constants.Zone; import mage.filter.FilterCard; import mage.game.Game; import mage.players.Player; -import mage.target.TargetCard; import mage.target.TargetPlayer; +import mage.target.common.TargetCardInGraveyard; /** * @@ -60,7 +60,7 @@ public class KrosanReclamation extends CardImpl { this.getSpellAbility().addEffect(new KrosanReclamationEffect()); this.getSpellAbility().addTarget(new TargetPlayer()); this.getSpellAbility().addTarget(new KrosanReclamationTarget()); - + // Flashback {1}{G} this.addAbility(new FlashbackAbility(new ManaCostsImpl("{1}{G}"), TimingRule.INSTANT)); } @@ -116,10 +116,10 @@ class KrosanReclamationEffect extends OneShotEffect { } } -class KrosanReclamationTarget extends TargetCard { +class KrosanReclamationTarget extends TargetCardInGraveyard { public KrosanReclamationTarget() { - super(0, 2, Zone.GRAVEYARD, new FilterCard()); + super(0, 2, new FilterCard()); } public KrosanReclamationTarget(final KrosanReclamationTarget target) { diff --git a/Mage.Sets/src/mage/sets/magic2010/MirrorOfFate.java b/Mage.Sets/src/mage/sets/magic2010/MirrorOfFate.java index 66e1f8a889..c37851903a 100644 --- a/Mage.Sets/src/mage/sets/magic2010/MirrorOfFate.java +++ b/Mage.Sets/src/mage/sets/magic2010/MirrorOfFate.java @@ -46,6 +46,7 @@ import mage.game.ExileZone; import mage.game.Game; import mage.players.Player; import mage.target.TargetCard; +import mage.target.common.TargetCardInExile; /** * @@ -145,10 +146,10 @@ class FaceUpPredicate implements Predicate { } } -class MirrorOfFateTarget extends TargetCard { +class MirrorOfFateTarget extends TargetCardInExile { public MirrorOfFateTarget() { - super(0, 7, Zone.EXILED, new FilterCard()); + super(0, 7, new FilterCard(), null); filter.add(new FaceUpPredicate()); this.targetName = "face-up exiled cards you own"; } diff --git a/Mage.Sets/src/mage/sets/timeshifted/GaeasBlessing.java b/Mage.Sets/src/mage/sets/timeshifted/GaeasBlessing.java index dffbfa04c1..d7263c04eb 100644 --- a/Mage.Sets/src/mage/sets/timeshifted/GaeasBlessing.java +++ b/Mage.Sets/src/mage/sets/timeshifted/GaeasBlessing.java @@ -42,8 +42,8 @@ import mage.constants.Zone; import mage.filter.FilterCard; import mage.game.Game; import mage.players.Player; -import mage.target.TargetCard; import mage.target.TargetPlayer; +import mage.target.common.TargetCardInGraveyard; /** * @@ -55,15 +55,14 @@ public class GaeasBlessing extends CardImpl { super(ownerId, 77, "Gaea's Blessing", Rarity.SPECIAL, new CardType[]{CardType.SORCERY}, "{1}{G}"); this.expansionSetCode = "TSB"; - // Target player shuffles up to three target cards from his or her graveyard into his or her library. this.getSpellAbility().addEffect(new GaeasBlessingEffect()); this.getSpellAbility().addTarget(new TargetPlayer()); this.getSpellAbility().addTarget(new GaeasBlessingTarget()); - + // Draw a card. this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(1)); - + // When Gaea's Blessing is put into your graveyard from your library, shuffle your graveyard into your library. this.addAbility(new GaeasBlessingTriggeredAbility()); } @@ -119,10 +118,10 @@ class GaeasBlessingEffect extends OneShotEffect { } } -class GaeasBlessingTarget extends TargetCard { +class GaeasBlessingTarget extends TargetCardInGraveyard { public GaeasBlessingTarget() { - super(0, 3, Zone.GRAVEYARD, new FilterCard()); + super(0, 3, new FilterCard()); } public GaeasBlessingTarget(final GaeasBlessingTarget target) { @@ -148,8 +147,9 @@ class GaeasBlessingTarget extends TargetCard { } class GaeasBlessingTriggeredAbility extends ZoneChangeTriggeredAbility { + public GaeasBlessingTriggeredAbility() { - super(Zone.LIBRARY, Zone.GRAVEYARD, new GaeasBlessingGraveToLibraryEffect(), "", false); + super(Zone.LIBRARY, Zone.GRAVEYARD, new GaeasBlessingGraveToLibraryEffect(), "", false); } public GaeasBlessingTriggeredAbility(final GaeasBlessingTriggeredAbility ability) { @@ -161,7 +161,6 @@ class GaeasBlessingTriggeredAbility extends ZoneChangeTriggeredAbility { return new GaeasBlessingTriggeredAbility(this); } - @Override public String getRule() { return "When {this} is put into your graveyard from your library, shuffle your graveyard into your library."; @@ -184,9 +183,9 @@ class GaeasBlessingGraveToLibraryEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { game.informPlayers(new StringBuilder(controller.getLogName()).append(" shuffle his or her graveyard into his or her library").toString()); - for (Card card: controller.getGraveyard().getCards(game)) { + for (Card card : controller.getGraveyard().getCards(game)) { controller.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.GRAVEYARD, true, true); - } + } controller.getLibrary().addAll(controller.getGraveyard().getCards(game), game); controller.getGraveyard().clear(); controller.shuffleLibrary(source, game); diff --git a/Mage.Sets/src/mage/sets/torment/DwellOnThePast.java b/Mage.Sets/src/mage/sets/torment/DwellOnThePast.java index 1b0a93f4ae..3dc290cbca 100644 --- a/Mage.Sets/src/mage/sets/torment/DwellOnThePast.java +++ b/Mage.Sets/src/mage/sets/torment/DwellOnThePast.java @@ -40,8 +40,8 @@ import mage.constants.Zone; import mage.filter.FilterCard; import mage.game.Game; import mage.players.Player; -import mage.target.TargetCard; import mage.target.TargetPlayer; +import mage.target.common.TargetCardInGraveyard; /** * @@ -111,10 +111,10 @@ class DwellOnThePastEffect extends OneShotEffect { } } -class DwellOnThePastTarget extends TargetCard { +class DwellOnThePastTarget extends TargetCardInGraveyard { public DwellOnThePastTarget() { - super(0, 4, Zone.GRAVEYARD, new FilterCard("cards from target player's graveyard")); + super(0, 4, new FilterCard("cards from target player's graveyard")); } public DwellOnThePastTarget(final DwellOnThePastTarget target) {