[CMR] fixed Sphinx of the Second Sun - wrong extra phase and server freeze on usage;

This commit is contained in:
Oleg Agafonov 2020-12-16 04:17:03 +04:00
parent ac7910159e
commit f8206df3ba
4 changed files with 67 additions and 11 deletions

View file

@ -1,7 +1,5 @@
package mage.cards.a;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
@ -14,8 +12,9 @@ import mage.constants.SubType;
import mage.constants.TargetController;
import mage.game.Game;
import java.util.UUID;
/**
*
* @author Loki
*/
public final class AgentOfMasks extends CardImpl {
@ -25,7 +24,7 @@ public final class AgentOfMasks extends CardImpl {
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.ADVISOR);
// At the beginning of your upkeep, each opponent loses 1 life. You gain life equal to the life lost this way.
this.power = new MageInt(2);
this.toughness = new MageInt(3);
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new AgentOfMasksEffect(), TargetController.YOU, false));

View file

@ -30,7 +30,7 @@ public final class SphinxOfTheSecondSun extends CardImpl {
// Flying
this.addAbility(FlyingAbility.getInstance());
// At the beginning of your postcombat main phase, you get an additional beginning phase after this phase.
// At the beginning of your postcombat main phase, you get an additional beginning phase after this phase. (The beginning phase includes the untap, upkeep, and draw steps.)
this.addAbility(new BeginningOfPostCombatMainTriggeredAbility(
new SphinxOfTheSecondSunEffect(), TargetController.YOU, false
), new SphinxOfTheSecondSunWatcher());
@ -50,7 +50,7 @@ class SphinxOfTheSecondSunEffect extends OneShotEffect {
SphinxOfTheSecondSunEffect() {
super(Outcome.Benefit);
staticText = "you get an additional beginning phase after this phase";
staticText = "you get an additional beginning phase after this phase. <i>(The beginning phase includes the untap, upkeep, and draw steps.)</i>";
}
private SphinxOfTheSecondSunEffect(final SphinxOfTheSecondSunEffect effect) {
@ -74,9 +74,9 @@ class SphinxOfTheSecondSunEffect extends OneShotEffect {
break;
}
}
TurnMod combat = new TurnMod(source.getControllerId(), TurnPhase.POSTCOMBAT_MAIN, turnPhase, false);
combat.setNote("sphinxSecondSun");
game.getState().getTurnMods().add(combat);
TurnMod newPhase = new TurnMod(source.getControllerId(), TurnPhase.BEGINNING, turnPhase, false);
newPhase.setNote("sphinxSecondSun");
game.getState().getTurnMods().add(newPhase);
return true;
}
}

View file

@ -0,0 +1,57 @@
package org.mage.test.cards.single.cmr;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author JayDi85
*/
public class SphinxOfTheSecondSunTest extends CardTestPlayerBase {
@Test
public void test_Playable_OneCard() {
// bug: card generating infinite amount of extra steps
// At the beginning of your postcombat main phase, you get an additional beginning phase after this phase.
// (The beginning phase includes the untap, upkeep, and draw steps.)
addCard(Zone.BATTLEFIELD, playerA, "Sphinx of the Second Sun", 1);
//
// At the beginning of your upkeep, each opponent loses 1 life. You gain life equal to the life lost this way.
addCard(Zone.BATTLEFIELD, playerA, "Agent of Masks", 1);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
// 2x upkeep phases (1x normal + 1x from sphinx)
assertLife(playerA, 20 + 2);
assertLife(playerB, 20 - 2);
}
@Test
public void test_Playable_TwoCards() {
// bug: card generating infinite amount of extra steps
// At the beginning of your postcombat main phase, you get an additional beginning phase after this phase.
// (The beginning phase includes the untap, upkeep, and draw steps.)
addCard(Zone.BATTLEFIELD, playerA, "Sphinx of the Second Sun", 2);
//
// At the beginning of your upkeep, each opponent loses 1 life. You gain life equal to the life lost this way.
addCard(Zone.BATTLEFIELD, playerA, "Agent of Masks", 1);
setChoice(playerA, "At the beginning"); // 2x triggers
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
// 3x upkeep phases (1x normal + 2x from sphinx)
assertLife(playerA, 20 + 3);
assertLife(playerB, 20 - 3);
}
}

View file

@ -1028,7 +1028,7 @@ public class TestPlayer implements Player {
if (numberOfActions == actions.size()) {
foundNoAction++;
if (foundNoAction > maxCallsWithoutAction) {
throw new AssertionError("More priority calls to " + getName()
throw new AssertionError("Too much priority calls to " + getName()
+ " without taking any action than allowed (" + maxCallsWithoutAction + ") on turn " + game.getTurnNum());
}
} else {