diff --git a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpCell.java b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpCell.java index 36e5a5088..715b34d11 100644 --- a/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpCell.java +++ b/src/main/java/edu/rpi/legup/puzzle/lightup/LightUpCell.java @@ -67,6 +67,50 @@ public LightUpCellType getType() { return null; } + /** + * Sets the type of this LightUpCell + * + * @param e element to set the type of this LightUp cell to + * @param m mouse event being processed + */ + @Override + public void setType(Element e, MouseEvent m) { + switch(e.getElementName()) { + case "Black Tile": + this.data = -1; + break; + case "Bulb Tile": + this.data = -4; + break; + case "Number Tile": + if (m.getButton() == MouseEvent.BUTTON1) { + // Place a number tile if not a number tile + if (this.data < 0 || this.data >= 9) { + this.data = 1; + } + else { + // Increase number + this.data++; + } + } + else { + if (m.getButton() == MouseEvent.BUTTON3) { + // Decrease number value (down to 1) if pressing number tile + if (this.data > 1 && this.data <= 8) { + this.data--; + } + else { + this.data = 1; + } + } + } + break; + default: + this.data = -3; + break; + } + } + public boolean isLite() { return isLite; } 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..c67bc9217 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentCell.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentCell.java @@ -21,12 +21,16 @@ 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; + break; } } 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..3f87c5d72 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentCellFactory.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentCellFactory.java @@ -28,7 +28,7 @@ public PuzzleElement importCell(Node node, Board board) throws InvalidFileFormat NamedNodeMap attributeList = node.getAttributes(); if (node.getNodeName().equalsIgnoreCase("cell")) { - int value = Integer.valueOf(attributeList.getNamedItem("value").getNodeValue()); + int value = TreeTentType.valueToInt(attributeList.getNamedItem("value").getNodeValue()); int x = Integer.valueOf(attributeList.getNamedItem("x").getNodeValue()); int y = Integer.valueOf(attributeList.getNamedItem("y").getNodeValue()); if (x >= width || y >= height) { diff --git a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentType.java b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentType.java index 890cdfe29..cea266ea9 100644 --- a/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentType.java +++ b/src/main/java/edu/rpi/legup/puzzle/treetent/TreeTentType.java @@ -18,4 +18,17 @@ public static TreeTentType valueOf(int num) { return UNKNOWN; } } + + public static int valueToInt(String value) { + switch(value) { + case "TREE": + return 1; + case "GRASS": + return 2; + case "TENT": + return 3; + default: + return 0; + } + } } \ No newline at end of file