forked from External/mage
moved Watchers to Ability and moved Counters to CardState
This commit is contained in:
parent
620a3b9a52
commit
632573fc3e
204 changed files with 1516 additions and 347 deletions
|
|
@ -75,6 +75,7 @@ import mage.game.stack.StackAbility;
|
|||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.Targets;
|
||||
import mage.watchers.Watcher;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
|
|
@ -84,6 +85,7 @@ import org.apache.log4j.Logger;
|
|||
public abstract class AbilityImpl implements Ability {
|
||||
|
||||
private static final transient Logger logger = Logger.getLogger(AbilityImpl.class);
|
||||
private static final List<Watcher> emptyWatchers = new ArrayList<>();
|
||||
|
||||
protected UUID id;
|
||||
protected UUID originalId;
|
||||
|
|
@ -107,6 +109,7 @@ public abstract class AbilityImpl implements Ability {
|
|||
protected boolean activated = false;
|
||||
protected boolean worksFaceDown = false;
|
||||
protected MageObject sourceObject;
|
||||
protected List<Watcher> watchers = null;
|
||||
|
||||
public AbilityImpl(AbilityType abilityType, Zone zone) {
|
||||
this.id = UUID.randomUUID();
|
||||
|
|
@ -136,6 +139,12 @@ public abstract class AbilityImpl implements Ability {
|
|||
for (AlternativeCost cost: ability.alternativeCosts) {
|
||||
this.alternativeCosts.add((AlternativeCost)cost.copy());
|
||||
}
|
||||
if (ability.watchers != null) {
|
||||
this.watchers = new ArrayList<>();
|
||||
for (Watcher watcher: ability.watchers) {
|
||||
watchers.add(watcher.copy());
|
||||
}
|
||||
}
|
||||
this.modes = ability.modes.copy();
|
||||
this.ruleAtTheTop = ability.ruleAtTheTop;
|
||||
this.ruleVisible = ability.ruleVisible;
|
||||
|
|
@ -548,6 +557,11 @@ public abstract class AbilityImpl implements Ability {
|
|||
@Override
|
||||
public void setControllerId(UUID controllerId) {
|
||||
this.controllerId = controllerId;
|
||||
if (watchers != null) {
|
||||
for (Watcher watcher: watchers) {
|
||||
watcher.setControllerId(controllerId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -565,6 +579,11 @@ public abstract class AbilityImpl implements Ability {
|
|||
this.sourceId = sourceId;
|
||||
}
|
||||
}
|
||||
if (watchers != null) {
|
||||
for (Watcher watcher: watchers) {
|
||||
watcher.setSourceId(sourceId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -624,6 +643,23 @@ public abstract class AbilityImpl implements Ability {
|
|||
return zone;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Watcher> getWatchers() {
|
||||
if (watchers != null)
|
||||
return watchers;
|
||||
else
|
||||
return emptyWatchers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addWatcher(Watcher watcher) {
|
||||
if (watchers == null)
|
||||
watchers = new ArrayList<>();
|
||||
watcher.setSourceId(this.sourceId);
|
||||
watcher.setControllerId(this.controllerId);
|
||||
watchers.add(watcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUsesStack() {
|
||||
return usesStack;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue