Skip to content

Commit

Permalink
Added argument for minimum number of case rules
Browse files Browse the repository at this point in the history
  • Loading branch information
charlestian23 committed Mar 26, 2024
1 parent c1b10f4 commit 62132c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/java/edu/rpi/legup/history/AutoCaseRuleCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/edu/rpi/legup/model/rules/CaseRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
}

/**
Expand Down

0 comments on commit 62132c3

Please sign in to comment.