* Changing some Target inheritance to fix AI Target handling (e.g. Loaming Shaman).

This commit is contained in:
LevelX2 2016-04-11 17:00:28 +02:00
parent 4403f919a1
commit 2f4232476e
9 changed files with 46 additions and 113 deletions

View file

@ -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) {

View file

@ -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<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
Set<UUID> 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);
}
}

View file

@ -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);

View file

@ -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) {

View file

@ -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) {

View file

@ -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) {

View file

@ -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<Card> {
}
}
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";
}

View file

@ -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);

View file

@ -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) {