1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-03-29 17:00:07 -09:00

Additional watchers fixes for , see comments in f21151bca5

This commit is contained in:
Oleg Agafonov 2019-12-06 21:02:41 +04:00
parent 97f066a31a
commit a8d707b469
3 changed files with 35 additions and 11 deletions

View file

@ -58,7 +58,7 @@ public abstract class AbilityImpl implements Ability {
protected ManaCosts<ManaCost> manaCostsToPay;
protected Costs<Cost> costs;
protected Costs<Cost> optionalCosts;
protected Modes modes;
protected Modes modes; // access to it by GetModes only (it's can be override by some abilities)
protected Zone zone;
protected String name;
protected AbilityWord abilityWord;
@ -70,7 +70,7 @@ public abstract class AbilityImpl implements Ability {
protected boolean activated = false;
protected boolean worksFaceDown = false;
protected int sourceObjectZoneChangeCounter;
protected List<Watcher> watchers = new ArrayList<>();
protected List<Watcher> watchers = new ArrayList<>(); // access to it by GetWatchers only (it's can be override by some abilities)
protected List<Ability> subAbilities = null;
protected boolean canFizzle = true;
protected TargetAdjuster targetAdjuster = null;
@ -102,7 +102,7 @@ public abstract class AbilityImpl implements Ability {
this.manaCostsToPay = ability.manaCostsToPay.copy();
this.costs = ability.costs.copy();
this.optionalCosts = ability.optionalCosts.copy();
for (Watcher watcher : ability.watchers) {
for (Watcher watcher : ability.getWatchers()) {
watchers.add(watcher.copy());
}
@ -263,8 +263,9 @@ public abstract class AbilityImpl implements Ability {
this.getManaCostsToPay().clear();
}
}
if (modes.getAdditionalCost() != null) {
modes.getAdditionalCost().addOptionalAdditionalModeCosts(this, game);
if (getModes().getAdditionalCost() != null) {
getModes().getAdditionalCost().addOptionalAdditionalModeCosts(this, game);
}
// 20130201 - 601.2b
// If the spell has alternative or additional costs that will be paid as it's being cast such
@ -656,7 +657,7 @@ public abstract class AbilityImpl implements Ability {
@Override
public void setControllerId(UUID controllerId) {
this.controllerId = controllerId;
for (Watcher watcher : watchers) {
for (Watcher watcher : getWatchers()) {
watcher.setControllerId(controllerId);
}
@ -684,7 +685,7 @@ public abstract class AbilityImpl implements Ability {
subAbility.setSourceId(sourceId);
}
}
for (Watcher watcher : watchers) {
for (Watcher watcher : getWatchers()) {
watcher.setSourceId(sourceId);
}
@ -757,7 +758,7 @@ public abstract class AbilityImpl implements Ability {
watcher.setSourceId(this.sourceId);
watcher.setControllerId(this.controllerId);
watchers.add(watcher);
getWatchers().add(watcher);
}
@Override

View file

@ -9,6 +9,9 @@ import mage.abilities.effects.Effects;
import mage.constants.EffectType;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.watchers.Watcher;
import java.util.List;
/**
* Adds condition to {@link mage.abilities.effects.ContinuousEffect}. Acts as
@ -37,7 +40,6 @@ public class ConditionalInterveningIfTriggeredAbility extends TriggeredAbilityIm
this.modes = ability.getModes();
this.condition = condition;
this.abilityText = text;
this.watchers = ability.getWatchers();
}
public ConditionalInterveningIfTriggeredAbility(final ConditionalInterveningIfTriggeredAbility triggered) {
@ -45,7 +47,6 @@ public class ConditionalInterveningIfTriggeredAbility extends TriggeredAbilityIm
this.ability = triggered.ability.copy();
this.condition = triggered.condition;
this.abilityText = triggered.abilityText;
this.watchers = triggered.watchers;
}
@Override
@ -93,6 +94,16 @@ public class ConditionalInterveningIfTriggeredAbility extends TriggeredAbilityIm
return ability.getModes();
}
@Override
public List<Watcher> getWatchers() {
return ability.getWatchers();
}
@Override
public void addWatcher(Watcher watcher) {
ability.addWatcher(watcher);
}
@Override
public Effects getEffects(Game game, EffectType effectType) {
return ability.getEffects(game, effectType);

View file

@ -9,6 +9,9 @@ import mage.abilities.effects.Effects;
import mage.constants.EffectType;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.watchers.Watcher;
import java.util.List;
/**
* Adds condition to {@link mage.abilities.effects.ContinuousEffect}. Acts as
@ -34,7 +37,6 @@ public class ConditionalTriggeredAbility extends TriggeredAbilityImpl {
public ConditionalTriggeredAbility(TriggeredAbility ability, Condition condition, String text) {
super(ability.getZone(), null);
this.ability = ability;
this.modes = ability.getModes();
this.condition = condition;
this.abilityText = text;
}
@ -86,6 +88,16 @@ public class ConditionalTriggeredAbility extends TriggeredAbilityImpl {
return ability.getModes();
}
@Override
public List<Watcher> getWatchers() {
return ability.getWatchers();
}
@Override
public void addWatcher(Watcher watcher) {
ability.addWatcher(watcher);
}
@Override
public Effects getEffects(Game game, EffectType effectType) {
return ability.getEffects(game, effectType);