mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 12:02:01 -08:00
* Repeated Reverberation - fixed rollback error on creatures cast (#7474);
This commit is contained in:
parent
5077a82585
commit
c03279d835
3 changed files with 70 additions and 40 deletions
|
|
@ -60,8 +60,8 @@ class RepeatedReverberationTriggeredAbility extends DelayedTriggeredAbility {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkEventType(GameEvent event, Game game) {
|
public boolean checkEventType(GameEvent event, Game game) {
|
||||||
return event.getType() == GameEvent.EventType.SPELL_CAST
|
return event.getType() == GameEvent.EventType.ACTIVATED_ABILITY
|
||||||
|| event.getType() == GameEvent.EventType.ACTIVATED_ABILITY;
|
|| event.getType() == GameEvent.EventType.SPELL_CAST;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -69,28 +69,37 @@ class RepeatedReverberationTriggeredAbility extends DelayedTriggeredAbility {
|
||||||
if (!event.getPlayerId().equals(this.getControllerId())) {
|
if (!event.getPlayerId().equals(this.getControllerId())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
|
||||||
if (spell != null && spell.isInstantOrSorcery()) {
|
// activated ability
|
||||||
this.getEffects().clear();
|
if (event.getType() == GameEvent.EventType.ACTIVATED_ABILITY) {
|
||||||
this.addEffect(
|
StackAbility stackAbility = (StackAbility) game.getStack().getStackObject(event.getSourceId());
|
||||||
new CopyTargetSpellEffect(true)
|
if (stackAbility != null && stackAbility.getStackAbility() instanceof LoyaltyAbility) {
|
||||||
.setTargetPointer(new FixedTarget(event.getTargetId(), game))
|
this.getEffects().clear();
|
||||||
);
|
this.addEffect(
|
||||||
this.addEffect(
|
new RepeatedReverberationEffect()
|
||||||
new CopyTargetSpellEffect(true)
|
.setTargetPointer(new FixedTarget(event.getTargetId(), game))
|
||||||
.setTargetPointer(new FixedTarget(event.getTargetId(), game))
|
);
|
||||||
);
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
}
|
||||||
StackAbility stackAbility = (StackAbility) game.getStack().getStackObject(event.getSourceId());
|
|
||||||
if (stackAbility != null && stackAbility.getStackAbility() instanceof LoyaltyAbility) {
|
// spell
|
||||||
this.getEffects().clear();
|
if (event.getType() == GameEvent.EventType.SPELL_CAST) {
|
||||||
this.addEffect(
|
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||||
new RepeatedReverberationEffect()
|
if (spell != null && spell.isInstantOrSorcery()) {
|
||||||
.setTargetPointer(new FixedTarget(event.getTargetId(), game))
|
this.getEffects().clear();
|
||||||
);
|
this.addEffect(
|
||||||
return true;
|
new CopyTargetSpellEffect(true)
|
||||||
|
.setTargetPointer(new FixedTarget(event.getTargetId(), game))
|
||||||
|
);
|
||||||
|
this.addEffect(
|
||||||
|
new CopyTargetSpellEffect(true)
|
||||||
|
.setTargetPointer(new FixedTarget(event.getTargetId(), game))
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
|
|
||||||
package mage.cards.r;
|
package mage.cards.r;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.TriggeredAbilityImpl;
|
import mage.abilities.TriggeredAbilityImpl;
|
||||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
|
|
@ -15,13 +13,13 @@ import mage.constants.Outcome;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.game.events.GameEvent.EventType;
|
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.game.stack.StackAbility;
|
import mage.game.stack.StackAbility;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public final class RingsOfBrighthearth extends CardImpl {
|
public final class RingsOfBrighthearth extends CardImpl {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
package org.mage.test.cards.single.m20;
|
package org.mage.test.cards.single.m20;
|
||||||
|
|
||||||
import mage.constants.PhaseStep;
|
import mage.constants.PhaseStep;
|
||||||
|
|
@ -8,23 +7,22 @@ import org.junit.Test;
|
||||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Jgray1206
|
* @author Jgray1206
|
||||||
*/
|
*/
|
||||||
public class RepeatedReverberationTest extends CardTestPlayerBase {
|
public class RepeatedReverberationTest extends CardTestPlayerBase {
|
||||||
|
|
||||||
/* Repeated Reverberation {2}{R}{R}
|
/* Repeated Reverberation {2}{R}{R}
|
||||||
* When you next cast an instant spell, cast a sorcery spell, or activate a loyalty ability this turn, copy that spell or ability twice.
|
* When you next cast an instant spell, cast a sorcery spell, or activate a loyalty ability this turn, copy that spell or ability twice.
|
||||||
* You may choose new targets for the copies.
|
* You may choose new targets for the copies.
|
||||||
*/
|
*/
|
||||||
String repeatedReverb = "Repeated Reverberation";
|
String repeatedReverb = "Repeated Reverberation";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* https://github.com/magefree/mage/issues/5882
|
* https://github.com/magefree/mage/issues/5882
|
||||||
* Repeated Reverberation was not working with loyalty counter abilities.
|
* Repeated Reverberation was not working with loyalty counter abilities.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testRepeatedReverberationWorksWithLoyaltyAbilities() {
|
public void test_WorksWithLoyaltyAbilities() {
|
||||||
/* Ajani Goldmane: {2}{W}{W} starts with 4 Loyality counters
|
/* Ajani Goldmane: {2}{W}{W} starts with 4 Loyality counters
|
||||||
* +1: You gain 2 life.
|
* +1: You gain 2 life.
|
||||||
* -1: Put a +1/+1 counter on each creature you control. Those creatures gain vigilance until end of turn.
|
* -1: Put a +1/+1 counter on each creature you control. Those creatures gain vigilance until end of turn.
|
||||||
|
|
@ -32,7 +30,7 @@ public class RepeatedReverberationTest extends CardTestPlayerBase {
|
||||||
*/
|
*/
|
||||||
String ajani = "Ajani Goldmane";
|
String ajani = "Ajani Goldmane";
|
||||||
|
|
||||||
addCard(Zone.HAND, playerA, ajani);
|
addCard(Zone.HAND, playerA, ajani);
|
||||||
addCard(Zone.HAND, playerA, repeatedReverb);
|
addCard(Zone.HAND, playerA, repeatedReverb);
|
||||||
addCard(Zone.BATTLEFIELD, playerA, "Plains", 4);
|
addCard(Zone.BATTLEFIELD, playerA, "Plains", 4);
|
||||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 4);
|
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 4);
|
||||||
|
|
@ -41,26 +39,26 @@ public class RepeatedReverberationTest extends CardTestPlayerBase {
|
||||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, repeatedReverb);
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, repeatedReverb);
|
||||||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "+1: You gain 2 life");
|
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "+1: You gain 2 life");
|
||||||
|
|
||||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
|
||||||
setStrictChooseMode(true);
|
setStrictChooseMode(true);
|
||||||
|
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||||
execute();
|
execute();
|
||||||
|
assertAllCommandsUsed();
|
||||||
|
|
||||||
assertPermanentCount(playerA, ajani, 1);
|
assertPermanentCount(playerA, ajani, 1);
|
||||||
assertGraveyardCount(playerA, repeatedReverb, 1);
|
assertGraveyardCount(playerA, repeatedReverb, 1);
|
||||||
assertCounterCount(ajani, CounterType.LOYALTY, 5); // 4 + 1 = 5
|
assertCounterCount(ajani, CounterType.LOYALTY, 5); // 4 + 1 = 5
|
||||||
|
|
||||||
assertLife(playerA, 26);
|
assertLife(playerA, 26);
|
||||||
assertAllCommandsUsed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRepeatedReverberationWorksWithInstants() {
|
public void test_WorksWithInstants() {
|
||||||
/* Soothing Balm - Instant {1}{W}
|
/* Soothing Balm - Instant {1}{W}
|
||||||
* Target player gains 5 life
|
* Target player gains 5 life
|
||||||
* Just an arbitrary instant to test reverb with.
|
* Just an arbitrary instant to test reverb with.
|
||||||
*/
|
*/
|
||||||
String soothingBalm = "Soothing Balm";
|
String soothingBalm = "Soothing Balm";
|
||||||
|
|
||||||
addCard(Zone.HAND, playerA, soothingBalm);
|
addCard(Zone.HAND, playerA, soothingBalm);
|
||||||
addCard(Zone.HAND, playerA, repeatedReverb);
|
addCard(Zone.HAND, playerA, repeatedReverb);
|
||||||
addCard(Zone.BATTLEFIELD, playerA, "Plains", 4);
|
addCard(Zone.BATTLEFIELD, playerA, "Plains", 4);
|
||||||
|
|
@ -75,20 +73,20 @@ public class RepeatedReverberationTest extends CardTestPlayerBase {
|
||||||
setChoice(playerA, "Yes"); //Choose new targets?
|
setChoice(playerA, "Yes"); //Choose new targets?
|
||||||
addTarget(playerA, playerA);
|
addTarget(playerA, playerA);
|
||||||
|
|
||||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
|
||||||
setStrictChooseMode(true);
|
setStrictChooseMode(true);
|
||||||
|
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||||
execute();
|
execute();
|
||||||
|
assertAllCommandsUsed();
|
||||||
|
|
||||||
assertGraveyardCount(playerA, soothingBalm, 1);
|
assertGraveyardCount(playerA, soothingBalm, 1);
|
||||||
assertGraveyardCount(playerA, repeatedReverb, 1);
|
assertGraveyardCount(playerA, repeatedReverb, 1);
|
||||||
|
|
||||||
assertLife(playerA, 30);
|
assertLife(playerA, 30);
|
||||||
assertLife(playerB, 25);
|
assertLife(playerB, 25);
|
||||||
assertAllCommandsUsed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRepeatedReverberationWorksWithSorceries() {
|
public void test_WorksWithSorceries() {
|
||||||
/* Soul Feast - Sorcery {3}{B}{B}
|
/* Soul Feast - Sorcery {3}{B}{B}
|
||||||
* Target player loses 4 life. You gain 4 life.
|
* Target player loses 4 life. You gain 4 life.
|
||||||
* Just an arbitrary sorcery to test reverb with.
|
* Just an arbitrary sorcery to test reverb with.
|
||||||
|
|
@ -106,15 +104,40 @@ public class RepeatedReverberationTest extends CardTestPlayerBase {
|
||||||
setChoice(playerA, "No"); //Choose new targets?
|
setChoice(playerA, "No"); //Choose new targets?
|
||||||
setChoice(playerA, "No"); //Choose new targets?
|
setChoice(playerA, "No"); //Choose new targets?
|
||||||
|
|
||||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
|
||||||
setStrictChooseMode(true);
|
setStrictChooseMode(true);
|
||||||
|
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||||
execute();
|
execute();
|
||||||
|
assertAllCommandsUsed();
|
||||||
|
|
||||||
assertGraveyardCount(playerA, soulFeast, 1);
|
assertGraveyardCount(playerA, soulFeast, 1);
|
||||||
assertGraveyardCount(playerA, repeatedReverb, 1);
|
assertGraveyardCount(playerA, repeatedReverb, 1);
|
||||||
|
|
||||||
assertLife(playerA, 32);
|
assertLife(playerA, 32);
|
||||||
assertLife(playerB, 8);
|
assertLife(playerB, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_MustNotWorksWithCreatures() {
|
||||||
|
addCard(Zone.HAND, playerA, repeatedReverb); // {2}{R}{R}
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 4);
|
||||||
|
//
|
||||||
|
addCard(Zone.HAND, playerA, "Balduvian Bears", 1);
|
||||||
|
addCard(Zone.BATTLEFIELD, playerA, "Forest", 2);
|
||||||
|
|
||||||
|
// prepare reverb
|
||||||
|
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}", 4);
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, repeatedReverb);
|
||||||
|
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
|
||||||
|
// cast creature
|
||||||
|
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {G}", 2);
|
||||||
|
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Balduvian Bears");
|
||||||
|
|
||||||
|
setStrictChooseMode(true);
|
||||||
|
setStopAt(1, PhaseStep.END_TURN);
|
||||||
|
execute();
|
||||||
assertAllCommandsUsed();
|
assertAllCommandsUsed();
|
||||||
|
|
||||||
|
assertPermanentCount(playerA, "Balduvian Bears", 1);
|
||||||
|
assertGraveyardCount(playerA, repeatedReverb, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue