From a16ae5a1c7aacd9756ad5aef9b7686ddb6eab0e0 Mon Sep 17 00:00:00 2001 From: Kevin-771 <70790256+Kevin-771@users.noreply.github.com> Date: Wed, 13 Dec 2023 15:26:36 -0500 Subject: [PATCH] Added back TreeTent line creation (#695) * Test suite branch -- BulbsInPathContradictionRuleTest (#674) * Region Based Changes (#559) Co-authored-by: Hanson Gu <123511202+hansongu123@users.noreply.github.com> * Short Truth Table Puzzle Editor (#451) * Created files for STT elements * Renamed Tiles classes to Elements to match package name Also added an elements reference sheet and renamed rules reference sheet accordingly * More progress made This won't compile, just saving progress made * More progress being made * Fixed file name typo and added placeholder tiles * Added image paths * Created element classes and added placeholder tile images (#452) * Renamed Tiles classes to Elements to match package name Also added an elements reference sheet and renamed rules reference sheet accordingly * More progress made This won't compile, just saving progress made * More progress being made * Fixed file name typo and added placeholder tiles * Added image paths * Set the current board on boardView * Fixed typo and turned on STT puzzle editor for testing * Added preliminary valid dimensions checker This will most definitely change in the future, hopefully can change to accept a number of statements * Fixed image file paths * Added ActionListener Allows us to determine what puzzle is selected by the user * Hide rows and columns input for Short Truth Table * Added text area for Short Truth Table * Added scrollbars to show up as needed * Reformatted code * More code reformatting * Even more reformatting * Separate the data from the TextArea into different lines * Did some researching/testing Tested certain variable values with a STT file with no true/false values * Made more progress Added new methods to handle creating Short Truth Table boards from an array of strings * Added a bunch of TODOs - Implemented a couple functions to be used later - Added a bunch of TODO comments for future work * Made some more progress * Implemented abstract methods from PuzzleImporter * Added abstract methods to Fillapix and added other exception reporting * CheckStyle formatting * Removed a TODO comment * Statements show up in puzzle editor Fixed a bug where the importer was not properly being initialized. Statements now show up in the puzzle editor. * Removed empty statements * Changed InvalidFormatException to IllegalArgumentException * Remove argument that has already been caught * Removed elements that will not be used * Added puzzle editor cell clicking functionality * Added ability to toggle certain logical elements * New icons and more functionality implemented * Fixed a bug where spacer rows could be modified * Added statement error checking * Fixed formatting * Only one logic symbol element needed * Changed InputMismatchException to UnsupportedOperationException * Renamed variables to not be STT specific * Finding initial issue and starting fix * Issue is statement copying and modifying * STT exporter now working. Overrode setCell for STTBoard. * Added code documentation * removed testing println() * Gradle fixes * Revert "Merge pull request #545 from MMosley502/puzzle_editor-short_truth_table-file_saving" This reverts commit 2e82547896a7fb3e52ec27634cd8938ef299732f, reversing changes made to beb60a2ab67c8317d404f54e52471739f698bf22. * Saving files now works * Fixed the blank element to be categorized as a placeable element * Fixed a bug where file wouldn't save due to batch grader updates * Reformatted code in STT * Reformatted code again * MORE REFORMATTING Pls like my code CheckStyle --------- Co-authored-by: Matthew Mosley Co-authored-by: MMosley502 <74743867+MMosley502@users.noreply.github.com> * Have null changes be valid and fix IsolatedBlackContradicitonRule error message (#561) * Get Tests to be called Revert "Create first cypress test template" This reverts commit 3e50909b93b5aa9634cf0d296e9aeff756b0a909. First commit Finish Lightup tests * Add more tests Update TestRunner.java * Somehow ended up in the wrong spot Fix Import * Please let this be the fix Update TreeTransition.java Update TreeTransition.java Update DirectRule.java Check to see which is not correct Update ElementController.java Revert "maybe the null is making it think that it's not valid" This reverts commit 7bf1de0d66ced6749ee37fbb9c252636b2fcdc79. Just trying to change color Revert "Just trying to change color" This reverts commit ec44695ee578d664055d135a668927a0fd900f5d. Revert "maybe the null is making it think that it's not valid" This reverts commit 3f162fbdc32e6fbd23da321a14a6af96f0ff520d. Check to see which is not correct Revert "Check to see which is not correct" This reverts commit 136b0a41b9d103e6f3e9a7f8cd5d970bf76b050b. Update TreeTransition.java Update TreeTransition.java Revert "Update TreeTransition.java" This reverts commit cde45bb9001cfbfa4f6e2a49b4e9990d2fa7ad33. * Fix error with isolated Black Fix error message with isolated black * Removed excess whitespace and imports. Added short JavaDoc for `TestRunner.java` --------- Co-authored-by: Charles Tian <46334090+charlestian23@users.noreply.github.com> Co-authored-by: Bram van Heuveln Co-authored-by: Corppet * Fixed a bug * Update BlackTile.java Black tile should not be placeable * Added unknown tile stuff * ID error * Some Fixes to Recently Discussed UX Bugs (#563) * frame and panels default sizes, default pos on screen * hardcoded version number * homepanel default size * set panels' own sizes * some changes * Removed unused import --------- Co-authored-by: Charles Tian <46334090+charlestian23@users.noreply.github.com> Co-authored-by: Corppet * Oops pushed the wrong file Yeah some tiles work now but this is the ID error * Number Tile working * Update Exporter (#627) * Update Exporter * Delete Test_Save --------- Co-authored-by: Charles Tian <46334090+charlestian23@users.noreply.github.com> * Create run-tests.yml * Update run-tests.yml * Update run-tests.yml * Update run-tests.yml * Update run-tests.yml * Windows things * Added print messages * More Windows things * Debugging * Update run-tests.yml * Update run-tests.yml * Maybe this will work now? * Didn't work * Update run-tests.yml * Update run-tests.yml * Create DummyTest.java For debugging purposes * Added another dummy test * Update run-tests.yml * Update run-tests.yml Get rid of all this info * Deleted the dummy tests * BulbsInPathContradictionRuleTest looks good. I added one more function to check for the BlockInHorizontalPath test case. * I think I might have run into a problem on the testing function. I will confirm this problem next time and will write another test case. * I made another puzzle and test case to check what would happen if the cells could actually be lit, meaning there would be no contradiction. The test case passed and so I think CannotLightACellContradictionRule works correctly for all cases. * I made another puzzle and test case to check what would happen if the cells could actually be lit, meaning there would be no contradiction. The test case passed and so I think CannotLightACellContradictionRule works correctly for all cases. --------- Co-authored-by: Antonio Orta <60408336+19690ao@users.noreply.github.com> Co-authored-by: Hanson Gu <123511202+hansongu123@users.noreply.github.com> Co-authored-by: Charles Tian <46334090+charlestian23@users.noreply.github.com> Co-authored-by: Matthew Mosley Co-authored-by: MMosley502 <74743867+MMosley502@users.noreply.github.com> Co-authored-by: Viane Matsibekker <117249183+04vmatsibekker@users.noreply.github.com> Co-authored-by: Bram van Heuveln Co-authored-by: Corppet Co-authored-by: charlestian23 Co-authored-by: Chase Grajeda <76405306+Chase-Grajeda@users.noreply.github.com> Co-authored-by: ThisMatt <98851950+ThisMatt@users.noreply.github.com> * Revert "Test suite branch -- BulbsInPathContradictionRuleTest (#674)" (#687) This reverts commit 6afa15c57fca05a9b8da4b4f27b88dd55d69bfb8. * added back link functionality --------- Co-authored-by: pitbull51067 <103721450+pitbull51067@users.noreply.github.com> Co-authored-by: Antonio Orta <60408336+19690ao@users.noreply.github.com> Co-authored-by: Hanson Gu <123511202+hansongu123@users.noreply.github.com> Co-authored-by: Charles Tian <46334090+charlestian23@users.noreply.github.com> Co-authored-by: Matthew Mosley Co-authored-by: MMosley502 <74743867+MMosley502@users.noreply.github.com> Co-authored-by: Viane Matsibekker <117249183+04vmatsibekker@users.noreply.github.com> Co-authored-by: Bram van Heuveln Co-authored-by: Corppet Co-authored-by: charlestian23 Co-authored-by: Chase Grajeda <76405306+Chase-Grajeda@users.noreply.github.com> Co-authored-by: ThisMatt <98851950+ThisMatt@users.noreply.github.com> --- .../puzzle/treetent/TreeTentController.java | 152 +++++++++--------- 1 file changed, 76 insertions(+), 76 deletions(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentController.java b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentController.java index 2b969b4bb..1f431594c 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentController.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentController.java @@ -29,83 +29,83 @@ public TreeTentController() { this.lastCellPressed = null; } -// @Override -// public void mousePressed(MouseEvent e) { -// if (e.getButton() != MouseEvent.BUTTON2) { -// BoardView boardView = getInstance().getLegupUI().getBoardView(); -// dragStart = boardView.getElement(e.getPoint()); -// lastCellPressed = boardView.getElement(e.getPoint()); -// } -// } + @Override + public void mousePressed(MouseEvent e) { + if (e.getButton() != MouseEvent.BUTTON2) { + BoardView boardView = getInstance().getLegupUI().getBoardView(); + dragStart = boardView.getElement(e.getPoint()); + lastCellPressed = boardView.getElement(e.getPoint()); + } + } + + @Override + public void mouseReleased(MouseEvent e) { + if (GameBoardFacade.getInstance().getLegupUI().getTreePanel() != null && e.getButton() != MouseEvent.BUTTON2) { + TreePanel treePanel = GameBoardFacade.getInstance().getLegupUI().getTreePanel(); + TreeView treeView = GameBoardFacade.getInstance().getLegupUI().getTreePanel().getTreeView(); + BoardView boardView = getInstance().getLegupUI().getBoardView(); + lastCellPressed = boardView.getElement(e.getPoint()); + Board board = boardView.getBoard(); + TreeViewSelection selection = treeView.getSelection(); -// @Override -// public void mouseReleased(MouseEvent e) { -// if (GameBoardFacade.getInstance().getLegupUI().getTreePanel() != null && e.getButton() != MouseEvent.BUTTON2) { -// TreePanel treePanel = GameBoardFacade.getInstance().getLegupUI().getTreePanel(); -// TreeView treeView = GameBoardFacade.getInstance().getLegupUI().getTreePanel().getTreeView(); -// BoardView boardView = getInstance().getLegupUI().getBoardView(); -// lastCellPressed = boardView.getElement(e.getPoint()); -// Board board = boardView.getBoard(); -// TreeViewSelection selection = treeView.getSelection(); -// -// if (dragStart != null) { -// if (board instanceof CaseBoard) { -// CaseBoard caseBoard = (CaseBoard) board; -// AutoCaseRuleCommand autoCaseRuleCommand = new AutoCaseRuleCommand(dragStart, selection, caseBoard.getCaseRule(), caseBoard, e); -// if (autoCaseRuleCommand.canExecute()) { -// autoCaseRuleCommand.execute(); -// getInstance().getHistory().pushChange(autoCaseRuleCommand); -// treePanel.updateError(""); -// } -// else { -// treePanel.updateError(autoCaseRuleCommand.getError()); -// } -// } -// else { -// if (dragStart == lastCellPressed) { -// if (dragStart.getPuzzleElement().getIndex() >= 0) { -// ICommand edit = new EditDataCommand(lastCellPressed, selection, e); -// if (edit.canExecute()) { -// edit.execute(); -// getInstance().getHistory().pushChange(edit); -// treePanel.updateError(""); -// } -// else { -// treePanel.updateError(edit.getError()); -// } -// } -// else { -// ClueCommand edit = new ClueCommand(selection, (TreeTentClueView) dragStart); -// if (edit.canExecute()) { -// edit.execute(); -// getInstance().getHistory().pushChange(edit); -// treePanel.updateError(""); -// } -// else { -// treePanel.updateError(edit.getError()); -// } -// } -// } -// else { -// if (lastCellPressed != null) { -// if (dragStart instanceof TreeTentElementView) { -// ICommand editLine = new EditLineCommand(selection, (TreeTentElementView) dragStart, lastCellPressed); -// if (editLine.canExecute()) { -// editLine.execute(); -// getInstance().getHistory().pushChange(editLine); -// } -// else { -// treePanel.updateError(editLine.getError()); -// } -// } -// } -// } -// } -// } -// dragStart = null; -// lastCellPressed = null; -// } -// } + if (dragStart != null) { + if (board instanceof CaseBoard) { + CaseBoard caseBoard = (CaseBoard) board; + AutoCaseRuleCommand autoCaseRuleCommand = new AutoCaseRuleCommand(dragStart, selection, caseBoard.getCaseRule(), caseBoard, e); + if (autoCaseRuleCommand.canExecute()) { + autoCaseRuleCommand.execute(); + getInstance().getHistory().pushChange(autoCaseRuleCommand); + treePanel.updateError(""); + } + else { + treePanel.updateError(autoCaseRuleCommand.getError()); + } + } + else { + if (dragStart == lastCellPressed) { + if (dragStart.getPuzzleElement().getIndex() >= 0) { + ICommand edit = new EditDataCommand(lastCellPressed, selection, e); + if (edit.canExecute()) { + edit.execute(); + getInstance().getHistory().pushChange(edit); + treePanel.updateError(""); + } + else { + treePanel.updateError(edit.getError()); + } + } + else { + ClueCommand edit = new ClueCommand(selection, (TreeTentClueView) dragStart); + if (edit.canExecute()) { + edit.execute(); + getInstance().getHistory().pushChange(edit); + treePanel.updateError(""); + } + else { + treePanel.updateError(edit.getError()); + } + } + } + else { + if (lastCellPressed != null) { + if (dragStart instanceof TreeTentElementView) { + ICommand editLine = new EditLineCommand(selection, (TreeTentElementView) dragStart, lastCellPressed); + if (editLine.canExecute()) { + editLine.execute(); + getInstance().getHistory().pushChange(editLine); + } + else { + treePanel.updateError(editLine.getError()); + } + } + } + } + } + } + dragStart = null; + lastCellPressed = null; + } + } @Override public void changeCell(MouseEvent e, PuzzleElement element) {