mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
Change handling of minNumberOfTargets and required status
This commit is contained in:
parent
1129858a6c
commit
13b8cad131
3 changed files with 18 additions and 8 deletions
|
@ -239,7 +239,11 @@ public class HumanPlayer extends PlayerImpl {
|
|||
updateGameStatePriority("choose(5)", game);
|
||||
while (!abort) {
|
||||
Set<UUID> cards = target.possibleTargets(null, playerId, game);
|
||||
game.fireSelectTargetEvent(playerId, target.getMessage(), cards, target.isRequired(sourceId, game), options);
|
||||
boolean required = target.isRequired(sourceId, game);
|
||||
if (target.getTargets().size() >= target.getNumberOfTargets()) {
|
||||
required = false;
|
||||
}
|
||||
game.fireSelectTargetEvent(playerId, target.getMessage(), cards, required, options);
|
||||
waitForResponse(game);
|
||||
if (response.getUUID() != null) {
|
||||
if (target instanceof TargetPermanent) {
|
||||
|
@ -287,7 +291,10 @@ public class HumanPlayer extends PlayerImpl {
|
|||
updateGameStatePriority("chooseTarget", game);
|
||||
while (!abort) {
|
||||
Set<UUID> possibleTargets = target.possibleTargets(source==null?null:source.getSourceId(), playerId, game);
|
||||
boolean required = possibleTargets.isEmpty() ? false : target.isRequired(source);
|
||||
boolean required = target.isRequired(source);
|
||||
if (possibleTargets.isEmpty() || target.getTargets().size() >= target.getNumberOfTargets()) {
|
||||
required = false;
|
||||
}
|
||||
game.fireSelectTargetEvent(playerId, target.getMessage(), possibleTargets, required, getOptions(target));
|
||||
waitForResponse(game);
|
||||
if (response.getUUID() != null) {
|
||||
|
@ -319,7 +326,7 @@ public class HumanPlayer extends PlayerImpl {
|
|||
}
|
||||
|
||||
private Map<String, Serializable> getOptions(Target target) {
|
||||
return target.getNumberOfTargets() != target.getMaxNumberOfTargets() ? staticOptions : null;
|
||||
return target.getTargets().size() >= target.getNumberOfTargets() ? staticOptions : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -336,6 +343,9 @@ public class HumanPlayer extends PlayerImpl {
|
|||
required = false;
|
||||
}
|
||||
}
|
||||
if (target.getTargets().size() >= target.getNumberOfTargets()) {
|
||||
required = false;
|
||||
}
|
||||
Map<String, Serializable> options = getOptions(target);
|
||||
if (target.getTargets().size() > 0) {
|
||||
if (options == null) {
|
||||
|
@ -379,7 +389,10 @@ public class HumanPlayer extends PlayerImpl {
|
|||
required = false;
|
||||
}
|
||||
}
|
||||
game.fireSelectTargetEvent(playerId, target.getMessage(), cards, target.isRequired(source), null);
|
||||
if (target.getTargets().size() >= target.getNumberOfTargets()) {
|
||||
required = false;
|
||||
}
|
||||
game.fireSelectTargetEvent(playerId, target.getMessage(), cards, required, null);
|
||||
waitForResponse(game);
|
||||
if (response.getUUID() != null) {
|
||||
if (target.canTarget(response.getUUID(), cards, game)) {
|
||||
|
|
|
@ -58,9 +58,6 @@ public abstract class TargetObject extends TargetImpl {
|
|||
public TargetObject(int minNumTargets, int maxNumTargets, Zone zone, boolean notTarget) {
|
||||
this.minNumberOfTargets = minNumTargets;
|
||||
this.maxNumberOfTargets = maxNumTargets;
|
||||
if (minNumTargets == 0) {
|
||||
setRequired(false);
|
||||
}
|
||||
this.zone = zone;
|
||||
this.targetName = "card";
|
||||
this.notTarget = notTarget;
|
||||
|
|
|
@ -65,7 +65,7 @@ public class TargetCardInLibrary extends TargetCard {
|
|||
|
||||
public TargetCardInLibrary(int minNumTargets, int maxNumTargets, FilterCard filter) {
|
||||
super(minNumTargets, maxNumTargets, Zone.LIBRARY, filter);
|
||||
this.setRequired(minNumTargets > 0 && !filter.hasPredicates());
|
||||
this.setRequired(!filter.hasPredicates());
|
||||
this.librarySearchLimit = Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue