diff --git a/Mage.Sets/src/mage/cards/d/DeathbellowWarCry.java b/Mage.Sets/src/mage/cards/d/DeathbellowWarCry.java index 2a70c911977..fddedf90f3b 100644 --- a/Mage.Sets/src/mage/cards/d/DeathbellowWarCry.java +++ b/Mage.Sets/src/mage/cards/d/DeathbellowWarCry.java @@ -1,5 +1,6 @@ package mage.cards.d; +import mage.abilities.Ability; import mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect; import mage.cards.Card; import mage.cards.CardImpl; @@ -60,10 +61,10 @@ class DeathbellowWarCryTarget extends TargetCardInLibrary { } @Override - public boolean canTarget(UUID id, Cards cards, Game game) { + public boolean canTarget(UUID playerId, UUID id, Ability source, Cards cards, Game game) { Card card = cards.get(id, game); return card != null - && filter.match(card, game) + && filter.match(card, playerId, game) && this .getTargets() .stream() diff --git a/Mage.Sets/src/mage/cards/g/GiftsUngiven.java b/Mage.Sets/src/mage/cards/g/GiftsUngiven.java index c99f4c54f10..ea23326f71a 100644 --- a/Mage.Sets/src/mage/cards/g/GiftsUngiven.java +++ b/Mage.Sets/src/mage/cards/g/GiftsUngiven.java @@ -1,7 +1,5 @@ - package mage.cards.g; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.cards.*; @@ -15,14 +13,15 @@ import mage.target.TargetCard; import mage.target.common.TargetCardInLibrary; import mage.target.common.TargetOpponent; +import java.util.UUID; + /** - * * @author LevelX2 */ public final class GiftsUngiven extends CardImpl { public GiftsUngiven(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{3}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{U}"); // Search your library for up to four cards with different names and reveal them. Target opponent chooses two of those cards. Put the chosen cards into your graveyard and the rest into your hand. Then shuffle your library. this.getSpellAbility().addEffect(new GiftsUngivenEffect()); @@ -115,7 +114,7 @@ class GiftsUngivenTarget extends TargetCardInLibrary { } @Override - public boolean canTarget(UUID id, Cards cards, Game game) { + public boolean canTarget(UUID playerId, UUID id, Ability source, Cards cards, Game game) { Card card = cards.get(id, game); if (card != null) { for (UUID targetId : this.getTargets()) { @@ -124,7 +123,7 @@ class GiftsUngivenTarget extends TargetCardInLibrary { return false; } } - return filter.match(card, game); + return filter.match(card, playerId, game); } return false; } diff --git a/Mage.Sets/src/mage/cards/m/MyriadLandscape.java b/Mage.Sets/src/mage/cards/m/MyriadLandscape.java index be5c3e2e26c..a88e3285de0 100644 --- a/Mage.Sets/src/mage/cards/m/MyriadLandscape.java +++ b/Mage.Sets/src/mage/cards/m/MyriadLandscape.java @@ -88,8 +88,8 @@ class TargetCardInLibrarySharingLandType extends TargetCardInLibrary { } @Override - public boolean canTarget(UUID id, Cards cards, Game game) { - if (super.canTarget(id, cards, game)) { + public boolean canTarget(UUID playerId, UUID id, Ability source, Cards cards, Game game) { + if (super.canTarget(playerId, id, source, cards, game)) { if (!getTargets().isEmpty()) { // check if new target shares a Land Type SubTypeList landTypes = new SubTypeList(); diff --git a/Mage.Sets/src/mage/cards/n/NissasEncouragement.java b/Mage.Sets/src/mage/cards/n/NissasEncouragement.java index a94f7703856..63466a9dda1 100644 --- a/Mage.Sets/src/mage/cards/n/NissasEncouragement.java +++ b/Mage.Sets/src/mage/cards/n/NissasEncouragement.java @@ -1,15 +1,8 @@ - package mage.cards.n; -import java.util.HashMap; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; -import mage.cards.CardImpl; -import mage.cards.CardSetInfo; -import mage.cards.Cards; -import mage.cards.CardsImpl; +import mage.cards.*; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Zone; @@ -21,8 +14,10 @@ import mage.players.Player; import mage.target.TargetCard; import mage.target.common.TargetCardInLibrary; +import java.util.HashMap; +import java.util.UUID; + /** - * * @author spjspj */ public final class NissasEncouragement extends CardImpl { @@ -89,8 +84,8 @@ class NissasEncouragementEffect extends OneShotEffect { foundCards.put("Brambleweft Behemoth", 0); foundCards.put("Nissa, Genesis Mage", 0); Cards cards = new CardsImpl(); - - if (!target.getTargets().isEmpty()) { + + if (!target.getTargets().isEmpty()) { for (UUID cardId : target.getTargets()) { Card card = player.getLibrary().remove(cardId, game); @@ -120,7 +115,7 @@ class NissasEncouragementEffect extends OneShotEffect { } } } - + if (!cards.isEmpty()) { player.revealCards(sourceCard.getIdName(), cards, game); player.moveCards(cards, Zone.HAND, source, game); @@ -149,7 +144,7 @@ class NissasEncouragementTarget extends TargetCardInLibrary { } @Override - public boolean canTarget(UUID id, Cards cards, Game game) { + public boolean canTarget(UUID playerId, UUID id, Ability source, Cards cards, Game game) { Card card = cards.get(id, game); if (card != null) { for (UUID targetId : this.getTargets()) { @@ -158,7 +153,7 @@ class NissasEncouragementTarget extends TargetCardInLibrary { return false; } } - return filter.match(card, game); + return filter.match(card, playerId, game); } return false; } diff --git a/Mage.Sets/src/mage/cards/o/OpenTheArmory.java b/Mage.Sets/src/mage/cards/o/OpenTheArmory.java index a0063c18b63..8e04b2959ce 100644 --- a/Mage.Sets/src/mage/cards/o/OpenTheArmory.java +++ b/Mage.Sets/src/mage/cards/o/OpenTheArmory.java @@ -1,31 +1,35 @@ - package mage.cards.o; -import java.util.UUID; import mage.abilities.effects.common.search.SearchLibraryPutInHandEffect; -import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.cards.Cards; import mage.constants.CardType; import mage.constants.SubType; import mage.filter.FilterCard; import mage.filter.predicate.Predicates; import mage.filter.predicate.mageobject.SubtypePredicate; -import mage.game.Game; import mage.target.common.TargetCardInLibrary; +import java.util.UUID; + /** - * * @author escplan9 (Derek Monturo - dmontur1 at gmail dot com) */ public final class OpenTheArmory extends CardImpl { + private static final FilterCard auraOrEquipmentTarget = new FilterCard("Aura or Equipment card"); + + static { + auraOrEquipmentTarget.add(Predicates.or( + new SubtypePredicate(SubType.EQUIPMENT), + new SubtypePredicate(SubType.AURA))); + } + public OpenTheArmory(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{1}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{W}"); // Search your library for an Aura or Equipment card, reveal it, and put it into your hand. Then shuffle your library. - this.getSpellAbility().addEffect(new SearchLibraryPutInHandEffect(new OpenTheArmoryTarget(), true, true)); + this.getSpellAbility().addEffect(new SearchLibraryPutInHandEffect(new TargetCardInLibrary(1, 1, auraOrEquipmentTarget), true, true)); } public OpenTheArmory(final OpenTheArmory card) { @@ -36,36 +40,4 @@ public final class OpenTheArmory extends CardImpl { public OpenTheArmory copy() { return new OpenTheArmory(this); } -} - -class OpenTheArmoryTarget extends TargetCardInLibrary { - - private static final FilterCard auraOrEquipmentTarget = new FilterCard("Aura or Equipment card"); - static { - auraOrEquipmentTarget.add(Predicates.or( - new SubtypePredicate(SubType.EQUIPMENT), - new SubtypePredicate(SubType.AURA))); - } - - public OpenTheArmoryTarget() { - super(1, 1, auraOrEquipmentTarget.copy()); - } - - public OpenTheArmoryTarget(final OpenTheArmoryTarget target) { - super(target); - } - - @Override - public OpenTheArmoryTarget copy() { - return new OpenTheArmoryTarget(this); - } - - @Override - public boolean canTarget(UUID id, Cards cards, Game game) { - Card card = cards.get(id, game); - if (card != null) { - return auraOrEquipmentTarget.match(card, game); - } - return false; - } -} +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/cards/r/RealmsUncharted.java b/Mage.Sets/src/mage/cards/r/RealmsUncharted.java index 399fb4494fd..09752eba1a6 100644 --- a/Mage.Sets/src/mage/cards/r/RealmsUncharted.java +++ b/Mage.Sets/src/mage/cards/r/RealmsUncharted.java @@ -1,16 +1,9 @@ - package mage.cards.r; -import java.util.Set; -import java.util.UUID; import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; -import mage.cards.CardImpl; -import mage.cards.CardSetInfo; -import mage.cards.Cards; -import mage.cards.CardsImpl; +import mage.cards.*; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Zone; @@ -23,14 +16,16 @@ import mage.target.TargetCard; import mage.target.common.TargetCardInLibrary; import mage.target.common.TargetOpponent; +import java.util.Set; +import java.util.UUID; + /** - * * @author North */ public final class RealmsUncharted extends CardImpl { public RealmsUncharted(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{2}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{G}"); // Search your library for four land cards with different names and reveal them. An opponent chooses two of those cards. Put the chosen cards into your graveyard and the rest into your hand. Then shuffle your library. this.getSpellAbility().addEffect(new RealmsUnchartedEffect()); @@ -128,7 +123,7 @@ class RealmsUnchartedTarget extends TargetCardInLibrary { } @Override - public boolean canTarget(UUID id, Cards cards, Game game) { + public boolean canTarget(UUID playerId, UUID id, Ability source, Cards cards, Game game) { Card card = cards.get(id, game); if (card != null) { for (UUID targetId : this.getTargets()) { @@ -137,7 +132,7 @@ class RealmsUnchartedTarget extends TargetCardInLibrary { return false; } } - return filter.match(card, game); + return filter.match(card, playerId, game); } return false; } diff --git a/Mage.Sets/src/mage/cards/s/SaheeliRai.java b/Mage.Sets/src/mage/cards/s/SaheeliRai.java index 29dba317881..cc3a069b3bb 100644 --- a/Mage.Sets/src/mage/cards/s/SaheeliRai.java +++ b/Mage.Sets/src/mage/cards/s/SaheeliRai.java @@ -1,7 +1,5 @@ - package mage.cards.s; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.DelayedTriggeredAbility; import mage.abilities.LoyaltyAbility; @@ -9,20 +7,16 @@ import mage.abilities.common.PlaneswalkerEntersWithLoyaltyCountersAbility; import mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility; import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.CreateTokenCopyTargetEffect; import mage.abilities.effects.common.DamagePlayersEffect; import mage.abilities.effects.common.ExileTargetEffect; -import mage.abilities.effects.common.CreateTokenCopyTargetEffect; import mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect; import mage.abilities.effects.keyword.ScryEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.cards.Cards; -import mage.constants.CardType; -import mage.constants.SubType; -import mage.constants.Outcome; -import mage.constants.SuperType; -import mage.constants.TargetController; +import mage.constants.*; import mage.filter.StaticFilters; import mage.filter.common.FilterArtifactCard; import mage.game.Game; @@ -31,14 +25,15 @@ import mage.target.common.TargetCardInLibrary; import mage.target.common.TargetControlledPermanent; import mage.target.targetpointer.FixedTarget; +import java.util.UUID; + /** - * * @author emerald000 */ public final class SaheeliRai extends CardImpl { public SaheeliRai(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.PLANESWALKER},"{1}{U}{R}"); + super(ownerId, setInfo, new CardType[]{CardType.PLANESWALKER}, "{1}{U}{R}"); this.addSuperType(SuperType.LEGENDARY); this.subtype.add(SubType.SAHEELI); @@ -121,7 +116,7 @@ class SaheeliRaiTarget extends TargetCardInLibrary { } @Override - public boolean canTarget(UUID id, Cards cards, Game game) { + public boolean canTarget(UUID playerId, UUID id, Ability source, Cards cards, Game game) { Card card = cards.get(id, game); if (card != null) { for (UUID targetId : this.getTargets()) { @@ -130,7 +125,7 @@ class SaheeliRaiTarget extends TargetCardInLibrary { return false; } } - return filter.match(card, game); + return filter.match(card, playerId, game); } return false; } diff --git a/Mage.Sets/src/mage/cards/s/SharedSummons.java b/Mage.Sets/src/mage/cards/s/SharedSummons.java index 62c9d5edf93..f49b10117ca 100644 --- a/Mage.Sets/src/mage/cards/s/SharedSummons.java +++ b/Mage.Sets/src/mage/cards/s/SharedSummons.java @@ -1,5 +1,6 @@ package mage.cards.s; +import mage.abilities.Ability; import mage.abilities.effects.common.search.SearchLibraryPutInHandEffect; import mage.cards.Card; import mage.cards.CardImpl; @@ -55,15 +56,20 @@ class SharedSummonsTarget extends TargetCardInLibrary { } @Override - public boolean canTarget(UUID id, Cards cards, Game game) { + public boolean canTarget(UUID playerId, UUID id, Ability source, Cards cards, Game game) { Card card = cards.get(id, game); if (card == null || !card.isCreature()) { return false; } - return !this + + if (!filter.match(card, playerId, game)) { + return false; + } + + return this .getTargets() .stream() - .map(uuid -> game.getCard(uuid)) - .anyMatch(c -> c != null && c.getName().equals(card.getName())); + .map(game::getCard) + .noneMatch(c -> c != null && c.getName().equals(card.getName())); } } diff --git a/Mage.Sets/src/mage/cards/t/ThreeDreams.java b/Mage.Sets/src/mage/cards/t/ThreeDreams.java index 6ca476d0b48..b8543af3f89 100644 --- a/Mage.Sets/src/mage/cards/t/ThreeDreams.java +++ b/Mage.Sets/src/mage/cards/t/ThreeDreams.java @@ -1,7 +1,6 @@ - package mage.cards.t; -import java.util.UUID; +import mage.abilities.Ability; import mage.abilities.effects.common.search.SearchLibraryPutInHandEffect; import mage.cards.Card; import mage.cards.CardImpl; @@ -14,14 +13,15 @@ import mage.filter.predicate.mageobject.SubtypePredicate; import mage.game.Game; import mage.target.common.TargetCardInLibrary; +import java.util.UUID; + /** - * * @author LevelX2 */ public final class ThreeDreams extends CardImpl { public ThreeDreams(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{4}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{W}"); // Search your library for up to three Aura cards with different names, reveal them, and put them into your hand. Then shuffle your library. @@ -41,6 +41,7 @@ public final class ThreeDreams extends CardImpl { class ThreeDreamsTarget extends TargetCardInLibrary { private static final FilterCard aurafilter = new FilterCard("Aura cards with different names"); + static { aurafilter.add(new SubtypePredicate(SubType.AURA)); } @@ -59,7 +60,7 @@ class ThreeDreamsTarget extends TargetCardInLibrary { } @Override - public boolean canTarget(UUID id, Cards cards, Game game) { + public boolean canTarget(UUID playerId, UUID id, Ability source, Cards cards, Game game) { Card card = cards.get(id, game); if (card != null) { // check if card with that name was selected before @@ -69,7 +70,7 @@ class ThreeDreamsTarget extends TargetCardInLibrary { return false; } } - return filter.match(card, game); + return filter.match(card, playerId, game); } return false; } diff --git a/Mage.Sets/src/mage/cards/u/UncageTheMenagerie.java b/Mage.Sets/src/mage/cards/u/UncageTheMenagerie.java index 840fbbe22ef..e45a6432a57 100644 --- a/Mage.Sets/src/mage/cards/u/UncageTheMenagerie.java +++ b/Mage.Sets/src/mage/cards/u/UncageTheMenagerie.java @@ -1,14 +1,8 @@ - package mage.cards.u; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; -import mage.cards.Card; -import mage.cards.CardImpl; -import mage.cards.CardSetInfo; -import mage.cards.Cards; -import mage.cards.CardsImpl; +import mage.cards.*; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Zone; @@ -19,8 +13,9 @@ import mage.game.Game; import mage.players.Player; import mage.target.common.TargetCardInLibrary; +import java.util.UUID; + /** - * * @author spjspj */ public final class UncageTheMenagerie extends CardImpl { @@ -115,7 +110,7 @@ class UncageTheMenagerieTarget extends TargetCardInLibrary { } @Override - public boolean canTarget(UUID id, Cards cards, Game game) { + public boolean canTarget(UUID playerId, UUID id, Ability source, Cards cards, Game game) { Card card = cards.get(id, game); if (card != null) { for (UUID targetId : this.getTargets()) { @@ -124,11 +119,12 @@ class UncageTheMenagerieTarget extends TargetCardInLibrary { return false; } } + if (!(card.isCreature() && card.getConvertedManaCost() == xValue)) { return false; } - return filter.match(card, game); + return filter.match(card, playerId, game); } return false; } diff --git a/Mage/src/main/java/mage/target/TargetCard.java b/Mage/src/main/java/mage/target/TargetCard.java index a1d00b7f824..464b14ff221 100644 --- a/Mage/src/main/java/mage/target/TargetCard.java +++ b/Mage/src/main/java/mage/target/TargetCard.java @@ -208,8 +208,8 @@ public class TargetCard extends TargetObject { && getFilter() != null && getFilter().match(card, playerId, game); } - public boolean canTarget(UUID id, Cards cards, Game game) { - return cards.contains(id) && canTarget(id, game); + public boolean canTarget(UUID playerId, UUID id, Ability source, Cards cards, Game game) { + return cards.contains(id) && canTarget(playerId, id, source, game); } @Override