forked from External/mage
Refactored Target pointers. All tests pass now.
This commit is contained in:
parent
13f547f1a2
commit
12954eceee
138 changed files with 259 additions and 182 deletions
|
|
@ -1,6 +1,8 @@
|
|||
package mage.target.targetpointer;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.cards.Card;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -8,6 +10,7 @@ import java.util.UUID;
|
|||
|
||||
public class FixedTarget implements TargetPointer {
|
||||
private UUID target;
|
||||
private int zoneChangeCounter;
|
||||
|
||||
public FixedTarget(UUID target) {
|
||||
this.target = target;
|
||||
|
|
@ -15,17 +18,42 @@ public class FixedTarget implements TargetPointer {
|
|||
|
||||
public FixedTarget(final FixedTarget fixedTarget) {
|
||||
this.target = fixedTarget.target;
|
||||
this.zoneChangeCounter = fixedTarget.zoneChangeCounter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UUID> getTargets(Ability source) {
|
||||
public void init(Game game, Ability source) {
|
||||
Card card = game.getCard(target);
|
||||
if (card != null) {
|
||||
this.zoneChangeCounter = card.getZoneChangeCounter();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UUID> getTargets(Game game, Ability source) {
|
||||
// check target not changed zone
|
||||
if (this.zoneChangeCounter > 0) { // will be zero if not defined in init
|
||||
Card card = game.getCard(target);
|
||||
if (card != null && card.getZoneChangeCounter() != this.zoneChangeCounter) {
|
||||
return new ArrayList<UUID>(); // return empty
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<UUID> list = new ArrayList<UUID>(1);
|
||||
list.add(target);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getFirst(Ability source) {
|
||||
public UUID getFirst(Game game, Ability source) {
|
||||
// check target not changed zone
|
||||
if (this.zoneChangeCounter > 0) { // will be zero if not defined in init
|
||||
Card card = game.getCard(target);
|
||||
if (card != null && card.getZoneChangeCounter() != this.zoneChangeCounter) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue