From bb38732347241c3d686f62d9d9d9d2d7712c1b3c Mon Sep 17 00:00:00 2001 From: Jacob Long Date: Fri, 17 Nov 2023 17:06:08 -0500 Subject: [PATCH] fix treetent puzzle editor (add breaks for switch) (exporter exports same data that importer expects) --- .../rpi/legup/puzzle/treetent/TreeTentCell.java | 16 ++++++++++++++++ .../puzzle/treetent/TreeTentCellFactory.java | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentCell.java b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentCell.java index 290e0858d..b6411a5cf 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentCell.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentCell.java @@ -16,15 +16,31 @@ public TreeTentType getType() { return data; } + public int getValue() { + switch (data) { + case TREE: + return 1; + case GRASS: + return 2; + case TENT: + return 3; + default: + return 0; + } + } + @Override public void setType(Element e, MouseEvent m) { switch (e.getElementName()) { case "Unknown Tile": this.data = TreeTentType.UNKNOWN; + break; case "Tree Tile": this.data = TreeTentType.TREE; + break; case "Grass Tile": this.data = TreeTentType.GRASS; + break; case "Tent Tile": this.data = TreeTentType.TENT; } diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentCellFactory.java b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentCellFactory.java index 969ffdf0f..20b8066a4 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentCellFactory.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentCellFactory.java @@ -83,7 +83,7 @@ public org.w3c.dom.Element exportCell(Document document, PuzzleElement puzzleEle TreeTentCell cell = (TreeTentCell) puzzleElement; Point loc = cell.getLocation(); - cellElement.setAttribute("value", String.valueOf(cell.getData())); + cellElement.setAttribute("value", String.valueOf(cell.getValue())); cellElement.setAttribute("x", String.valueOf(loc.x)); cellElement.setAttribute("y", String.valueOf(loc.y));