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:
Oleg Agafonov 2023-11-07 01:25:15 +04:00
parent 70c79fd6a6
commit d6c858ecaf
4 changed files with 68 additions and 0 deletions

View file

@ -51,6 +51,8 @@ class DayboundEffect extends ContinuousEffectImpl {
@Override
public boolean apply(Game game, Ability source) {
if (!game.hasDayNight()) {
// 702.145d
// Any time a player controls a permanent with daybound, if its neither day nor night, it becomes day.
game.setDaytime(true);
}
return true;

View file

@ -57,6 +57,9 @@ class NightboundEffect extends ContinuousEffectImpl {
@Override
public boolean apply(Game game, Ability source) {
if (!game.hasDayNight()) {
// 702.145f
// Any time a player controls a permanent that is back face up with nightbound and its day,
// that player transforms that permanent. This happens immediately and isnt a state-based action.
game.setDaytime(false);
}
return true;

View file

@ -29,7 +29,15 @@ public class UntapStep extends Step {
@Override
public void beginStep(Game game, UUID activePlayerId) {
super.beginStep(game, activePlayerId);
// 726.2.
// As the second part of the untap step, the game checks the previous turn to see
// if the games day/night designation should change. See rule 502, Untap Step.
//
// Before a player untaps their permanents during the untap step, the game checks to see
// if the day/night designation should change. (2021-09-24)
handleDayNight(game);
Player activePlayer = game.getPlayer(activePlayerId);
//20091005 - 502.1/703.4a
activePlayer.phasing(game);
@ -52,8 +60,18 @@ public class UntapStep extends Step {
.getWatcher(CastSpellLastTurnWatcher.class)
.getActivePlayerPrevTurnCount();
if (game.checkDayNight(true) && previousSpells == 0) {
// 726.2a
// If its day and the previous turns active player didnt cast any spells during that turn,
// it becomes night. Multiplayer games using the shared team turns option (see rule 805)
// use a modified rule: if its day and no player from the previous turns active team cast a
// spell during that turn, it becomes night.
game.setDaytime(false);
} else if (game.checkDayNight(false) && previousSpells >= 2) {
// 726.2b
// If its night, and previous turns active player cast two or more spells during the previous turn,
// it becomes day. Multiplayer games using the shared team turns option (see rule 805) use a modified
// rule: if its night and any player from the previous turns active team cast two or more spells
// during that turn, it becomes day.
game.setDaytime(true);
}
}