mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +00:00
a list that is null is just strange, just use an empty List
This commit is contained in:
parent
e205fef785
commit
ad8b046b05
1 changed files with 13 additions and 23 deletions
|
@ -27,10 +27,6 @@
|
||||||
*/
|
*/
|
||||||
package mage.abilities;
|
package mage.abilities;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.MageObjectReference;
|
import mage.MageObjectReference;
|
||||||
import mage.Mana;
|
import mage.Mana;
|
||||||
|
@ -63,6 +59,11 @@ import mage.util.ThreadLocalStringBuilder;
|
||||||
import mage.watchers.Watcher;
|
import mage.watchers.Watcher;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
|
@ -70,7 +71,6 @@ public abstract class AbilityImpl implements Ability {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(AbilityImpl.class);
|
private static final Logger logger = Logger.getLogger(AbilityImpl.class);
|
||||||
private static final ThreadLocalStringBuilder threadLocalBuilder = new ThreadLocalStringBuilder(100);
|
private static final ThreadLocalStringBuilder threadLocalBuilder = new ThreadLocalStringBuilder(100);
|
||||||
private static final List<Watcher> emptyWatchers = new ArrayList<>();
|
|
||||||
private static final List<Ability> emptyAbilities = new ArrayList<>();
|
private static final List<Ability> emptyAbilities = new ArrayList<>();
|
||||||
|
|
||||||
protected UUID id;
|
protected UUID id;
|
||||||
|
@ -95,7 +95,7 @@ public abstract class AbilityImpl implements Ability {
|
||||||
protected boolean worksFaceDown = false;
|
protected boolean worksFaceDown = false;
|
||||||
protected MageObject sourceObject;
|
protected MageObject sourceObject;
|
||||||
protected int sourceObjectZoneChangeCounter;
|
protected int sourceObjectZoneChangeCounter;
|
||||||
protected List<Watcher> watchers = null;
|
protected List<Watcher> watchers = new ArrayList<>();
|
||||||
protected List<Ability> subAbilities = null;
|
protected List<Ability> subAbilities = null;
|
||||||
protected boolean canFizzle = true;
|
protected boolean canFizzle = true;
|
||||||
protected TargetAdjustment targetAdjustment = TargetAdjustment.NONE;
|
protected TargetAdjustment targetAdjustment = TargetAdjustment.NONE;
|
||||||
|
@ -125,12 +125,10 @@ public abstract class AbilityImpl implements Ability {
|
||||||
this.manaCostsToPay = ability.manaCostsToPay.copy();
|
this.manaCostsToPay = ability.manaCostsToPay.copy();
|
||||||
this.costs = ability.costs.copy();
|
this.costs = ability.costs.copy();
|
||||||
this.optionalCosts = ability.optionalCosts.copy();
|
this.optionalCosts = ability.optionalCosts.copy();
|
||||||
if (ability.watchers != null) {
|
for (Watcher watcher : ability.watchers) {
|
||||||
this.watchers = new ArrayList<>();
|
watchers.add(watcher.copy());
|
||||||
for (Watcher watcher : ability.watchers) {
|
|
||||||
watchers.add(watcher.copy());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ability.subAbilities != null) {
|
if (ability.subAbilities != null) {
|
||||||
this.subAbilities = new ArrayList<>();
|
this.subAbilities = new ArrayList<>();
|
||||||
for (Ability subAbility : ability.subAbilities) {
|
for (Ability subAbility : ability.subAbilities) {
|
||||||
|
@ -623,11 +621,10 @@ public abstract class AbilityImpl implements Ability {
|
||||||
@Override
|
@Override
|
||||||
public void setControllerId(UUID controllerId) {
|
public void setControllerId(UUID controllerId) {
|
||||||
this.controllerId = controllerId;
|
this.controllerId = controllerId;
|
||||||
if (watchers != null) {
|
|
||||||
for (Watcher watcher : watchers) {
|
for (Watcher watcher : watchers) {
|
||||||
watcher.setControllerId(controllerId);
|
watcher.setControllerId(controllerId);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (subAbilities != null) {
|
if (subAbilities != null) {
|
||||||
for (Ability subAbility : subAbilities) {
|
for (Ability subAbility : subAbilities) {
|
||||||
subAbility.setControllerId(controllerId);
|
subAbility.setControllerId(controllerId);
|
||||||
|
@ -652,11 +649,10 @@ public abstract class AbilityImpl implements Ability {
|
||||||
subAbility.setSourceId(sourceId);
|
subAbility.setSourceId(sourceId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (watchers != null) {
|
|
||||||
for (Watcher watcher : watchers) {
|
for (Watcher watcher : watchers) {
|
||||||
watcher.setSourceId(sourceId);
|
watcher.setSourceId(sourceId);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -718,18 +714,12 @@ public abstract class AbilityImpl implements Ability {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Watcher> getWatchers() {
|
public List<Watcher> getWatchers() {
|
||||||
if (watchers != null) {
|
return watchers;
|
||||||
return watchers;
|
|
||||||
} else {
|
|
||||||
return emptyWatchers;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addWatcher(Watcher watcher) {
|
public void addWatcher(Watcher watcher) {
|
||||||
if (watchers == null) {
|
|
||||||
watchers = new ArrayList<>();
|
|
||||||
}
|
|
||||||
watcher.setSourceId(this.sourceId);
|
watcher.setSourceId(this.sourceId);
|
||||||
watcher.setControllerId(this.controllerId);
|
watcher.setControllerId(this.controllerId);
|
||||||
watchers.add(watcher);
|
watchers.add(watcher);
|
||||||
|
|
Loading…
Reference in a new issue