Added more object types.

Added Map and Structure. Created a working map int Test.java, but Structures are still not implemented.
This commit is contained in:
2017-11-29 15:50:43 +01:00
parent ad09ee4b1d
commit fc74f55c85
4 changed files with 102 additions and 4 deletions

View File

@ -5,7 +5,7 @@ public class Tile {
private Action action;
private int[] teleportTarget;
public Tile (char representation, boolean solid, String action) {
public Tile (char representation, boolean solid, String action) throws IllegalArgumentException {
this.representation = representation;
this.solid = solid;
this.action = Action.valueOf(action.toUpperCase());
@ -16,12 +16,16 @@ public class Tile {
}
}
public Tile (char representation, boolean solid, String action, int x, int y) {
public Tile (char representation, boolean solid, String action, int x, int y) throws IllegalArgumentException {
this.representation = representation;
this.solid = solid;
this.action = Action.valueOf(action.toUpperCase());
int[] intArray = {x, y};
this.teleportTarget = intArray;
if (this.action == Action.TELEPORT) {
int[] intArray = {x, y};
this.teleportTarget = intArray;
} else {
throw new IllegalArgumentException("A non-teleport tile can't have a teleport target.");
}
}
public char toChar() {