mirror of
https://github.com/correl/mage.git
synced 2025-03-12 17:00:08 -09:00
* Fixed that enchant card in graveyard auras select target when entering the battlefield (allows the Animate Dead Worlgorger Dragon combo).
This commit is contained in:
parent
c285fc6c4d
commit
ffd0b0c685
5 changed files with 114 additions and 17 deletions
|
@ -56,7 +56,8 @@ public class Cultivate extends CardImpl {
|
|||
public Cultivate(UUID ownerId) {
|
||||
super(ownerId, 168, "Cultivate", Rarity.COMMON, new CardType[]{CardType.SORCERY}, "{2}{G}");
|
||||
this.expansionSetCode = "M11";
|
||||
this.color.setGreen(true);
|
||||
|
||||
// Search your library for up to two basic land cards, reveal those cards, and put one onto the battlefield tapped and the other into your hand. Then shuffle your library.
|
||||
this.getSpellAbility().addEffect(new CultivateEffect());
|
||||
|
||||
}
|
||||
|
@ -103,7 +104,7 @@ class CultivateEffect extends OneShotEffect {
|
|||
}
|
||||
player.revealCards("Cultivate", revealed, game);
|
||||
if (target.getTargets().size() == 2) {
|
||||
TargetCard target2 = new TargetCard(Zone.PICK, filter);
|
||||
TargetCard target2 = new TargetCard(Zone.LIBRARY, filter);
|
||||
player.choose(Outcome.Benefit, revealed, target2, game);
|
||||
Card card = revealed.get(target2.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
|
|
|
@ -51,4 +51,69 @@ public class WorlgorgerDragonTest extends CardTestPlayerBase {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
1. Cast Animate Dead, targeting the Dragon
|
||||
2. Dragon comes into play, it's ability goes on the stack.
|
||||
3. The ability resolves, and all my other permanents leave play
|
||||
4. Since Animate Dead left play, Dragon goes to the graveyard
|
||||
5. Since the Dragon left play, the land and Animate Dead return to play. Animate Dead triggers, targeting the Dragon.
|
||||
6. In response to Animate Dead's ability going on the stack, tap the lands for mana.
|
||||
7. Animate Dead resolves, Dragon comes into play, everything else leaves play.
|
||||
8. Steps 4-7 repeat endlessly. Your mana pool fills.
|
||||
9. You can interrupt the sequence to play an instant.
|
||||
*/
|
||||
@Test
|
||||
public void testWithAnimateDead() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2);
|
||||
|
||||
// When Worldgorger Dragon enters the battlefield, exile all other permanents you control.
|
||||
// When Worldgorger Dragon leaves the battlefield, return the exiled cards to the battlefield under their owners' control.
|
||||
addCard(Zone.GRAVEYARD, playerA, "Worldgorger Dragon", 1);
|
||||
addCard(Zone.HAND, playerA, "Animate Dead");
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3);
|
||||
// Instant {X}{R}{R}
|
||||
// Volcanic Geyser deals X damage to target creature or player.
|
||||
addCard(Zone.HAND, playerA, "Volcanic Geyser", 1);
|
||||
// When Staunch Defenders enters the battlefield, you gain 4 life.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Staunch Defenders", 1);
|
||||
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Animate Dead", "Worldgorger Dragon");
|
||||
|
||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
||||
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Volcanic Geyser", playerB, 22);
|
||||
setChoice(playerA, "X=20");
|
||||
|
||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertLife(playerA, 20);
|
||||
assertLife(playerB, 0);
|
||||
|
||||
assertGraveyardCount(playerA, "Volcanic Geyser", 1);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -127,7 +127,7 @@ public class TestPlayer extends ComputerPlayer {
|
|||
String command = action.getAction();
|
||||
command = command.substring(command.indexOf("activate:") + 9);
|
||||
String[] groups = command.split("\\$");
|
||||
if (!checkSpellOnStackCondition(groups, game) || !checkSpellOnTopOfStackCondition(groups, game)) {
|
||||
if (groups.length > 2 && !checkExecuteCondition(groups, game)) {
|
||||
break;
|
||||
}
|
||||
for (Ability ability: this.getPlayable(game, true)) {
|
||||
|
@ -522,8 +522,8 @@ public class TestPlayer extends ComputerPlayer {
|
|||
return null;
|
||||
}
|
||||
|
||||
private boolean checkSpellOnStackCondition(String[] groups, Game game) {
|
||||
if (groups.length > 2 && groups[2].startsWith("spellOnStack=")) {
|
||||
private boolean checkExecuteCondition(String[] groups, Game game) {
|
||||
if (groups[2].startsWith("spellOnStack=")) {
|
||||
String spellOnStack = groups[2].substring(13);
|
||||
for (StackObject stackObject: game.getStack()) {
|
||||
if (stackObject.getStackAbility().toString().contains(spellOnStack)) {
|
||||
|
@ -531,7 +531,7 @@ public class TestPlayer extends ComputerPlayer {
|
|||
}
|
||||
}
|
||||
return false;
|
||||
} else if (groups.length > 2 && groups[2].startsWith("!spellOnStack=")) {
|
||||
} else if (groups[2].startsWith("!spellOnStack=")) {
|
||||
String spellNotOnStack = groups[2].substring(14);
|
||||
for (StackObject stackObject: game.getStack()) {
|
||||
if (stackObject.getStackAbility().toString().contains(spellNotOnStack)) {
|
||||
|
@ -539,12 +539,7 @@ public class TestPlayer extends ComputerPlayer {
|
|||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean checkSpellOnTopOfStackCondition(String[] groups, Game game) {
|
||||
if (groups.length > 2 && groups[2].startsWith("spellOnTopOfStack=")) {
|
||||
} else if (groups[2].startsWith("spellOnTopOfStack=")) {
|
||||
String spellOnTopOFStack = groups[2].substring(18);
|
||||
if (game.getStack().size() > 0) {
|
||||
StackObject stackObject = game.getStack().getFirst();
|
||||
|
@ -553,15 +548,33 @@ public class TestPlayer extends ComputerPlayer {
|
|||
}
|
||||
}
|
||||
return false;
|
||||
} else if (groups[2].startsWith("manaInPool=")) {
|
||||
String manaInPool = groups[2].substring(11);
|
||||
int amountOfMana = Integer.parseUnsignedInt(manaInPool);
|
||||
return this.getManaPool().getMana().count() >= amountOfMana;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// private boolean checkSpellOnTopOfStackCondition(String[] groups, Game game) {
|
||||
// if (groups.length > 2 && groups[2].startsWith("spellOnTopOfStack=")) {
|
||||
// String spellOnTopOFStack = groups[2].substring(18);
|
||||
// if (game.getStack().size() > 0) {
|
||||
// StackObject stackObject = game.getStack().getFirst();
|
||||
// if (stackObject != null && stackObject.getStackAbility().toString().contains(spellOnTopOFStack)) {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
|
||||
private boolean addTargets(Ability ability, String[] groups, Game game) {
|
||||
boolean result = true;
|
||||
for (int i = 1; i < groups.length; i++) {
|
||||
String group = groups[i];
|
||||
if (group.startsWith("spellOnStack") || group.startsWith("spellOnTopOfStack") || group.startsWith("!spellOnStack") || group.startsWith("target=null") ) {
|
||||
if (group.startsWith("spellOnStack") || group.startsWith("spellOnTopOfStack") || group.startsWith("!spellOnStack") || group.startsWith("target=null") || group.startsWith("manaInPool=")) {
|
||||
break;
|
||||
}
|
||||
if (ability instanceof SpellAbility && ((SpellAbility) ability).getSpellAbilityType().equals(SpellAbilityType.SPLIT_FUSED)) {
|
||||
|
|
|
@ -723,6 +723,10 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
player.addAction(turnNum, step, "activate:Cast " + cardName + "$targetPlayer=" + target.getName());
|
||||
}
|
||||
|
||||
public void castSpell(int turnNum, PhaseStep step, TestPlayer player, String cardName, Player target, int manaInPool) {
|
||||
player.addAction(turnNum, step, "activate:Cast " + cardName + "$targetPlayer=" + target.getName() + "$manaInPool=" + manaInPool);
|
||||
}
|
||||
|
||||
public void castSpell(int turnNum, PhaseStep step, TestPlayer player, String cardName, String targetName) {
|
||||
player.addAction(turnNum, step, "activate:Cast " + cardName + "$target=" + targetName);
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ import java.util.UUID;
|
|||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.target.common.TargetCardInGraveyard;
|
||||
|
||||
/**
|
||||
* Cards with the Aura subtype don't change the zone they are in, if there is no
|
||||
|
@ -100,7 +101,7 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
|
|||
|
||||
UUID targetId = null;
|
||||
MageObject sourceObject = game.getObject(sourceId);
|
||||
|
||||
boolean enchantCardInGraveyard = false;
|
||||
if (sourceObject instanceof Spell) {
|
||||
if (fromZone.equals(Zone.EXILED)) {
|
||||
// cast from exile (e.g. Neightveil Spector) -> no replacement
|
||||
|
@ -116,6 +117,7 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
|
|||
|
||||
if (targetId == null) {
|
||||
Target target = card.getSpellAbility().getTargets().get(0);
|
||||
enchantCardInGraveyard = target instanceof TargetCardInGraveyard;
|
||||
Player player = game.getPlayer(card.getOwnerId());
|
||||
Outcome auraOutcome = Outcome.BoostCreature;
|
||||
Ability: for (Ability ability:card.getAbilities()) {
|
||||
|
@ -128,15 +130,24 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (player != null && player.choose(auraOutcome, target, card.getId(), game)) {
|
||||
if (target != null && player != null && player.choose(auraOutcome, target, card.getId(), game)) {
|
||||
targetId = target.getFirstTarget();
|
||||
}
|
||||
}
|
||||
|
||||
Permanent targetPermanent = game.getPermanent(targetId);
|
||||
Card targetCard = null;
|
||||
Permanent targetPermanent = null;
|
||||
if (enchantCardInGraveyard) {
|
||||
targetCard = game.getCard(targetId);
|
||||
} else {
|
||||
targetPermanent = game.getPermanent(targetId);
|
||||
}
|
||||
Player targetPlayer = game.getPlayer(targetId);
|
||||
if (targetPermanent != null || targetPlayer != null) {
|
||||
if (targetCard != null || targetPermanent != null || targetPlayer != null) {
|
||||
switch (fromZone) {
|
||||
case EXILED:
|
||||
game.getExile().removeCard(card, game);
|
||||
break;
|
||||
case GRAVEYARD:
|
||||
game.getPlayer(card.getOwnerId()).removeFromGraveyard(card, game);
|
||||
break;
|
||||
|
@ -158,6 +169,9 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
|
|||
game.applyEffects();
|
||||
game.fireEvent(new ZoneChangeEvent(permanent, controllerId, fromZone, Zone.BATTLEFIELD));
|
||||
|
||||
if (targetCard != null) {
|
||||
permanent.attachTo(targetCard.getId(), game);
|
||||
}
|
||||
if (targetPermanent != null) {
|
||||
targetPermanent.addAttachment(permanent.getId(), game);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue