mirror of
https://github.com/magefree/mage.git
synced 2026-01-10 21:02:08 -08:00
changes to the way abilities are added to cards
This commit is contained in:
parent
65390e09a6
commit
72ff6f27b3
91 changed files with 2003 additions and 217 deletions
|
|
@ -86,6 +86,7 @@ public abstract class AbilityImpl implements Ability {
|
|||
|
||||
private static final transient Logger logger = Logger.getLogger(AbilityImpl.class);
|
||||
private static final List<Watcher> emptyWatchers = new ArrayList<>();
|
||||
private static final List<Ability> emptyAbilities = new ArrayList<>();
|
||||
|
||||
protected UUID id;
|
||||
protected UUID originalId;
|
||||
|
|
@ -110,6 +111,7 @@ public abstract class AbilityImpl implements Ability {
|
|||
protected boolean worksFaceDown = false;
|
||||
protected MageObject sourceObject;
|
||||
protected List<Watcher> watchers = null;
|
||||
protected List<Ability> subAbilities = null;
|
||||
|
||||
public AbilityImpl(AbilityType abilityType, Zone zone) {
|
||||
this.id = UUID.randomUUID();
|
||||
|
|
@ -145,6 +147,12 @@ public abstract class AbilityImpl implements Ability {
|
|||
watchers.add(watcher.copy());
|
||||
}
|
||||
}
|
||||
if (ability.subAbilities != null) {
|
||||
this.subAbilities = new ArrayList<>();
|
||||
for (Ability subAbility: ability.subAbilities) {
|
||||
subAbilities.add(subAbility.copy());
|
||||
}
|
||||
}
|
||||
this.modes = ability.modes.copy();
|
||||
this.ruleAtTheTop = ability.ruleAtTheTop;
|
||||
this.ruleVisible = ability.ruleVisible;
|
||||
|
|
@ -562,6 +570,11 @@ public abstract class AbilityImpl implements Ability {
|
|||
watcher.setControllerId(controllerId);
|
||||
}
|
||||
}
|
||||
if (subAbilities != null) {
|
||||
for (Ability subAbility: subAbilities) {
|
||||
subAbility.setControllerId(controllerId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -579,6 +592,11 @@ public abstract class AbilityImpl implements Ability {
|
|||
this.sourceId = sourceId;
|
||||
}
|
||||
}
|
||||
if (subAbilities != null) {
|
||||
for (Ability subAbility: subAbilities) {
|
||||
subAbility.setSourceId(sourceId);
|
||||
}
|
||||
}
|
||||
if (watchers != null) {
|
||||
for (Watcher watcher: watchers) {
|
||||
watcher.setSourceId(sourceId);
|
||||
|
|
@ -660,6 +678,23 @@ public abstract class AbilityImpl implements Ability {
|
|||
watchers.add(watcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Ability> getSubAbilities() {
|
||||
if (subAbilities != null)
|
||||
return subAbilities;
|
||||
else
|
||||
return emptyAbilities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSubAbility(Ability ability) {
|
||||
if (subAbilities == null)
|
||||
subAbilities = new ArrayList<>();
|
||||
ability.setSourceId(this.sourceId);
|
||||
ability.setControllerId(this.controllerId);
|
||||
subAbilities.add(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUsesStack() {
|
||||
return usesStack;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue