Fixed several cards with ETB abilities that didn't use last known information properly

This commit is contained in:
Evan Kranzler 2017-08-22 13:31:49 -04:00
parent 778ec735de
commit e3faef4a52
5 changed files with 25 additions and 7 deletions

View file

@ -45,6 +45,7 @@ import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import mage.target.targetpointer.FixedTarget;
/** /**
* *
@ -97,7 +98,7 @@ class CloudstoneCurioEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller != null) {
Permanent triggeringCreature = game.getPermanent(getTargetPointer().getFirst(game, source)); Permanent triggeringCreature = ((FixedTarget) getTargetPointer()).getTargetedPermanentOrLKIBattlefield(game);
if (triggeringCreature == null) { if (triggeringCreature == null) {
triggeringCreature = (Permanent) game.getLastKnownInformation(getTargetPointer().getFirst(game, source), Zone.BATTLEFIELD); triggeringCreature = (Permanent) game.getLastKnownInformation(getTargetPointer().getFirst(game, source), Zone.BATTLEFIELD);
} }

View file

@ -43,6 +43,7 @@ import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetCard; import mage.target.TargetCard;
import mage.target.common.TargetCardInHand; import mage.target.common.TargetCardInHand;
import mage.target.targetpointer.FixedTarget;
/** /**
* *
@ -89,7 +90,7 @@ class CreamOfTheCropEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game, source)); Permanent permanent = ((FixedTarget) getTargetPointer()).getTargetedPermanentOrLKIBattlefield(game);
if (player != null && permanent != null) { if (player != null && permanent != null) {
int numLooked = Math.min(permanent.getPower().getValue(), player.getLibrary().size()); int numLooked = Math.min(permanent.getPower().getValue(), player.getLibrary().size());
if (numLooked > 0) { if (numLooked > 0) {

View file

@ -61,7 +61,7 @@ public class Mirrorworks extends CardImpl {
// Whenever another nontoken artifact enters the battlefield under your control, you may pay {2}. // Whenever another nontoken artifact enters the battlefield under your control, you may pay {2}.
// If you do, create a token that's a copy of that artifact. // If you do, create a token that's a copy of that artifact.
Effect effect = new DoIfCostPaid(new PutTokenOntoBattlefieldCopyTargetEffect(), Effect effect = new DoIfCostPaid(new PutTokenOntoBattlefieldCopyTargetEffect(true),
new ManaCostsImpl("{2}"), "Create a token that's a copy of that artifact?"); new ManaCostsImpl("{2}"), "Create a token that's a copy of that artifact?");
effect.setText("you may pay {2}. If you do, create a token that's a copy of that artifact"); effect.setText("you may pay {2}. If you do, create a token that's a copy of that artifact");
this.addAbility(new EntersBattlefieldControlledTriggeredAbility(Zone.BATTLEFIELD, effect, filter, false, SetTargetPointer.PERMANENT, null)); this.addAbility(new EntersBattlefieldControlledTriggeredAbility(Zone.BATTLEFIELD, effect, filter, false, SetTargetPointer.PERMANENT, null));

View file

@ -82,7 +82,7 @@ public class RikuOfTwoReflections extends CardImpl {
this.addAbility(new SpellCastControllerTriggeredAbility(new DoIfCostPaid(effect, new ManaCostsImpl("{U}{R}")), filter, false, true)); this.addAbility(new SpellCastControllerTriggeredAbility(new DoIfCostPaid(effect, new ManaCostsImpl("{U}{R}")), filter, false, true));
// Whenever another nontoken creature enters the battlefield under your control, you may pay {G}{U}. If you do, create a token that's a copy of that creature. // Whenever another nontoken creature enters the battlefield under your control, you may pay {G}{U}. If you do, create a token that's a copy of that creature.
effect = new DoIfCostPaid(new PutTokenOntoBattlefieldCopyTargetEffect(), effect = new DoIfCostPaid(new PutTokenOntoBattlefieldCopyTargetEffect(true),
new ManaCostsImpl("{G}{U}"), "Create a token that's a copy of that creature?"); new ManaCostsImpl("{G}{U}"), "Create a token that's a copy of that creature?");
effect.setText("you may pay {G}{U}. If you do, create a token that's a copy of that creature"); effect.setText("you may pay {G}{U}. If you do, create a token that's a copy of that creature");
this.addAbility(new EntersBattlefieldControlledTriggeredAbility(Zone.BATTLEFIELD, effect, filterPermanent, false, SetTargetPointer.PERMANENT, null)); this.addAbility(new EntersBattlefieldControlledTriggeredAbility(Zone.BATTLEFIELD, effect, filterPermanent, false, SetTargetPointer.PERMANENT, null));

View file

@ -70,6 +70,12 @@ public class PutTokenOntoBattlefieldCopyTargetEffect extends OneShotEffect {
private boolean gainsFlying; private boolean gainsFlying;
private boolean becomesArtifact; private boolean becomesArtifact;
private ObjectColor color; private ObjectColor color;
private boolean useLKI = false;
public PutTokenOntoBattlefieldCopyTargetEffect(boolean useLKI) {
this();
this.useLKI = useLKI;
}
public PutTokenOntoBattlefieldCopyTargetEffect() { public PutTokenOntoBattlefieldCopyTargetEffect() {
super(Outcome.PutCreatureInPlay); super(Outcome.PutCreatureInPlay);
@ -149,6 +155,7 @@ public class PutTokenOntoBattlefieldCopyTargetEffect extends OneShotEffect {
this.gainsFlying = effect.gainsFlying; this.gainsFlying = effect.gainsFlying;
this.becomesArtifact = effect.becomesArtifact; this.becomesArtifact = effect.becomesArtifact;
this.color = effect.color; this.color = effect.color;
this.useLKI = effect.useLKI;
} }
public void setBecomesArtifact(boolean becomesArtifact) { public void setBecomesArtifact(boolean becomesArtifact) {
@ -163,7 +170,12 @@ public class PutTokenOntoBattlefieldCopyTargetEffect extends OneShotEffect {
} else { } else {
targetId = getTargetPointer().getFirst(game, source); targetId = getTargetPointer().getFirst(game, source);
} }
Permanent permanent = game.getPermanentOrLKIBattlefield(targetId); Permanent permanent;
if (useLKI) {
permanent = ((FixedTarget) getTargetPointer()).getTargetedPermanentOrLKIBattlefield(game);
} else {
permanent = game.getPermanentOrLKIBattlefield(targetId);
}
Card copyFrom; Card copyFrom;
ApplyToPermanent applier = new EmptyApplyToPermanent(); ApplyToPermanent applier = new EmptyApplyToPermanent();
if (permanent != null) { if (permanent != null) {
@ -220,7 +232,7 @@ public class PutTokenOntoBattlefieldCopyTargetEffect extends OneShotEffect {
if (onlySubType != null && !token.getSubtype(game).contains(onlySubType)) { if (onlySubType != null && !token.getSubtype(game).contains(onlySubType)) {
token.getSubtype(game).clear(); token.getSubtype(game).clear();
token.getSubtype(game).add(onlySubType); token.getSubtype(game).add(onlySubType);
} }
if (color != null) { if (color != null) {
token.getColor(game).setColor(color); token.getColor(game).setColor(color);
} }
@ -279,8 +291,12 @@ public class PutTokenOntoBattlefieldCopyTargetEffect extends OneShotEffect {
public void setOnlySubType(String onlySubType) { public void setOnlySubType(String onlySubType) {
this.onlySubType = onlySubType; this.onlySubType = onlySubType;
} }
public void setOnlyColor(ObjectColor color) { public void setOnlyColor(ObjectColor color) {
this.color = color; this.color = color;
} }
public void setUseLKI(boolean useLKI) {
this.useLKI = useLKI;
}
} }