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
|
|
@ -1,7 +1,11 @@
|
|||
package mage.target.targetpointer;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author JayDi85
|
||||
|
|
@ -11,6 +15,8 @@ public abstract class TargetPointerImpl implements TargetPointer {
|
|||
// Store custom data here. Use it to keep unique values for ability instances on stack (example: Gruul Ragebeast)
|
||||
private Map<String, String> data;
|
||||
|
||||
private boolean initialized = false;
|
||||
|
||||
public TargetPointerImpl() {
|
||||
super();
|
||||
}
|
||||
|
|
@ -21,6 +27,17 @@ public abstract class TargetPointerImpl implements TargetPointer {
|
|||
this.data = new HashMap<>();
|
||||
this.data.putAll(targetPointer.data);
|
||||
}
|
||||
this.initialized = targetPointer.initialized;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInitialized() {
|
||||
return this.initialized;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInitialized() {
|
||||
this.initialized = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -39,4 +56,14 @@ public abstract class TargetPointerImpl implements TargetPointer {
|
|||
data.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final FixedTarget getFirstAsFixedTarget(Game game, Ability source) {
|
||||
UUID firstId = this.getFirst(game, source);
|
||||
if (firstId != null) {
|
||||
return new FixedTarget(firstId, game.getState().getZoneChangeCounter(firstId));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue