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

Fixed issue #357 #373

Merged
merged 21 commits into from
Nov 15, 2022
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
2 changes: 1 addition & 1 deletion bin/main/edu/rpi/legup/legup/config
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<puzzle name="LightUp"
qualifiedClassName="edu.rpi.legup.puzzle.lightup.LightUp"
fileType=".xml"
fileCreationDisabled="true"/>
fileCreationDisabled="false"/>
<puzzle name="Masyu"
qualifiedClassName="edu.rpi.legup.puzzle.masyu.Masyu"
fileType=".xml"
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@ task buildNativeWindows(type: Exec, dependsOn: 'createExe') {

repositories {
mavenCentral()
}
}
11 changes: 5 additions & 6 deletions src/main/java/edu/rpi/legup/puzzle/lightup/LightUp.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ public class LightUp extends Puzzle {

public LightUp() {
super();
name = "LightUp";
this.name = "LightUp";

importer = new LightUpImporter(this);
exporter = new LightUpExporter(this);
this.importer = new LightUpImporter(this);
this.exporter = new LightUpExporter(this);

factory = new LightUpCellFactory();
this.factory = new LightUpCellFactory();
}

/**
Expand Down Expand Up @@ -47,8 +47,7 @@ public Board generatePuzzle(int difficulty) {
* @return true if the given dimensions are valid for Light Up, false otherwise
*/
public boolean isValidDimensions(int rows, int columns) {
// This is a placeholder, this method needs to be implemented
throw new UnsupportedOperationException();
return rows > 0 && columns > 0;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ public class NumberTile extends NonPlaceableElement {

int object_number;

// Follow the default format and resolves the NoSuchMethod error
public NumberTile() {
super("LTUP-UNPL-0001", "Number Tile", "The number tile", "edu/rpi/legup/images/lightup/1.gif");
}

public NumberTile(int num) {
super("LTUP-UNPL-0001", "Number Tile", "The number tile", "edu/rpi/legup/images/lightup/" + num + ".gif");
if (num > 3 || num < 1) num = 1;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
LTUP-BASC-0001 : BulbsOutsideDiagonalBasicRule
LTUP-BASC-0002 : EmptyCellInLightBasicRule
LTUP-BASC-0003 : EmptyCornersBasicRule
LTUP-BASC-0004 : FinishWithBulbsBasicRule
LTUP-BASC-0005 : FinishWithEmptyBasicRule
LTUP-BASC-0006 : MustLightBasicRule
LTUP-BASC-0001 : EmptyCellInLightBasicRule
LTUP-BASC-0002 : EmptyCornersBasicRule
LTUP-BASC-0003 : FinishWithBulbsBasicRule
LTUP-BASC-0004 : FinishWithEmptyBasicRule
LTUP-BASC-0005 : MustLightBasicRule

LTUP-CONT-0001 : BulbsInPathContradictionRule
LTUP-CONT-0002 : CannotLightACellContradictionRule
Expand Down
39 changes: 25 additions & 14 deletions src/main/java/edu/rpi/legup/ui/CreatePuzzleDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,39 @@ public class CreatePuzzleDialog extends JDialog {
* @param e the event to be processed
*/
@Override
public void actionPerformed(ActionEvent e) {
public void actionPerformed(ActionEvent ae) {
String game = Config.convertDisplayNameToClassName((String) gameBox.getSelectedItem());

// Check if all 3 TextFields are filled
if (game.equals("") || rows.getText().equals("") || columns.getText().equals("")) {
System.out.println("Unfilled fields");
return;
}

try {
homePanel.openEditorWithNewPuzzle(game, Integer.valueOf(rows.getText()), Integer.valueOf(columns.getText()));
setVisible(false);
}
catch (IllegalArgumentException exception) {
// Don't do anything. This is here to prevent the dialog from closing if the dimensions are invalid.
catch (IllegalArgumentException e) {
System.out.println("Failed to open editor with new puzzle");
e.printStackTrace(System.out);
}
}
};

private JButton cancel = new JButton("Cancel");
private ActionListener cancelButtonListener = new ActionListener() {
/**
* Hides the puzzle creation dialog
* Dispose the puzzle creation dialog
*
* @param e the event to be processed
*/
@Override
public void actionPerformed(ActionEvent e) {
setVisible(false);
dispose();
}
};


public CreatePuzzleDialog(JFrame parent, HomePanel homePanel) {
super(parent, true);

Expand Down Expand Up @@ -106,24 +114,27 @@ public CreatePuzzleDialog(JFrame parent, HomePanel homePanel) {
public void initPuzzles() {
this.games = GameBoardFacade.getInstance().getConfig().getFileCreationEnabledPuzzles().toArray(new String[0]);
Arrays.sort(this.games);
gameBox = new JComboBox(GameBoardFacade.getInstance().getConfig().getFileCreationEnabledPuzzleNames().toArray(new String[0]));
gameBox = new JComboBox(this.games);
}

// ^This method seems useless and never got covered
public void actionPerformed(ActionEvent e) {
if (e.getSource() == ok) {
String game = Config.convertDisplayNameToClassName((String) gameBox.getSelectedItem());

try {
this.homePanel.openEditorWithNewPuzzle(game, Integer.valueOf(this.rows.getText()), Integer.valueOf(this.columns.getText()));
setVisible(false);
this.setVisible(false);
}
catch (IllegalArgumentException exception) {
catch (IllegalArgumentException exception) {
// Don't do anything. This is here to prevent the dialog from closing if the dimensions are invalid.
}
}
else {
if (e.getSource() == cancel) {
setVisible(false);
}
else if (e.getSource() == cancel) {
this.setVisible(false);
}
else {
// Unknown Action Event
}
}
}
}
2 changes: 1 addition & 1 deletion src/main/resources/edu/rpi/legup/legup/config
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<puzzle name="LightUp"
qualifiedClassName="edu.rpi.legup.puzzle.lightup.LightUp"
fileType=".xml"
fileCreationDisabled="true"/>
fileCreationDisabled="false"/>
<puzzle name="Masyu"
qualifiedClassName="edu.rpi.legup.puzzle.masyu.Masyu"
fileType=".xml"
Expand Down

This file was deleted.