From 13b8cad13100f6847d37d4066ce1879a50a925cd Mon Sep 17 00:00:00 2001 From: Quercitron Date: Sun, 29 Jun 2014 02:45:18 +0400 Subject: [PATCH] Change handling of minNumberOfTargets and required status --- .../src/mage/player/human/HumanPlayer.java | 21 +++++++++++++++---- Mage/src/mage/target/TargetObject.java | 3 --- .../target/common/TargetCardInLibrary.java | 2 +- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java index 130d16b8d8..f5d24b3ec7 100644 --- a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java +++ b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java @@ -239,7 +239,11 @@ public class HumanPlayer extends PlayerImpl { updateGameStatePriority("choose(5)", game); while (!abort) { Set 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 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 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 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)) { diff --git a/Mage/src/mage/target/TargetObject.java b/Mage/src/mage/target/TargetObject.java index 3d6a38cc5f..1cfba8c3e5 100644 --- a/Mage/src/mage/target/TargetObject.java +++ b/Mage/src/mage/target/TargetObject.java @@ -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; diff --git a/Mage/src/mage/target/common/TargetCardInLibrary.java b/Mage/src/mage/target/common/TargetCardInLibrary.java index a352d7320f..1f9793e214 100644 --- a/Mage/src/mage/target/common/TargetCardInLibrary.java +++ b/Mage/src/mage/target/common/TargetCardInLibrary.java @@ -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; }