mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 19:11:59 -08:00
performance: added day/night performance test for transform ability (disabled by default, see DayNightTest, related to #11285), added day/night rules ref
This commit is contained in:
parent
70c79fd6a6
commit
d6c858ecaf
4 changed files with 68 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ import mage.constants.PhaseStep;
|
|||
import mage.constants.Zone;
|
||||
import mage.game.permanent.Permanent;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
|
|
@ -331,4 +332,48 @@ public class DayNightTest extends CardTestPlayerBase {
|
|||
assertDayNight(true);
|
||||
assertLife(playerB, 20 - 1 - 3 - 3 - 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // debug only, use it to performance profiling only, can be slow
|
||||
public void test_TransformDayboundPerformance() {
|
||||
// day/night transform can take too much CPU usage, see https://github.com/magefree/mage/issues/11081
|
||||
final int TEST_MAX_TURN = 300;
|
||||
final int TEST_MAX_SIMPLE_CARDS = 50;
|
||||
final int TEST_MAX_DAYBOUND_CARDS = 15;
|
||||
|
||||
// You have no maximum hand size.
|
||||
playerA.setMaxCallsWithoutAction(10000);
|
||||
playerB.setMaxCallsWithoutAction(10000);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Graceful Adept", 1);
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Graceful Adept", 1);
|
||||
// skip draw step
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Damia, Sage of Stone", 1);
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Damia, Sage of Stone", 1);
|
||||
// simple cards
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Angelfire Crusader", TEST_MAX_SIMPLE_CARDS);
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Angelfire Crusader", TEST_MAX_SIMPLE_CARDS);
|
||||
// day/night cards
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Baneblade Scoundrel", TEST_MAX_DAYBOUND_CARDS);
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Baneblade Scoundrel", TEST_MAX_DAYBOUND_CARDS);
|
||||
|
||||
for (int i = 10; i <= TEST_MAX_TURN; i++) {
|
||||
if (i % 2 == 0) {
|
||||
runCode("on turn " + i, i, PhaseStep.PRECOMBAT_MAIN, playerA, (info, player, game) -> {
|
||||
// switch to night: auto on untap
|
||||
// switch to day: here by workaround instead 2+ spells cast
|
||||
game.setDaytime(!game.checkDayNight(true));
|
||||
});
|
||||
}
|
||||
runCode("on turn " + i, i, PhaseStep.PRECOMBAT_MAIN, playerA, (info, player, game) -> {
|
||||
System.out.println(String.format("turn %d, is day: %s", game.getTurnNum(), game.checkDayNight(true) ? "yes" : "no"));
|
||||
});
|
||||
}
|
||||
showBattlefield("after", TEST_MAX_TURN, PhaseStep.PRECOMBAT_MAIN, playerA);
|
||||
|
||||
setStrictChooseMode(true);
|
||||
setStopAt(TEST_MAX_TURN, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
Assert.assertEquals(TEST_MAX_TURN, currentGame.getTurnNum());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue