mirror of
https://github.com/magefree/mage.git
synced 2026-01-10 04:42:07 -08:00
Introduce Duration.UntilYourNextUpkeepStep (#10600)
* add new Duration * refactor cards with new Duration. * fix both Durations and add unit tests. * fix text
This commit is contained in:
parent
14235b6320
commit
6a9340f1aa
14 changed files with 291 additions and 180 deletions
|
|
@ -0,0 +1,118 @@
|
|||
package org.mage.test.cards.continuous;
|
||||
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.common.continuous.BoostSourceEffect;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
* @author Susucr
|
||||
*/
|
||||
public class UntilEndCombatYourNextTurnTest extends CardTestPlayerBase {
|
||||
|
||||
public interface AdditionalSetup {
|
||||
void init(UntilEndCombatYourNextTurnTest test);
|
||||
}
|
||||
|
||||
public void doTest(AdditionalSetup additionalSetup, int endTurnNum, PhaseStep endPhaseStep, boolean stillActive) {
|
||||
addCustomCardWithAbility(
|
||||
"tester", playerA,
|
||||
new SimpleActivatedAbility(new BoostSourceEffect(
|
||||
1, 1, Duration.UntilEndCombatOfYourNextTurn
|
||||
), new ManaCostsImpl<>("{0}")), null,
|
||||
CardType.CREATURE, "", Zone.BATTLEFIELD
|
||||
);
|
||||
|
||||
if(additionalSetup != null){
|
||||
additionalSetup.init(this);
|
||||
}
|
||||
|
||||
activateAbility(1, PhaseStep.UPKEEP, playerA, "{0}");
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(endTurnNum, endPhaseStep);
|
||||
execute();
|
||||
|
||||
int powerToughness = stillActive ? 2 : 1;
|
||||
assertPowerToughness(playerA, "tester", powerToughness, powerToughness);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSameTurnPre() {
|
||||
doTest(null, 1, PhaseStep.PRECOMBAT_MAIN, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSameTurnPost() {
|
||||
doTest(null,1, PhaseStep.POSTCOMBAT_MAIN, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOppTurnPre() {
|
||||
doTest(null, 2, PhaseStep.PRECOMBAT_MAIN, true); }
|
||||
|
||||
@Test
|
||||
public void testOppTurnPost() {
|
||||
doTest(null, 2, PhaseStep.PRECOMBAT_MAIN, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTurnCyclePre() {
|
||||
doTest(null, 3, PhaseStep.PRECOMBAT_MAIN, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTurnCycleFalse() {
|
||||
|
||||
doTest(null, 3, PhaseStep.POSTCOMBAT_MAIN, false);
|
||||
}
|
||||
|
||||
// Relevant rulings:
|
||||
//
|
||||
// 614.10. An effect that causes a player to skip an event, step, phase, or turn
|
||||
// is a replacement effect. “Skip [something]” is the same as “Instead of doing
|
||||
// [something], do nothing.” Once a step, phase, or turn has started, it can no
|
||||
// longer be skipped—any skip effects will wait until the next occurrence.
|
||||
//
|
||||
// 614.10a Anything scheduled for a skipped step, phase, or turn won’t happen.
|
||||
// Anything scheduled for the “next” occurrence of something waits for the first
|
||||
// occurrence that isn’t skipped. If two effects each cause a player to skip
|
||||
// their next occurrence, that player must skip the next two; one effect will
|
||||
// be satisfied in skipping the first occurrence, while the other will remain
|
||||
// until another occurrence can be skipped
|
||||
private static void timeStopOn3(UntilEndCombatYourNextTurnTest test) {
|
||||
// End the turn.
|
||||
test.addCard(Zone.HAND, test.playerA, "Time Stop");
|
||||
test.addCard(Zone.BATTLEFIELD, test.playerA, "Island", 6);
|
||||
test.castSpell(3,PhaseStep.PRECOMBAT_MAIN,test.playerA,"Time Stop");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTimeStopTurnCyclePre() {
|
||||
|
||||
doTest(test -> timeStopOn3(test), 3, PhaseStep.PRECOMBAT_MAIN, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTimeStopTurnCycleFalse() {
|
||||
|
||||
doTest(test -> timeStopOn3(test), 3, PhaseStep.CLEANUP, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTimeStop2TurnCyclePre() {
|
||||
|
||||
doTest(test -> timeStopOn3(test), 5, PhaseStep.PRECOMBAT_MAIN, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTimeStop2TurnCycleFalse() {
|
||||
doTest(test -> timeStopOn3(test), 5, PhaseStep.POSTCOMBAT_MAIN, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
package org.mage.test.cards.continuous;
|
||||
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.common.continuous.BoostSourceEffect;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
* @author Susucr
|
||||
*/
|
||||
public class UntilYourNextUpkeep extends CardTestPlayerBase {
|
||||
|
||||
public interface AdditionalSetup {
|
||||
void init(UntilYourNextUpkeep test);
|
||||
}
|
||||
|
||||
public void doTest(AdditionalSetup additionalSetup,
|
||||
int startTurnNum, PhaseStep startPhaseStep,
|
||||
int endTurnNum, PhaseStep endPhaseStep,
|
||||
boolean stillActive) {
|
||||
setStrictChooseMode(true);
|
||||
|
||||
addCustomCardWithAbility(
|
||||
"tester", playerA,
|
||||
new SimpleActivatedAbility(new BoostSourceEffect(
|
||||
1, 1, Duration.UntilYourNextUpkeepStep
|
||||
), new ManaCostsImpl<>("{0}")), null,
|
||||
CardType.CREATURE, "", Zone.BATTLEFIELD
|
||||
);
|
||||
|
||||
if(additionalSetup != null){
|
||||
additionalSetup.init(this);
|
||||
}
|
||||
|
||||
activateAbility(startTurnNum, startPhaseStep, playerA, "{0}");
|
||||
|
||||
setStopAt(endTurnNum, endPhaseStep);
|
||||
execute();
|
||||
|
||||
int powerToughness = stillActive ? 2 : 1;
|
||||
assertPowerToughness(playerA, "tester", powerToughness, powerToughness);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSameTurn() {
|
||||
doTest(null, 1, PhaseStep.UPKEEP, 1, PhaseStep.PRECOMBAT_MAIN, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOppTurn() {
|
||||
doTest(null, 1, PhaseStep.UPKEEP, 2, PhaseStep.PRECOMBAT_MAIN, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTurnCycle() {
|
||||
doTest(null, 1, PhaseStep.UPKEEP, 3, PhaseStep.PRECOMBAT_MAIN, false);
|
||||
}
|
||||
|
||||
private static void initParadoxHaze(UntilYourNextUpkeep test) {
|
||||
// At the beginning of enchanted player’s first upkeep each turn,
|
||||
// that player gets an additional upkeep step after this step.
|
||||
test.addCard(Zone.HAND, test.playerA, "Paradox Haze");
|
||||
test.addCard(Zone.BATTLEFIELD, test.playerA, "Island", 3);
|
||||
test.castSpell(1, PhaseStep.PRECOMBAT_MAIN, test.playerA, "Paradox Haze", test.playerA);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParadoxHazeOppSameTurn() {
|
||||
doTest(test -> initParadoxHaze(test), 2, PhaseStep.UPKEEP, 2, PhaseStep.PRECOMBAT_MAIN, true);
|
||||
}
|
||||
|
||||
// Activating at first upkeep, at second upkeep the effect wears off.
|
||||
@Test
|
||||
public void testParadoxHazeSameTurn() {
|
||||
doTest(test -> initParadoxHaze(test), 3, PhaseStep.UPKEEP, 3, PhaseStep.PRECOMBAT_MAIN, false);
|
||||
}
|
||||
|
||||
private static void initEonHub(UntilYourNextUpkeep test) {
|
||||
// Players skip their upkeep step.
|
||||
test.addCard(Zone.BATTLEFIELD, test.playerA, "Eon Hub");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEonHubSameTurn() {
|
||||
doTest(test -> initEonHub(test), 1, PhaseStep.PRECOMBAT_MAIN, 1, PhaseStep.POSTCOMBAT_MAIN, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEonHubCycleTurn() {
|
||||
doTest(test -> initEonHub(test), 1, PhaseStep.PRECOMBAT_MAIN, 3, PhaseStep.POSTCOMBAT_MAIN, true);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue