forked from External/mage
multiple changes:
* refactor: improved target pointer init code and logic, added docs and runtime checks; * game: fixed miss or wrong init calls in some continuous effects; * game: fixed wrong usage of target pointers (miss copy code, miss npe checks);
This commit is contained in:
parent
b2aa4ecc08
commit
78612ddc91
115 changed files with 466 additions and 355 deletions
|
|
@ -21,6 +21,8 @@ public abstract class EffectImpl implements Effect {
|
|||
protected EffectType effectType;
|
||||
|
||||
// read related docs about static and dynamic targets in ContinuousEffectImpl.affectedObjectsSet
|
||||
// warning, do not change it directly, use setTargetPointer instead
|
||||
// TODO: make it private and replace all usage to getTargetPointer
|
||||
protected TargetPointer targetPointer = new FirstTargetPointer();
|
||||
|
||||
protected String staticText = "";
|
||||
|
|
@ -30,6 +32,8 @@ public abstract class EffectImpl implements Effect {
|
|||
public EffectImpl(Outcome outcome) {
|
||||
this.id = UUID.randomUUID();
|
||||
this.outcome = outcome;
|
||||
|
||||
initNewTargetPointer();
|
||||
}
|
||||
|
||||
protected EffectImpl(final EffectImpl effect) {
|
||||
|
|
@ -48,6 +52,11 @@ public abstract class EffectImpl implements Effect {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Init target pointer by default (see TargetPointer for details)
|
||||
*/
|
||||
abstract public void initNewTargetPointer();
|
||||
|
||||
@Override
|
||||
public UUID getId() {
|
||||
return id;
|
||||
|
|
@ -81,7 +90,13 @@ public abstract class EffectImpl implements Effect {
|
|||
|
||||
@Override
|
||||
public Effect setTargetPointer(TargetPointer targetPointer) {
|
||||
if (targetPointer == null) {
|
||||
// first target pointer is default
|
||||
throw new IllegalArgumentException("Wrong code usage: target pointer can't be set to null: " + this);
|
||||
}
|
||||
|
||||
this.targetPointer = targetPointer;
|
||||
initNewTargetPointer();
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue