Change Duration.UntilTheNextEndStep to statically end during the beginning of EndStep.

This commit is contained in:
Grath 2024-09-30 22:08:58 -04:00
parent b1678036fa
commit 49bce836f9
6 changed files with 61 additions and 28 deletions

View file

@ -56,11 +56,9 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
// until your next turn or until end of your next turn
private UUID startingControllerId; // player to check for turn duration (can't different with real controller ability)
private UUID startingActivePlayerId; // Player whose turn the effect started on
private boolean startingTurnWasActive; // effect started during related players turn and related players turn was already active
private int effectStartingOnTurn = 0; // turn the effect started
private int effectStartingControllerEndStep = 0;
private int effectStartingActivePlayerEndStep = 0;
private int effectStartingEndStep = 0;
private int nextTurnNumber = Integer.MAX_VALUE; // effect is waiting for a step during your next turn, we store it if found.
// set to the turn number on your next turn.
private int effectStartingStepNum = 0; // Some continuous are waiting for the next step of a kind.
@ -93,11 +91,9 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
this.affectedObjectList.addAll(effect.affectedObjectList);
this.temporary = effect.temporary;
this.startingControllerId = effect.startingControllerId;
this.startingActivePlayerId = effect.startingActivePlayerId;
this.startingTurnWasActive = effect.startingTurnWasActive;
this.effectStartingOnTurn = effect.effectStartingOnTurn;
this.effectStartingControllerEndStep = effect.effectStartingControllerEndStep;
this.effectStartingActivePlayerEndStep = effect.effectStartingActivePlayerEndStep;
this.effectStartingEndStep = effect.effectStartingEndStep;
this.dependencyTypes = effect.dependencyTypes;
this.dependendToTypes = effect.dependendToTypes;
this.characterDefining = effect.characterDefining;
@ -255,12 +251,10 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
@Override
public void setStartingControllerAndTurnNum(Game game, UUID startingController, UUID activePlayerId) {
this.startingControllerId = startingController;
this.startingActivePlayerId = activePlayerId;
this.startingTurnWasActive = activePlayerId != null
&& activePlayerId.equals(startingController); // you can't use "game" for active player cause it's called from tests/cheat too
this.effectStartingOnTurn = game.getTurnNum();
this.effectStartingControllerEndStep = EndStepCountWatcher.getCount(startingController, game);
this.effectStartingActivePlayerEndStep = EndStepCountWatcher.getCount(activePlayerId, game);
this.effectStartingEndStep = EndStepCountWatcher.getCount(startingController, game);
this.effectStartingStepNum = game.getState().getStepNum();
}
@ -272,12 +266,7 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
@Override
public boolean isYourNextEndStep(Game game) {
return EndStepCountWatcher.getCount(startingControllerId, game) > effectStartingControllerEndStep;
}
@Override
public boolean isTheNextEndStep(Game game) {
return EndStepCountWatcher.getCount(startingActivePlayerId, game) > effectStartingActivePlayerEndStep;
return EndStepCountWatcher.getCount(startingControllerId, game) > effectStartingEndStep;
}
public boolean isEndCombatOfYourNextTurn(Game game) {
@ -302,14 +291,13 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
@Override
public boolean isInactive(Ability source, Game game) {
// YOUR turn checks, players who left the game, and the next end step
// YOUR turn checks, players who left the game
// until end of turn - must be checked on cleanup step, see rules 514.2
// other must checked here (active and leave players), see rules 800.4
switch (duration) {
case UntilYourNextTurn:
case UntilEndOfYourNextTurn:
case UntilYourNextEndStep:
case UntilTheNextEndStep:
case UntilEndCombatOfYourNextTurn:
case UntilYourNextUpkeepStep:
break;
@ -354,10 +342,6 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
return this.isYourNextEndStep(game);
}
break;
case UntilTheNextEndStep:
if (player != null && player.isInGame()) {
return this.isTheNextEndStep(game);
}
case UntilEndCombatOfYourNextTurn:
if (player != null && player.isInGame()) {
return this.isEndCombatOfYourNextTurn(game);