Additional fix flashback and split cards (see cce467a5ec)

This commit is contained in:
Oleg Agafonov 2020-06-04 11:24:37 +04:00
parent cce467a5ec
commit 95075cf33e
3 changed files with 13 additions and 12 deletions

View file

@ -1,5 +1,3 @@
package org.mage.test.cards.abilities.other;
import mage.constants.PhaseStep;
@ -8,19 +6,17 @@ import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author BetaSteward
*/
public class PastInFlamesTest extends CardTestPlayerBase {
/**
/**
* Past in Flames
* Sorcery, 3R (4)
* Each instant and sorcery card in your graveyard gains flashback until end
* Each instant and sorcery card in your graveyard gains flashback until end
* of turn. The flashback cost is equal to its mana cost.
* Flashback {4}{R} (You may cast this card from your graveyard for its
* Flashback {4}{R} (You may cast this card from your graveyard for its
* flashback cost. Then exile it.)
*
*/
@Test
@ -31,7 +27,7 @@ public class PastInFlamesTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Past in Flames");
activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Flashback");
setStopAt(1, PhaseStep.END_TURN);
execute();
@ -40,7 +36,6 @@ public class PastInFlamesTest extends CardTestPlayerBase {
assertExileCount("Lightning Bolt", 1);
assertGraveyardCount(playerA, "Lightning Bolt", 0);
}
}

View file

@ -34,6 +34,7 @@ public class CastSplitCardsWithFlashbackTest extends CardTestPlayerBase {
assertAllCommandsUsed();
assertLife(playerB, 20 - 3);
assertExileCount(playerA, "Lightning Bolt", 1);
}
@Test
@ -66,6 +67,7 @@ public class CastSplitCardsWithFlashbackTest extends CardTestPlayerBase {
assertGraveyardCount(playerB, "Bident of Thassa", 1);
assertPermanentCount(playerB, "Bow of Nylea", 1);
assertExileCount(playerA, "Wear // Tear", 1);
}
@Test
@ -98,5 +100,6 @@ public class CastSplitCardsWithFlashbackTest extends CardTestPlayerBase {
assertGraveyardCount(playerB, "Bident of Thassa", 1);
assertPermanentCount(playerB, "Bow of Nylea", 1);
assertExileCount(playerA, "Wear // Tear", 1);
}
}

View file

@ -14,6 +14,7 @@ import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
import mage.util.CardUtil;
import java.util.UUID;
@ -53,6 +54,7 @@ public class FlashbackAbility extends SpellAbility {
@Override
public ActivationStatus canActivate(UUID playerId, Game game) {
// flashback ability dynamicly added to all card's parts (split cards)
if (super.canActivate(playerId, game).canActivate()) {
Card card = game.getCard(getSourceId());
if (card != null) {
@ -210,11 +212,12 @@ class FlashbackReplacementEffect extends ReplacementEffectImpl {
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getTargetId().equals(source.getSourceId())
UUID cardId = CardUtil.getMainCardId(game, source.getSourceId()); // for split cards
if (cardId.equals(event.getTargetId())
&& ((ZoneChangeEvent) event).getFromZone() == Zone.STACK
&& ((ZoneChangeEvent) event).getToZone() != Zone.EXILED) {
int zcc = game.getState().getZoneChangeCounter(source.getSourceId());
int zcc = game.getState().getZoneChangeCounter(cardId);
return ((FixedTarget) getTargetPointer()).getZoneChangeCounter() + 1 == zcc;
}