fix Unstable Amulet not working on split/mdfc/adventures

This commit is contained in:
Susucre 2024-06-09 13:59:56 +02:00
parent 9180e22844
commit cbe1db3434
2 changed files with 77 additions and 6 deletions

View file

@ -104,7 +104,7 @@ class UnstableAmuletEffect extends OneShotEffect {
}
// Allow the card to be played until it leaves that exile zone.
ContinuousEffect effect = new UnstableAmuletPlayEffect(exileId);
effect.setTargetPointer(new FixedTarget(card, game));
effect.setTargetPointer(new FixedTarget(card.getMainCard(), game));
game.addEffect(effect, source);
// Clean the exile Zone from other cards, that can no longer be played.
ExileZone exileZone = game.getExile().getExileZone(exileId);
@ -113,7 +113,7 @@ class UnstableAmuletEffect extends OneShotEffect {
}
Set<Card> inExileZone = exileZone.getCards(game);
for (Card cardInExile : inExileZone) {
if (cardInExile.getId().equals(card.getId())) {
if (cardInExile.getMainCard().getId().equals(card.getMainCard().getId())) {
continue;
}
game.getExile().moveToMainExileZone(cardInExile, game);
@ -149,16 +149,22 @@ class UnstableAmuletPlayEffect extends AsThoughEffectImpl {
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
UUID cardId = getTargetPointer().getFirst(game, source);
if (cardId == null) {
Card mainTargetCard = game.getCard(getTargetPointer().getFirst(game, source));
if (mainTargetCard == null) {
this.discard();
return false;
}
ExileZone exileZone = game.getExile().getExileZone(exileId);
if (exileZone == null || !exileZone.contains(cardId)) {
if (exileZone == null || !exileZone.contains(mainTargetCard.getId())) {
// Clean the Continuous effect if the target card is no longer in the exile zone
this.discard();
return false;
}
return cardId.equals(objectId) && affectedControllerId.equals(source.getControllerId());
Card objectCard = game.getCard(objectId);
if (objectCard == null) {
return false;
}
return mainTargetCard.getId().equals(objectCard.getMainCard().getId()) // using main card to work with split/mdfc/adventures
&& affectedControllerId.equals(source.getControllerId());
}
}

View file

@ -80,4 +80,69 @@ public class UnstableAmuletTest extends CardTestPlayerBase {
assertExileCount(playerA, "Grizzly Bears", 1);
assertPermanentCount(playerA, "Balduvian Bears", 1);
}
@Test
public void test_Split() {
setStrictChooseMode(true);
skipInitShuffling();
addCard(Zone.BATTLEFIELD, playerA, "Volcanic Island", 2);
addCard(Zone.HAND, playerA, amulet);
addCard(Zone.LIBRARY, playerA, "Fire // Ice");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, amulet, true);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}, Pay {E}{E}");
checkPlayableAbility("No mana to cast Fire", 1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Cast Fire", false);
checkPlayableAbility("No mana to cast Ice", 1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Cast Ice", false);
checkExileCount("Fire // Ice in exile", 1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Fire // Ice", 1);
checkPlayableAbility("Can play Fire", 3, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Fire", true);
checkPlayableAbility("Can play Ice", 3, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Ice", true);
castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Ice", amulet);
setStopAt(3, PhaseStep.BEGIN_COMBAT);
execute();
assertLife(playerB, 20 - 1); // 1 damage from Amulet trigger
assertHandCount(playerA, 2); // 1 from turn 3 draw step, 1 from Ice
assertTapped(amulet, true);
assertTappedCount("Volcanic Island", true, 2);
}
@Test
public void test_Adventure() {
setStrictChooseMode(true);
skipInitShuffling();
addCard(Zone.BATTLEFIELD, playerA, "Taiga", 2);
addCard(Zone.HAND, playerA, amulet);
addCard(Zone.LIBRARY, playerA, "Curious Pair");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, amulet, true);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}, Pay {E}{E}");
checkPlayableAbility("1: No mana to cast Curious Pair", 1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Cast Curious Pair", false);
checkPlayableAbility("1: No mana to cast Treats to Share", 1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Cast Treats to Share", false);
checkExileCount("1: Curious Pair in exile", 1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Curious Pair", 1);
checkPlayableAbility("2: Can play Curious Pair", 3, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Curious Pair", true);
checkPlayableAbility("2: Can play Treats to Share", 3, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Treats to Share", true);
castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Treats to Share");
checkPlayableAbility("3: No mana to cast Curious Pair", 3, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Curious Pair", false);
checkPlayableAbility("3: Can't cast Treats to Share (on an adventure)", 3, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Treats to Share", false);
checkExileCount("3: Curious Pair in exile (on an adventure)", 3, PhaseStep.POSTCOMBAT_MAIN, playerA, "Curious Pair", 1);
checkPlayableAbility("4: Can play Curious Pair", 5, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Curious Pair", true);
checkPlayableAbility("4: Can't cast Treats to Share (on an adventure)", 5, PhaseStep.PRECOMBAT_MAIN, playerA, "Cast Treats to Share", false);
castSpell(5, PhaseStep.PRECOMBAT_MAIN, playerA, "Curious Pair");
setStopAt(5, PhaseStep.BEGIN_COMBAT);
execute();
assertLife(playerB, 20 - 2); // 1 damage per Amulet trigger
assertTappedCount("Taiga", true, 2);
assertPermanentCount(playerA, "Food Token", 1);
assertPermanentCount(playerA, "Curious Pair", 1);
}
}