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

Check specific puzzles on the board for each treetransition #566

Closed
wants to merge 8 commits into from
Closed
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
8 changes: 8 additions & 0 deletions src/main/java/edu/rpi/legup/controller/ElementController.java
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is just printing out debug information? If it isn't a necessary feature for LEGUP, it should be removed.

Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ public void mouseReleased(MouseEvent e) {
// if (selectedElement != null) {
GridBoard b = (GridBoard) this.boardView.getBoard();
Point point = e.getPoint();


TreeTransition treeTransition = (TreeTransition) this.boardView.getTreeElement();
treeTransition.addNewPuzzleElement(elementView.getPuzzleElement());
System.out.println("size");
System.out.println(treeTransition.getNewPuzzleElements().size());


Point scaledPoint = new Point((int) Math.floor(point.x / (30 * this.boardView.getScale())), (int) Math.floor(point.y / (30 * this.boardView.getScale())));
if (this.boardView.getBoard() instanceof TreeTentBoard) {
scaledPoint.setLocation(scaledPoint.getX() - 1, scaledPoint.getY() - 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import edu.rpi.legup.app.GameBoardFacade;
import edu.rpi.legup.model.Puzzle;
import edu.rpi.legup.model.rules.ContradictionRule;
import edu.rpi.legup.ui.boardview.BoardView;
import edu.rpi.legup.model.tree.*;
import edu.rpi.legup.ui.proofeditorui.treeview.*;

Expand Down Expand Up @@ -41,6 +42,12 @@ public void executeCommand() {
Puzzle puzzle = GameBoardFacade.getInstance().getPuzzleModule();
final TreeViewSelection newSelection = new TreeViewSelection();


BoardView boardView = puzzle.getBoardView();
TreeTransition thisTreeElement = (TreeTransition) boardView.getTreeElement();
System.out.println("thisTreeElelement size ------------->");
System.out.println(thisTreeElement.getNewPuzzleElements().size());

List<TreeElementView> selectedViews = selection.getSelectedViews();
for (TreeElementView view : selectedViews) {
TreeElement treeElement = view.getTreeElement();
Expand Down Expand Up @@ -73,7 +80,7 @@ public void executeCommand() {
transition.getBoard().setModifiable(false);
tree.addTreeElement(treeNode, transition);
}

transition.addAllPuzzleElements(thisTreeElement.getNewPuzzleElements());
final TreeTransition finalTran = transition;
puzzle.notifyTreeListeners(listener -> listener.onTreeElementAdded(finalTran));

Expand Down
13 changes: 11 additions & 2 deletions src/main/java/edu/rpi/legup/model/rules/ContradictionRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@ public ContradictionRule(String ruleID, String ruleName, String description, Str
*/
@Override
public String checkRule(TreeTransition transition) {
return checkContradiction(transition.getBoard());
for (PuzzleElement puzzleElement : transition.getNewPuzzleElements()) {
System.out.println("Puzzle Elements getting checked are");
System.out.println(puzzleElement.getIndex());
String checkStr = checkContradictionAt(transition.getBoard(), puzzleElement);
if (checkStr == null) {
return checkStr;
}
}
return this.NO_CONTRADICTION_MESSAGE;
}

/**
Expand All @@ -57,7 +65,8 @@ public String checkRuleAt(TreeTransition transition, PuzzleElement puzzleElement
*/
@Override
public String checkRuleRaw(TreeTransition transition) {
return checkContradiction(transition.getBoard());
//MIGHT HAVE TO CHANGE HERE TOO
return checkRule(transition);
}

/**
Expand Down
42 changes: 42 additions & 0 deletions src/main/java/edu/rpi/legup/model/tree/TreeTransition.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,23 @@
import java.util.ArrayList;
import java.util.List;

import java.util.HashSet;
import java.util.Set;








public class TreeTransition extends TreeElement {
private ArrayList<TreeNode> parents;
private TreeNode childNode;
private Rule rule;
private boolean isCorrect;
private boolean isVerified;
private Set<PuzzleElement> newPuzzleElements;

/**
* TreeTransition Constructor create a transition from one node to another
Expand All @@ -28,8 +39,39 @@ public TreeTransition(Board board) {
this.rule = null;
this.isCorrect = false;
this.isVerified = false;
this.newPuzzleElements = new HashSet<>();
}
/**
* Returns a copy of the set containing all the puzzle elements on this board.
*
* @return A set containing all the puzzle elements on this board.
*/
public Set<PuzzleElement> getNewPuzzleElements() {
return new HashSet<>(this.newPuzzleElements);
}
/**
* Adds a {@link PuzzleElement} to this board.
*
* @param puzzleElement The puzzleElement to be added
* @throws IllegalStateException if the board is not modifiable at the moment
*/
public void addNewPuzzleElement(PuzzleElement puzzleElement) {
this.newPuzzleElements.add(puzzleElement);
System.out.println("adding Element to transition");
System.out.println(puzzleElement.getIndex());
}

/**
* Adds a {@link PuzzleElement} to this board.
*
* @param puzzleElements The puzzleElement to be added
* @throws IllegalStateException if the board is not modifiable at the moment
*/
public void addAllPuzzleElements(Set<PuzzleElement> puzzleElements) {
this.newPuzzleElements = puzzleElements;
}


/**
* TreeTransition Constructor - create a transition from one node to another
*
Expand Down
Loading