Skip to content

Commit

Permalink
Rename fields for 'until the beginning of the next end step' duration…
Browse files Browse the repository at this point in the history
…; update comment to reflect that 'until the next end step' happens before the cleanup step and 514.2 does not apply.
  • Loading branch information
Grath committed Sep 30, 2024
1 parent 4a432b6 commit a200351
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions Mage/src/main/java/mage/abilities/effects/ContinuousEffectImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ A Characteristic Defining Ability (CDA) is an ability that defines a characteris

// 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 activePlayerId; // Player whose turn the effect started on
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 effectControllerStartingEndStep = 0;
private int effectActivePlayerStartingEndStep = 0;
private int effectStartingControllerEndStep = 0;
private int effectStartingActivePlayerEndStep = 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.
Expand Down Expand Up @@ -93,9 +93,11 @@ protected ContinuousEffectImpl(final ContinuousEffectImpl effect) {
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.effectControllerStartingEndStep = effect.effectControllerStartingEndStep;
this.effectStartingControllerEndStep = effect.effectStartingControllerEndStep;
this.effectStartingActivePlayerEndStep = effect.effectStartingActivePlayerEndStep;
this.dependencyTypes = effect.dependencyTypes;
this.dependendToTypes = effect.dependendToTypes;
this.characterDefining = effect.characterDefining;
Expand Down Expand Up @@ -253,12 +255,12 @@ public UUID getStartingController() {
@Override
public void setStartingControllerAndTurnNum(Game game, UUID startingController, UUID activePlayerId) {
this.startingControllerId = startingController;
this.activePlayerId = activePlayerId;
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.effectControllerStartingEndStep = EndStepCountWatcher.getCount(startingController, game);
this.effectActivePlayerStartingEndStep = EndStepCountWatcher.getCount(activePlayerId, game);
this.effectStartingControllerEndStep = EndStepCountWatcher.getCount(startingController, game);
this.effectStartingActivePlayerEndStep = EndStepCountWatcher.getCount(activePlayerId, game);
this.effectStartingStepNum = game.getState().getStepNum();
}

Expand All @@ -270,12 +272,12 @@ public boolean isYourNextTurn(Game game) {

@Override
public boolean isYourNextEndStep(Game game) {
return EndStepCountWatcher.getCount(startingControllerId, game) > effectControllerStartingEndStep;
return EndStepCountWatcher.getCount(startingControllerId, game) > effectStartingControllerEndStep;
}

@Override
public boolean isTheNextEndStep(Game game) {
return EndStepCountWatcher.getCount(activePlayerId, game) > effectActivePlayerStartingEndStep;
return EndStepCountWatcher.getCount(startingActivePlayerId, game) > effectStartingActivePlayerEndStep;
}

public boolean isEndCombatOfYourNextTurn(Game game) {
Expand All @@ -300,7 +302,7 @@ public boolean isYourNextUpkeepStep(Game game) {

@Override
public boolean isInactive(Ability source, Game game) {
// YOUR turn checks
// YOUR turn checks, players who left the game, and the next end step
// 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) {
Expand Down

0 comments on commit a200351

Please sign in to comment.