forked from External/mage
Fix Pyrrhic Revival not adding -1/-1 counters on returned creatures. (#10626)
* Add (failing) unit test on Pyrrhic Revival * fix PyrrhicRevival reworked ReturnFromGraveyardToBattlefieldWithCounterTargetEffect to support having multiple cards in its targetPointer. added test for Persist (the card from mh2). * refactor & cleanup * add myself as author, the effect was remade.
This commit is contained in:
parent
96cb6b8673
commit
0c7965a725
5 changed files with 147 additions and 35 deletions
|
|
@ -23,6 +23,9 @@ public class ReturnFromGraveyardToBattlefieldTargetEffect extends OneShotEffect
|
|||
|
||||
private final boolean tapped;
|
||||
private final boolean attacking;
|
||||
// If true, creatures are returned to their owner's control.
|
||||
// If false, creatures are returned under the effect's controller control.
|
||||
private final boolean underOwnerControl;
|
||||
|
||||
public ReturnFromGraveyardToBattlefieldTargetEffect() {
|
||||
this(false);
|
||||
|
|
@ -31,17 +34,22 @@ public class ReturnFromGraveyardToBattlefieldTargetEffect extends OneShotEffect
|
|||
public ReturnFromGraveyardToBattlefieldTargetEffect(boolean tapped) {
|
||||
this(tapped, false);
|
||||
}
|
||||
|
||||
public ReturnFromGraveyardToBattlefieldTargetEffect(boolean tapped, boolean attacking) {
|
||||
this(tapped, attacking, false);
|
||||
}
|
||||
|
||||
public ReturnFromGraveyardToBattlefieldTargetEffect(boolean tapped, boolean attacking, boolean underOwnerControl) {
|
||||
super(Outcome.PutCreatureInPlay);
|
||||
this.tapped = tapped;
|
||||
this.attacking = attacking;
|
||||
this.underOwnerControl = underOwnerControl;
|
||||
}
|
||||
|
||||
protected ReturnFromGraveyardToBattlefieldTargetEffect(final ReturnFromGraveyardToBattlefieldTargetEffect effect) {
|
||||
super(effect);
|
||||
this.tapped = effect.tapped;
|
||||
this.attacking = effect.attacking;
|
||||
this.underOwnerControl = effect.underOwnerControl;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -60,7 +68,7 @@ public class ReturnFromGraveyardToBattlefieldTargetEffect extends OneShotEffect
|
|||
cardsToMove.add(card);
|
||||
}
|
||||
}
|
||||
controller.moveCards(cardsToMove, Zone.BATTLEFIELD, source, game, tapped, false, false, null);
|
||||
controller.moveCards(cardsToMove, Zone.BATTLEFIELD, source, game, tapped, false, underOwnerControl, null);
|
||||
if (attacking) {
|
||||
for (Card card : cardsToMove) {
|
||||
game.getCombat().addAttackingCreature(card.getId(), game);
|
||||
|
|
@ -111,7 +119,12 @@ public class ReturnFromGraveyardToBattlefieldTargetEffect extends OneShotEffect
|
|||
sb.append(" attacking");
|
||||
}
|
||||
if (!yourGrave) {
|
||||
sb.append(" under your control");
|
||||
if (underOwnerControl) {
|
||||
sb.append("under their owner's control");
|
||||
}
|
||||
else {
|
||||
sb.append(" under your control");
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ import mage.game.Game;
|
|||
import mage.game.events.EntersTheBattlefieldEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author weirddan455
|
||||
|
|
@ -24,7 +27,11 @@ public class ReturnFromGraveyardToBattlefieldWithCounterTargetEffect extends Ret
|
|||
}
|
||||
|
||||
public ReturnFromGraveyardToBattlefieldWithCounterTargetEffect(Counter counter, boolean additional) {
|
||||
super();
|
||||
this(counter, additional, false);
|
||||
}
|
||||
|
||||
public ReturnFromGraveyardToBattlefieldWithCounterTargetEffect(Counter counter, boolean additional, boolean underOwnerControl) {
|
||||
super(false, false, underOwnerControl);
|
||||
this.counter = counter;
|
||||
this.additional = additional;
|
||||
}
|
||||
|
|
@ -42,8 +49,11 @@ public class ReturnFromGraveyardToBattlefieldWithCounterTargetEffect extends Ret
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
AddCounterTargetReplacementEffect counterEffect = new AddCounterTargetReplacementEffect(counter);
|
||||
game.addEffect(counterEffect, source);
|
||||
for (UUID targetId : getTargetPointer().getTargets(game, source)) {
|
||||
AddCounterTargetReplacementEffect counterEffect = new AddCounterTargetReplacementEffect(counter);
|
||||
counterEffect.setTargetPointer(new FixedTarget(targetId, game));
|
||||
game.addEffect(counterEffect, source);
|
||||
}
|
||||
return super.apply(game, source);
|
||||
}
|
||||
|
||||
|
|
@ -69,7 +79,11 @@ public class ReturnFromGraveyardToBattlefieldWithCounterTargetEffect extends Ret
|
|||
if (counter.getCount() != 1) {
|
||||
sb.append('s');
|
||||
}
|
||||
sb.append(" on it");
|
||||
if (targetPointer.isPlural(mode.getTargets())) {
|
||||
sb.append(" on them");
|
||||
} else {
|
||||
sb.append(" on it");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue