Skip to content

Commit

Permalink
fix filapix puzzle and non-puzzle .xml files display
Browse files Browse the repository at this point in the history
  • Loading branch information
hansongu123 committed Aug 9, 2023
1 parent 4fa284b commit 912000f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Legup version="3.0.0">
<lastSaved time="2023-07-28 16:14:19"/>
<puzzle name="Fillapix">
<board height="10" width="10">
<cells>
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/edu/rpi/legup/ui/HomePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,15 @@ private void recursive_parser(File folder, BufferedWriter writer, String path, S
public void startDocument() throws SAXException {
}
boolean solvedFlagExists = false;
boolean puzzleTypeExists = false;
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
// append file type to the writer
if (qName.equals("puzzle") && attributes.getQName(0) == "name") {
if (qName.equals("puzzle") && attributes.getQName(0) == "name" && !puzzleTypeExists) {
try {
writer.write(attributes.getValue(0));
writer.write(",");
puzzleTypeExists = true;
}
catch (IOException e) {
throw new RuntimeException(e);
Expand Down Expand Up @@ -431,7 +433,15 @@ public void endElement(String uri, String localName, String qName) throws SAXExc
}
@Override
public void endDocument() throws SAXException {
if (!solvedFlagExists) {
if (!puzzleTypeExists) {
try {
writer.write("not a LEGUP puzzle!");
}
catch (IOException e) {
throw new RuntimeException(e);
}
}
else if (!solvedFlagExists) {
try {
writer.write("missing flag!");
}
Expand Down

0 comments on commit 912000f

Please sign in to comment.