diff --git a/src/main/java/edu/rpi/legup/history/AutoCaseRuleCommand.java b/src/main/java/edu/rpi/legup/history/AutoCaseRuleCommand.java index 94f38be85..fac5ff1d9 100644 --- a/src/main/java/edu/rpi/legup/history/AutoCaseRuleCommand.java +++ b/src/main/java/edu/rpi/legup/history/AutoCaseRuleCommand.java @@ -117,9 +117,14 @@ public String getErrorString() { return "The selection must produce at least one case"; } - if (caseRule.getCases(caseBoard.getBaseBoard(), elementView.getPuzzleElement()).size() > caseRule.MAX_CASES) { + int numberOfCaseRules = caseRule.getCases(caseBoard.getBaseBoard(), elementView.getPuzzleElement()).size(); + System.out.println("Number of cases:" + numberOfCaseRules); + if (numberOfCaseRules > caseRule.MAX_CASES) { return "The selection can produce a max of " + caseRule.MAX_CASES + " cases"; } + if (numberOfCaseRules < caseRule.MIN_CASES) { + return "The selection must produce a minimum of " + caseRule.MIN_CASES + " cases"; + } return null; } diff --git a/src/main/java/edu/rpi/legup/model/rules/CaseRule.java b/src/main/java/edu/rpi/legup/model/rules/CaseRule.java index dd5121d63..b214e0119 100644 --- a/src/main/java/edu/rpi/legup/model/rules/CaseRule.java +++ b/src/main/java/edu/rpi/legup/model/rules/CaseRule.java @@ -15,6 +15,7 @@ public abstract class CaseRule extends Rule { private final String INVALID_USE_MESSAGE; public int MAX_CASES; + public int MIN_CASES; /** * CaseRule Constructor creates a new case rule. @@ -29,6 +30,7 @@ public CaseRule(String ruleID, String ruleName, String description, String image this.ruleType = CASE; this.INVALID_USE_MESSAGE = "Invalid use of the case rule " + this.ruleName; this.MAX_CASES = 10; + this.MIN_CASES = 0; // By default, this will not actually have any effect } /**