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.players.Player;
import mage.target.TargetPermanent;
import mage.target.targetpointer.FixedTarget;
/**
*
@ -97,7 +98,7 @@ class CloudstoneCurioEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Permanent triggeringCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
Permanent triggeringCreature = ((FixedTarget) getTargetPointer()).getTargetedPermanentOrLKIBattlefield(game);
if (triggeringCreature == null) {
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.target.TargetCard;
import mage.target.common.TargetCardInHand;
import mage.target.targetpointer.FixedTarget;
/**
*
@ -89,7 +90,7 @@ class CreamOfTheCropEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
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) {
int numLooked = Math.min(permanent.getPower().getValue(), player.getLibrary().size());
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}.
// 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?");
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));

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));
// 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?");
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));

View file

@ -70,6 +70,12 @@ public class PutTokenOntoBattlefieldCopyTargetEffect extends OneShotEffect {
private boolean gainsFlying;
private boolean becomesArtifact;
private ObjectColor color;
private boolean useLKI = false;
public PutTokenOntoBattlefieldCopyTargetEffect(boolean useLKI) {
this();
this.useLKI = useLKI;
}
public PutTokenOntoBattlefieldCopyTargetEffect() {
super(Outcome.PutCreatureInPlay);
@ -149,6 +155,7 @@ public class PutTokenOntoBattlefieldCopyTargetEffect extends OneShotEffect {
this.gainsFlying = effect.gainsFlying;
this.becomesArtifact = effect.becomesArtifact;
this.color = effect.color;
this.useLKI = effect.useLKI;
}
public void setBecomesArtifact(boolean becomesArtifact) {
@ -163,7 +170,12 @@ public class PutTokenOntoBattlefieldCopyTargetEffect extends OneShotEffect {
} else {
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;
ApplyToPermanent applier = new EmptyApplyToPermanent();
if (permanent != null) {
@ -283,4 +295,8 @@ public class PutTokenOntoBattlefieldCopyTargetEffect extends OneShotEffect {
public void setOnlyColor(ObjectColor color) {
this.color = color;
}
public void setUseLKI(boolean useLKI) {
this.useLKI = useLKI;
}
}