Skip to content

Commit

Permalink
Merge branch 'star-battle' of https://github.com/Bram-Hub/LEGUP into …
Browse files Browse the repository at this point in the history
…star-battle
  • Loading branch information
sarah-min committed Mar 29, 2024
2 parents b3452a8 + fe5800b commit 7bfa85b
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Legup version="2.0.0">
<puzzle name="StarBattle">
<board size="6" puzzle_num="1">
<region>
<cells>
<cell value="0" x="0" y="0"/>
<cell value="0" x="0" y="1"/>
<cell value="0" x="1" y="1"/>
</cells>
</region>
<cells>
<cell value="0" x="1" y="0"/>
<cell value="0" x="2" y="0"/>
<cell value="0" x="2" y="1"/>
<cell value="0" x="0" y="2"/>
<cell value="0" x="1" y="2"/>
<cell value="0" x="2" y="2"/>
<cell value="0" x="3" y="2"/>
<cell value="0" x="4" y="2"/>
<cell value="0" x="0" y="3"/>
<cell value="0" x="1" y="3"/>
<cell value="0" x="2" y="3"/>
<cell value="0" x="3" y="3"/>
<cell value="0" x="2" y="4"/>
<cell value="0" x="3" y="4"/>
<cell value="0" x="4" y="4"/>
</cells>
<region>
<cells>
<cell value="0" x="3" y="0"/>
<cell value="0" x="4" y="0"/>
<cell value="0" x="3" y="1"/>
<cell value="0" x="4" y="1"/>
</cells>
</region>
<region>
<cells>
<cell value="0" x="4" y="3"/>
</cells>
</region>
<region>
<cells>
<cell value="0" x="0" y="4"/>
<cell value="0" x="1" y="4"/>
</cells>
</region>
<region>

</region>
</board>
</puzzle>
</Legup>
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,18 @@ public void changeCell(MouseEvent e, PuzzleElement data) {
this.boardView.getSelectionPopupMenu().show(boardView, this.boardView.getCanvas().getX() + e.getX(), this.boardView.getCanvas().getY() + e.getY());
}
else {
if (cell.getData() == 0) {
data.setData(cell.getData() + 1);
if (cell.getData() >= 0) {
data.setData(-3);
}
else {
data.setData(cell.getData() + 1);
}
}
}
else {
if (e.getButton() == MouseEvent.BUTTON3) {
data.setData(cell.getData() - 1);
if (cell.getData() == -3) {
data.setData(0);
}
else {
data.setData(cell.getData() - 1);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@
import java.awt.*;

public class StarBattleView extends GridBoardView {
private static final Logger LOGGER = LogManager.getLogger(StarBattleView.class.getName());

static Image STAR;

static {
try {
STAR = ImageIO.read(ClassLoader.getSystemResourceAsStream("edu/rpi/legup/images/starbattle/star.png"));
STAR = ImageIO.read(ClassLoader.getSystemClassLoader().getResource("edu/rpi/legup/images/starbattle/star.gif"));
}
catch (IOException e) {
LOGGER.error("Failed to open starbattle image.");
// pass
}
}

Expand Down
9 changes: 8 additions & 1 deletion src/main/java/edu/rpi/legup/utility/LegupUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,14 @@ private static List<Class> findClassesZip(String path, String packageName) throw
for (ZipEntry entry = zip.getNextEntry(); entry != null; entry = zip.getNextEntry()) {
if (!entry.isDirectory() && entry.getName().endsWith(".class") && entry.getName().startsWith(packageName)) {
String className = entry.getName().replace('/', '.');
classes.add(Class.forName(className.substring(0, className.length() - ".class".length())));
String substr = className.substring(0, className.length() - ".class".length());
try {
Class<?> c = Class.forName(substr);
classes.add(c);
}
catch (LinkageError | ClassNotFoundException e) {
System.out.println("Failed on " + substr);
}
}
}
return classes;
Expand Down

0 comments on commit 7bfa85b

Please sign in to comment.