mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
add targets pointer
This commit is contained in:
parent
52b4858f99
commit
0b10a3a121
4 changed files with 53 additions and 1 deletions
|
@ -32,6 +32,8 @@ import java.util.UUID;
|
|||
import mage.Constants.EffectType;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.abilities.Ability;
|
||||
import mage.target.targetpointer.FirstTargetPointer;
|
||||
import mage.target.targetpointer.TargetPointer;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -42,6 +44,7 @@ public abstract class EffectImpl<T extends Effect<T>> implements Effect<T> {
|
|||
protected UUID id;
|
||||
protected final Outcome outcome;
|
||||
protected EffectType effectType;
|
||||
protected TargetPointer targetPointer = FirstTargetPointer.getInstance();
|
||||
protected String staticText = "";
|
||||
|
||||
public EffectImpl(Outcome outcome) {
|
||||
|
@ -54,6 +57,7 @@ public abstract class EffectImpl<T extends Effect<T>> implements Effect<T> {
|
|||
this.outcome = effect.outcome;
|
||||
this.effectType = effect.effectType;
|
||||
this.staticText = effect.staticText;
|
||||
this.targetPointer = effect.targetPointer.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -87,4 +91,8 @@ public abstract class EffectImpl<T extends Effect<T>> implements Effect<T> {
|
|||
public EffectType getEffectType() {
|
||||
return effectType;
|
||||
}
|
||||
|
||||
public void setTargetPointer(TargetPointer targetPointer) {
|
||||
this.targetPointer = targetPointer;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ public class AddPoisonCounterTargetEffect extends OneShotEffect<AddPoisonCounter
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getFirstTarget());
|
||||
Player player = game.getPlayer(targetPointer.getFirst(source));
|
||||
if (player != null) {
|
||||
player.getCounters().addCounter(CounterType.POISON.createInstance(amount));
|
||||
return true;
|
||||
|
|
32
Mage/src/mage/target/targetpointer/FirstTargetPointer.java
Normal file
32
Mage/src/mage/target/targetpointer/FirstTargetPointer.java
Normal file
|
@ -0,0 +1,32 @@
|
|||
package mage.target.targetpointer;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FirstTargetPointer implements TargetPointer {
|
||||
private static FirstTargetPointer instance = new FirstTargetPointer();
|
||||
|
||||
public static FirstTargetPointer getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UUID> getTargets(Ability source) {
|
||||
ArrayList<UUID> target = new ArrayList<UUID>();
|
||||
target.add(source.getFirstTarget());
|
||||
return target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getFirst(Ability source) {
|
||||
return source.getFirstTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetPointer copy() {
|
||||
return instance;
|
||||
}
|
||||
}
|
12
Mage/src/mage/target/targetpointer/TargetPointer.java
Normal file
12
Mage/src/mage/target/targetpointer/TargetPointer.java
Normal file
|
@ -0,0 +1,12 @@
|
|||
package mage.target.targetpointer;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface TargetPointer {
|
||||
List<UUID> getTargets(Ability source);
|
||||
UUID getFirst(Ability source);
|
||||
TargetPointer copy();
|
||||
}
|
Loading…
Reference in a new issue