mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
* Cleaned up FixedTargets MageObjectReference handling.
This commit is contained in:
parent
f6ad6b37c2
commit
309d4685e8
2 changed files with 14 additions and 8 deletions
|
@ -47,7 +47,7 @@ public class MageObjectReference implements Comparable<MageObjectReference>, Ser
|
|||
private static final Logger logger = Logger.getLogger(MageObjectReference.class);
|
||||
|
||||
private final UUID sourceId;
|
||||
private int zoneChangeCounter;
|
||||
private final int zoneChangeCounter;
|
||||
|
||||
public MageObjectReference(MageObject mageObject, Game game) {
|
||||
this.sourceId = mageObject.getId();
|
||||
|
@ -167,8 +167,4 @@ public class MageObjectReference implements Comparable<MageObjectReference>, Ser
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setZoneChangeCounter(int zoneChangeCounter) {
|
||||
this.zoneChangeCounter = zoneChangeCounter;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,10 +21,12 @@ import mage.game.permanent.Permanent;
|
|||
public class FixedTargets implements TargetPointer {
|
||||
|
||||
final ArrayList<MageObjectReference> targets = new ArrayList<>();
|
||||
final ArrayList<UUID> targetsNotInitialized = new ArrayList<>();
|
||||
|
||||
private boolean initialized;
|
||||
|
||||
public FixedTargets(UUID targetId) {
|
||||
targets.add(new MageObjectReference(targetId));
|
||||
targetsNotInitialized.add(targetId);
|
||||
this.initialized = false;
|
||||
}
|
||||
|
||||
|
@ -46,6 +48,7 @@ public class FixedTargets implements TargetPointer {
|
|||
|
||||
private FixedTargets(final FixedTargets fixedTargets) {
|
||||
this.targets.addAll(fixedTargets.targets);
|
||||
this.targetsNotInitialized.addAll(fixedTargets.targetsNotInitialized);
|
||||
this.initialized = fixedTargets.initialized;
|
||||
}
|
||||
|
||||
|
@ -53,8 +56,8 @@ public class FixedTargets implements TargetPointer {
|
|||
public void init(Game game, Ability source) {
|
||||
if (!initialized) {
|
||||
initialized = true;
|
||||
for (MageObjectReference mor : targets) {
|
||||
mor.setZoneChangeCounter(game.getState().getZoneChangeCounter(mor.getSourceId()));
|
||||
for (UUID targetId : targetsNotInitialized) {
|
||||
targets.add(new MageObjectReference(targetId, game.getState().getZoneChangeCounter(targetId), game));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -87,6 +90,13 @@ public class FixedTargets implements TargetPointer {
|
|||
return new FixedTargets(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a fixed target for (and only) the first taget
|
||||
*
|
||||
* @param game
|
||||
* @param source
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public FixedTarget getFixedTarget(Game game, Ability source) {
|
||||
this.init(game, source);
|
||||
|
|
Loading…
Reference in a new issue