mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 13:19:18 -08:00
Change Duration.UntilTheNextEndStep to statically end during the beginning of EndStep.
This commit is contained in:
parent
b1678036fa
commit
49bce836f9
6 changed files with 61 additions and 28 deletions
|
|
@ -74,8 +74,6 @@ public interface ContinuousEffect extends Effect {
|
|||
|
||||
boolean isYourNextEndStep(Game game);
|
||||
|
||||
boolean isTheNextEndStep(Game game);
|
||||
|
||||
boolean isYourNextUpkeepStep(Game game);
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -120,8 +120,8 @@ public class ContinuousEffects implements Serializable {
|
|||
preventionEffects.removeEndOfCombatEffects();
|
||||
requirementEffects.removeEndOfCombatEffects();
|
||||
restrictionEffects.removeEndOfCombatEffects();
|
||||
for (ContinuousEffectsList asThoughtlist : asThoughEffectsMap.values()) {
|
||||
asThoughtlist.removeEndOfCombatEffects();
|
||||
for (ContinuousEffectsList asThoughlist : asThoughEffectsMap.values()) {
|
||||
asThoughlist.removeEndOfCombatEffects();
|
||||
}
|
||||
costModificationEffects.removeEndOfCombatEffects();
|
||||
spliceCardEffects.removeEndOfCombatEffects();
|
||||
|
|
@ -134,13 +134,27 @@ public class ContinuousEffects implements Serializable {
|
|||
preventionEffects.removeEndOfTurnEffects(game);
|
||||
requirementEffects.removeEndOfTurnEffects(game);
|
||||
restrictionEffects.removeEndOfTurnEffects(game);
|
||||
for (ContinuousEffectsList asThoughtlist : asThoughEffectsMap.values()) {
|
||||
asThoughtlist.removeEndOfTurnEffects(game);
|
||||
for (ContinuousEffectsList asThoughlist : asThoughEffectsMap.values()) {
|
||||
asThoughlist.removeEndOfTurnEffects(game);
|
||||
}
|
||||
costModificationEffects.removeEndOfTurnEffects(game);
|
||||
spliceCardEffects.removeEndOfTurnEffects(game);
|
||||
}
|
||||
|
||||
public synchronized void removeBeginningOfEndStepEffects(Game game) {
|
||||
layeredEffects.removeBeginningOfEndStepEffects(game);
|
||||
continuousRuleModifyingEffects.removeBeginningOfEndStepEffects(game);
|
||||
replacementEffects.removeBeginningOfEndStepEffects(game);
|
||||
preventionEffects.removeBeginningOfEndStepEffects(game);
|
||||
requirementEffects.removeBeginningOfEndStepEffects(game);
|
||||
restrictionEffects.removeBeginningOfEndStepEffects(game);
|
||||
for (ContinuousEffectsList asThoughlist : asThoughEffectsMap.values()) {
|
||||
asThoughlist.removeBeginningOfEndStepEffects(game);
|
||||
}
|
||||
costModificationEffects.removeBeginningOfEndStepEffects(game);
|
||||
spliceCardEffects.removeBeginningOfEndStepEffects(game);
|
||||
}
|
||||
|
||||
public synchronized void removeInactiveEffects(Game game) {
|
||||
layeredEffects.removeInactiveEffects(game);
|
||||
continuousRuleModifyingEffects.removeInactiveEffects(game);
|
||||
|
|
|
|||
|
|
@ -71,6 +71,29 @@ public class ContinuousEffectsList<T extends ContinuousEffect> extends ArrayList
|
|||
}
|
||||
}
|
||||
|
||||
public void removeBeginningOfEndStepEffects(Game game) {
|
||||
// calls every turn on beginning of end step
|
||||
// rules 514.2
|
||||
for (Iterator<T> i = this.iterator(); i.hasNext(); ) {
|
||||
T entry = i.next();
|
||||
boolean canRemove;
|
||||
switch (entry.getDuration()) {
|
||||
case UntilTheNextEndStep:
|
||||
canRemove = true;
|
||||
break;
|
||||
case UntilYourNextEndStep:
|
||||
canRemove = entry.isYourNextEndStep(game);
|
||||
break;
|
||||
default:
|
||||
canRemove = false;
|
||||
}
|
||||
if (canRemove) {
|
||||
i.remove();
|
||||
effectAbilityMap.remove(entry.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removeEndOfCombatEffects() {
|
||||
for (Iterator<T> i = this.iterator(); i.hasNext(); ) {
|
||||
T entry = i.next();
|
||||
|
|
@ -156,7 +179,6 @@ public class ContinuousEffectsList<T extends ContinuousEffect> extends ArrayList
|
|||
case UntilEndOfYourNextTurn:
|
||||
case UntilEndCombatOfYourNextTurn:
|
||||
case UntilYourNextEndStep:
|
||||
case UntilTheNextEndStep:
|
||||
case UntilYourNextUpkeepStep:
|
||||
// until your turn effects continue until real turn reached, their used it's own inactive method
|
||||
// 514.2 Second, the following actions happen simultaneously: all damage marked on permanents
|
||||
|
|
@ -170,6 +192,7 @@ public class ContinuousEffectsList<T extends ContinuousEffect> extends ArrayList
|
|||
}
|
||||
break;
|
||||
case EndOfTurn:
|
||||
case UntilTheNextEndStep:
|
||||
// end of turn discards on cleanup steps
|
||||
// 514.2
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -692,6 +692,11 @@ public class GameState implements Serializable, Copyable<GameState> {
|
|||
game.applyEffects();
|
||||
}
|
||||
|
||||
// remove beginning of end step effects
|
||||
public void removeBoESEffects(Game game) {
|
||||
effects.removeBeginningOfEndStepEffects(game);
|
||||
}
|
||||
|
||||
public void removeTurnStartEffect(Game game) {
|
||||
delayed.removeStartOfNewTurn(game);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,11 @@
|
|||
package mage.game.turn;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
|
|
@ -26,4 +29,10 @@ public class EndStep extends Step {
|
|||
return new EndStep(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beginStep(Game game, UUID activePlayerId) {
|
||||
super.beginStep(game, activePlayerId);
|
||||
|
||||
game.getState().removeBoESEffects(game);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue