mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 12:02:01 -08:00
updating target methods - not finished yet
This commit is contained in:
parent
fb865de08b
commit
4ba0cab17a
12 changed files with 293 additions and 11 deletions
|
|
@ -67,7 +67,7 @@ public class DiscardTargetCost extends CostImpl<DiscardTargetCost> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPay(UUID sourceId, UUID controllerId, Game game) {
|
public boolean canPay(UUID sourceId, UUID controllerId, Game game) {
|
||||||
return targets.canChoose(controllerId, controllerId, game);
|
return targets.canChoose(controllerId, game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ public class SacrificeTargetCost extends CostImpl<SacrificeTargetCost> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPay(UUID sourceId, UUID controllerId, Game game) {
|
public boolean canPay(UUID sourceId, UUID controllerId, Game game) {
|
||||||
return targets.canChoose(controllerId, controllerId, game);
|
return targets.canChoose(controllerId, game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -48,21 +48,28 @@ public interface Target extends Serializable {
|
||||||
public boolean doneChosing();
|
public boolean doneChosing();
|
||||||
public void clearChosen();
|
public void clearChosen();
|
||||||
public boolean isNotTarget();
|
public boolean isNotTarget();
|
||||||
|
|
||||||
|
// methods for targets
|
||||||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game);
|
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game);
|
||||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game);
|
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game);
|
||||||
public boolean choose(Outcome outcome, UUID playerId, Game game);
|
|
||||||
public boolean chooseTarget(Outcome outcome, UUID playerId, Ability source, Game game);
|
public boolean chooseTarget(Outcome outcome, UUID playerId, Ability source, Game game);
|
||||||
|
public void addTarget(UUID id, Ability source, Game game);
|
||||||
|
public void addTarget(UUID id, int amount, Ability source, Game game);
|
||||||
|
public boolean canTarget(UUID id, Game game);
|
||||||
|
public boolean canTarget(UUID id, Ability source, Game game);
|
||||||
|
public boolean isLegal(Ability source, Game game);
|
||||||
|
|
||||||
|
//methods for non-targets
|
||||||
|
public boolean canChoose(UUID sourceControllerId, Game game);
|
||||||
|
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game);
|
||||||
|
public boolean choose(Outcome outcome, UUID playerId, Game game);
|
||||||
|
public void add(UUID id, Game game);
|
||||||
|
|
||||||
public String getMessage();
|
public String getMessage();
|
||||||
public String getTargetName();
|
public String getTargetName();
|
||||||
public void setTargetName(String name);
|
public void setTargetName(String name);
|
||||||
public String getTargetedName(Game game);
|
public String getTargetedName(Game game);
|
||||||
public Zone getZone();
|
public Zone getZone();
|
||||||
public boolean isLegal(Ability source, Game game);
|
|
||||||
public boolean canTarget(UUID id, Game game);
|
|
||||||
public boolean canTarget(UUID id, Ability source, Game game);
|
|
||||||
public void add(UUID id, Game game);
|
|
||||||
public void addTarget(UUID id, Ability source, Game game);
|
|
||||||
public void addTarget(UUID id, int amount, Ability source, Game game);
|
|
||||||
|
|
||||||
public int getTargetAmount(UUID targetId);
|
public int getTargetAmount(UUID targetId);
|
||||||
public int getNumberOfTargets();
|
public int getNumberOfTargets();
|
||||||
|
|
|
||||||
|
|
@ -76,8 +76,28 @@ public class TargetCard<T extends TargetCard<T>> extends TargetObject<TargetCard
|
||||||
return this.filter;
|
return this.filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if there are enough {@link Card} that can be chosen.
|
||||||
|
*
|
||||||
|
* @param sourceId - the target event source
|
||||||
|
* @param sourceControllerId - controller of the target event source
|
||||||
|
* @param game
|
||||||
|
* @return - true if enough valid {@link Card} exist
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||||
|
return canChoose(sourceControllerId, game);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if there are enough {@link Card} that can be selected.
|
||||||
|
*
|
||||||
|
* @param sourceControllerId - controller of the select event
|
||||||
|
* @param game
|
||||||
|
* @return - true if enough valid {@link Card} exist
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean canChoose(UUID sourceControllerId, Game game) {
|
||||||
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||||
if (filter.matchOwner(playerId)) {
|
if (filter.matchOwner(playerId)) {
|
||||||
Player player = game.getPlayer(playerId);
|
Player player = game.getPlayer(playerId);
|
||||||
|
|
@ -104,6 +124,11 @@ public class TargetCard<T extends TargetCard<T>> extends TargetObject<TargetCard
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||||
|
return possibleTargets(sourceControllerId, game);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
|
||||||
Set<UUID> possibleTargets = new HashSet<UUID>();
|
Set<UUID> possibleTargets = new HashSet<UUID>();
|
||||||
Player player = game.getPlayer(sourceControllerId);
|
Player player = game.getPlayer(sourceControllerId);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,15 @@ public class TargetPermanent<T extends TargetPermanent<T>> extends TargetObject<
|
||||||
return this.filter;
|
return this.filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if there are enough {@link Permanent} that can be chosen. Should only be used
|
||||||
|
* for Ability targets since this checks for protection, shroud etc.
|
||||||
|
*
|
||||||
|
* @param sourceId - the target event source
|
||||||
|
* @param sourceControllerId - controller of the target event source
|
||||||
|
* @param game
|
||||||
|
* @return - true if enough valid {@link Permanent} exist
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
@ -108,6 +117,19 @@ public class TargetPermanent<T extends TargetPermanent<T>> extends TargetObject<
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if there are enough {@link Permanent} that can be selected. Should not be used
|
||||||
|
* for Ability targets since this does not check for protection, shroud etc.
|
||||||
|
*
|
||||||
|
* @param sourceControllerId - controller of the select event
|
||||||
|
* @param game
|
||||||
|
* @return - true if enough valid {@link Permanent} exist
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean canChoose(UUID sourceControllerId, Game game) {
|
||||||
|
return game.getBattlefield().count(filter, sourceControllerId, game) >= this.minNumberOfTargets;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||||
Set<UUID> possibleTargets = new HashSet<UUID>();
|
Set<UUID> possibleTargets = new HashSet<UUID>();
|
||||||
|
|
@ -120,6 +142,15 @@ public class TargetPermanent<T extends TargetPermanent<T>> extends TargetObject<
|
||||||
return possibleTargets;
|
return possibleTargets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
|
||||||
|
Set<UUID> possibleTargets = new HashSet<UUID>();
|
||||||
|
for (Permanent permanent: game.getBattlefield().getActivePermanents(filter, sourceControllerId, game)) {
|
||||||
|
possibleTargets.add(permanent.getId());
|
||||||
|
}
|
||||||
|
return possibleTargets;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TargetPermanent copy() {
|
public TargetPermanent copy() {
|
||||||
return new TargetPermanent(this);
|
return new TargetPermanent(this);
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,15 @@ public class TargetPlayer<T extends TargetPlayer<T>> extends TargetImpl<TargetPl
|
||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if there are enough {@link Player} that can be chosen. Should only be used
|
||||||
|
* for Ability targets since this checks for protection, shroud etc.
|
||||||
|
*
|
||||||
|
* @param sourceId - the target event source
|
||||||
|
* @param sourceControllerId - controller of the target event source
|
||||||
|
* @param game
|
||||||
|
* @return - true if enough valid {@link Player} exist
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
@ -87,6 +96,28 @@ public class TargetPlayer<T extends TargetPlayer<T>> extends TargetImpl<TargetPl
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if there are enough {@link Player} that can be selected. Should not be used
|
||||||
|
* for Ability targets since this does not check for protection, shroud etc.
|
||||||
|
*
|
||||||
|
* @param sourceControllerId - controller of the select event
|
||||||
|
* @param game
|
||||||
|
* @return - true if enough valid {@link Player} exist
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean canChoose(UUID sourceControllerId, Game game) {
|
||||||
|
int count = 0;
|
||||||
|
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||||
|
Player player = game.getPlayer(playerId);
|
||||||
|
if (player != null && !player.hasLeft() && filter.match(player)) {
|
||||||
|
count++;
|
||||||
|
if (count >= this.minNumberOfTargets)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||||
Set<UUID> possibleTargets = new HashSet<UUID>();
|
Set<UUID> possibleTargets = new HashSet<UUID>();
|
||||||
|
|
@ -101,6 +132,18 @@ public class TargetPlayer<T extends TargetPlayer<T>> extends TargetImpl<TargetPl
|
||||||
return possibleTargets;
|
return possibleTargets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
|
||||||
|
Set<UUID> possibleTargets = new HashSet<UUID>();
|
||||||
|
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||||
|
Player player = game.getPlayer(playerId);
|
||||||
|
if (player != null && !player.hasLeft() && filter.match(player)) {
|
||||||
|
possibleTargets.add(playerId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return possibleTargets;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isLegal(Ability source, Game game) {
|
public boolean isLegal(Ability source, Game game) {
|
||||||
for (UUID playerId: targets.keySet()) {
|
for (UUID playerId: targets.keySet()) {
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,11 @@ public class TargetSpell extends TargetObject<TargetSpell> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||||
|
return canChoose(sourceControllerId, game);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canChoose(UUID sourceControllerId, Game game) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (StackObject stackObject: game.getStack()) {
|
for (StackObject stackObject: game.getStack()) {
|
||||||
if (stackObject instanceof Spell && game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId()) && filter.match((Spell)stackObject)) {
|
if (stackObject instanceof Spell && game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId()) && filter.match((Spell)stackObject)) {
|
||||||
|
|
@ -100,6 +105,11 @@ public class TargetSpell extends TargetObject<TargetSpell> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||||
|
return possibleTargets(sourceControllerId, game);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
|
||||||
Set<UUID> possibleTargets = new HashSet<UUID>();
|
Set<UUID> possibleTargets = new HashSet<UUID>();
|
||||||
for (StackObject stackObject: game.getStack()) {
|
for (StackObject stackObject: game.getStack()) {
|
||||||
if (stackObject instanceof Spell && game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId()) && filter.match((Spell)stackObject)) {
|
if (stackObject instanceof Spell && game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId()) && filter.match((Spell)stackObject)) {
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,11 @@ public class TargetStackObject extends TargetObject<TargetStackObject> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||||
|
return canChoose(sourceControllerId, game);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canChoose(UUID sourceControllerId, Game game) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (StackObject stackObject: game.getStack()) {
|
for (StackObject stackObject: game.getStack()) {
|
||||||
if (game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId()) && filter.match(stackObject)) {
|
if (game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId()) && filter.match(stackObject)) {
|
||||||
|
|
@ -99,6 +104,11 @@ public class TargetStackObject extends TargetObject<TargetStackObject> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||||
|
return possibleTargets(sourceControllerId, game);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
|
||||||
Set<UUID> possibleTargets = new HashSet<UUID>();
|
Set<UUID> possibleTargets = new HashSet<UUID>();
|
||||||
for (StackObject stackObject: game.getStack()) {
|
for (StackObject stackObject: game.getStack()) {
|
||||||
if (game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId()) && filter.match(stackObject)) {
|
if (game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId()) && filter.match(stackObject)) {
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ public class Targets extends ArrayList<Target> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean choose(Outcome outcome, UUID playerId, Game game) {
|
public boolean choose(Outcome outcome, UUID playerId, Game game) {
|
||||||
if (this.size() > 0) {
|
if (this.size() > 0 && canChoose(playerId, game)) {
|
||||||
while (!isChosen()) {
|
while (!isChosen()) {
|
||||||
Target target = this.getUnchosen().get(0);
|
Target target = this.getUnchosen().get(0);
|
||||||
if (!target.choose(outcome, playerId, game))
|
if (!target.choose(outcome, playerId, game))
|
||||||
|
|
@ -84,7 +84,7 @@ public class Targets extends ArrayList<Target> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean chooseTargets(Outcome outcome, UUID playerId, Ability source, Game game) {
|
public boolean chooseTargets(Outcome outcome, UUID playerId, Ability source, Game game) {
|
||||||
if (this.size() > 0) {
|
if (this.size() > 0 && canChoose(source.getSourceId(), playerId, game)) {
|
||||||
while (!isChosen()) {
|
while (!isChosen()) {
|
||||||
Target target = this.getUnchosen().get(0);
|
Target target = this.getUnchosen().get(0);
|
||||||
if (!target.chooseTarget(outcome, playerId, source, game))
|
if (!target.chooseTarget(outcome, playerId, source, game))
|
||||||
|
|
@ -103,6 +103,15 @@ public class Targets extends ArrayList<Target> {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if there are enough targets that can be chosen. Should only be used
|
||||||
|
* for Ability targets since this checks for protection, shroud etc.
|
||||||
|
*
|
||||||
|
* @param sourceId - the target event source
|
||||||
|
* @param sourceControllerId - controller of the target event source
|
||||||
|
* @param game
|
||||||
|
* @return - true if enough valid targets exist
|
||||||
|
*/
|
||||||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||||
for (Target target: this) {
|
for (Target target: this) {
|
||||||
if (!target.canChoose(sourceId, sourceControllerId, game))
|
if (!target.canChoose(sourceId, sourceControllerId, game))
|
||||||
|
|
@ -111,6 +120,22 @@ public class Targets extends ArrayList<Target> {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if there are enough objects that can be selected. Should not be used
|
||||||
|
* for Ability targets since this does not check for protection, shroud etc.
|
||||||
|
*
|
||||||
|
* @param sourceControllerId - controller of the select event
|
||||||
|
* @param game
|
||||||
|
* @return - true if enough valid objects exist
|
||||||
|
*/
|
||||||
|
public boolean canChoose(UUID sourceControllerId, Game game) {
|
||||||
|
for (Target target: this) {
|
||||||
|
if (!target.canChoose(sourceControllerId, game))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public UUID getFirstTarget() {
|
public UUID getFirstTarget() {
|
||||||
if (this.size() > 0)
|
if (this.size() > 0)
|
||||||
return this.get(0).getFirstTarget();
|
return this.get(0).getFirstTarget();
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,15 @@ public class TargetCreatureOrPlayer extends TargetImpl<TargetCreatureOrPlayer> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if there are enough {@link Permanent} or {@link Player} that can be chosen. Should only be used
|
||||||
|
* for Ability targets since this checks for protection, shroud etc.
|
||||||
|
*
|
||||||
|
* @param sourceId - the target event source
|
||||||
|
* @param sourceControllerId - controller of the target event source
|
||||||
|
* @param game
|
||||||
|
* @return - true if enough valid {@link Permanent} or {@link Player} exist
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
@ -129,6 +138,35 @@ public class TargetCreatureOrPlayer extends TargetImpl<TargetCreatureOrPlayer> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if there are enough {@link Permanent} or {@link Player} that can be selected. Should not be used
|
||||||
|
* for Ability targets since this does not check for protection, shroud etc.
|
||||||
|
*
|
||||||
|
* @param sourceControllerId - controller of the select event
|
||||||
|
* @param game
|
||||||
|
* @return - true if enough valid {@link Permanent} or {@link Player} exist
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean canChoose(UUID sourceControllerId, Game game) {
|
||||||
|
int count = 0;
|
||||||
|
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||||
|
Player player = game.getPlayer(playerId);
|
||||||
|
if (player != null && filter.match(player)) {
|
||||||
|
count++;
|
||||||
|
if (count >= this.minNumberOfTargets)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Permanent permanent: game.getBattlefield().getActivePermanents(FilterCreaturePermanent.getDefault(), sourceControllerId, game)) {
|
||||||
|
if (filter.match(permanent, sourceControllerId, game)) {
|
||||||
|
count++;
|
||||||
|
if (count >= this.minNumberOfTargets)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||||
Set<UUID> possibleTargets = new HashSet<UUID>();
|
Set<UUID> possibleTargets = new HashSet<UUID>();
|
||||||
|
|
@ -147,6 +185,23 @@ public class TargetCreatureOrPlayer extends TargetImpl<TargetCreatureOrPlayer> {
|
||||||
return possibleTargets;
|
return possibleTargets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
|
||||||
|
Set<UUID> possibleTargets = new HashSet<UUID>();
|
||||||
|
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||||
|
Player player = game.getPlayer(playerId);
|
||||||
|
if (player != null && filter.match(player)) {
|
||||||
|
possibleTargets.add(playerId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Permanent permanent: game.getBattlefield().getActivePermanents(FilterCreaturePermanent.getDefault(), sourceControllerId, game)) {
|
||||||
|
if (filter.match(permanent, sourceControllerId, game)) {
|
||||||
|
possibleTargets.add(permanent.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return possibleTargets;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTargetedName(Game game) {
|
public String getTargetedName(Game game) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,27 @@ public class TargetCreatureOrPlayerAmount extends TargetAmount<TargetCreatureOrP
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canChoose(UUID sourceControllerId, Game game) {
|
||||||
|
int count = 0;
|
||||||
|
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||||
|
Player player = game.getPlayer(playerId);
|
||||||
|
if (player != null && filter.match(player)) {
|
||||||
|
count++;
|
||||||
|
if (count >= this.minNumberOfTargets)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Permanent permanent: game.getBattlefield().getActivePermanents(FilterCreaturePermanent.getDefault(), sourceControllerId, game)) {
|
||||||
|
if (filter.match(permanent, sourceControllerId, game)) {
|
||||||
|
count++;
|
||||||
|
if (count >= this.minNumberOfTargets)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||||
Set<UUID> possibleTargets = new HashSet<UUID>();
|
Set<UUID> possibleTargets = new HashSet<UUID>();
|
||||||
|
|
@ -138,6 +159,23 @@ public class TargetCreatureOrPlayerAmount extends TargetAmount<TargetCreatureOrP
|
||||||
return possibleTargets;
|
return possibleTargets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
|
||||||
|
Set<UUID> possibleTargets = new HashSet<UUID>();
|
||||||
|
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||||
|
Player player = game.getPlayer(playerId);
|
||||||
|
if (player != null && filter.match(player)) {
|
||||||
|
possibleTargets.add(playerId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Permanent permanent: game.getBattlefield().getActivePermanents(FilterCreaturePermanent.getDefault(), sourceControllerId, game)) {
|
||||||
|
if (filter.match(permanent, sourceControllerId, game)) {
|
||||||
|
possibleTargets.add(permanent.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return possibleTargets;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTargetedName(Game game) {
|
public String getTargetedName(Game game) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,27 @@ public class TargetDefender extends TargetImpl<TargetDefender> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canChoose(UUID sourceControllerId, Game game) {
|
||||||
|
int count = 0;
|
||||||
|
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||||
|
Player player = game.getPlayer(playerId);
|
||||||
|
if (player != null && filter.match(player)) {
|
||||||
|
count++;
|
||||||
|
if (count >= this.minNumberOfTargets)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Permanent permanent: game.getBattlefield().getActivePermanents(new FilterPlaneswalkerPermanent(), sourceControllerId, game)) {
|
||||||
|
if (filter.match(permanent)) {
|
||||||
|
count++;
|
||||||
|
if (count >= this.minNumberOfTargets)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||||
Set<UUID> possibleTargets = new HashSet<UUID>();
|
Set<UUID> possibleTargets = new HashSet<UUID>();
|
||||||
|
|
@ -119,6 +140,23 @@ public class TargetDefender extends TargetImpl<TargetDefender> {
|
||||||
return possibleTargets;
|
return possibleTargets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
|
||||||
|
Set<UUID> possibleTargets = new HashSet<UUID>();
|
||||||
|
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||||
|
Player player = game.getPlayer(playerId);
|
||||||
|
if (player != null && filter.match(player)) {
|
||||||
|
possibleTargets.add(playerId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Permanent permanent: game.getBattlefield().getActivePermanents(new FilterPlaneswalkerPermanent(), sourceControllerId, game)) {
|
||||||
|
if (filter.match(permanent)) {
|
||||||
|
possibleTargets.add(permanent.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return possibleTargets;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTargetedName(Game game) {
|
public String getTargetedName(Game game) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue