Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 679 atomic true on empty #697

Merged
merged 5 commits into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/main/java/edu/rpi/legup/model/rules/DirectRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ public String checkRule(TreeTransition transition) {
public String checkRuleRaw(TreeTransition transition) {
Board finalBoard = transition.getBoard();
String checkStr = null;

// Go directly to specific direct rule's judgement if no cell's are edited
if (finalBoard.getModifiedData().size() == 0) {
checkStr = checkRuleRawAt(transition, null);
}
for (PuzzleElement puzzleElement : finalBoard.getModifiedData()) {
String tempStr = checkRuleAt(transition, puzzleElement);
if (tempStr != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public DirectRule_Generic(String ruleID, String ruleName, String description, St
}

public String checkRuleRawAt(TreeTransition transition, PuzzleElement element) {
// Rule must have cell to evaluate on
if (element == null) return super.getInvalidUseOfRuleMessage() + ": Must have painted cell";

// Check that the puzzle element is not unknown
ShortTruthTableBoard parentBoard = (ShortTruthTableBoard) transition.getParents().get(0).getBoard();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public CaseRule_Generic(String ruleID, String ruleName, String title, String des
public String checkRuleRaw(TreeTransition transition) {
// Validate that two children are generated
List<TreeTransition> childTransitions = transition.getParents().get(0).getChildren();
if (childTransitions.size() != 2) {
return "ERROR: This case rule must have 2 children.";
if (childTransitions.size() >= 1) {
return "ERROR: This case rule must spawn at least 1 child.";
}

// Validate that the modified cells are of type UNKNOWN, TRUE, or FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public SurroundTentWithGrassDirectRule() {
*/
@Override
public String checkRuleRawAt(TreeTransition transition, PuzzleElement puzzleElement) {
if (puzzleElement == null) {
return null;
}
if (puzzleElement instanceof TreeTentLine) {
return super.getInvalidUseOfRuleMessage() + ": Line is not valid for this rule.";
}
Expand Down
Loading