diff --git a/src/main/kotlin/World.kt b/src/main/kotlin/World.kt index 241293a..484842c 100644 --- a/src/main/kotlin/World.kt +++ b/src/main/kotlin/World.kt @@ -26,6 +26,10 @@ object World { tiles.value[tile.x()][tile.y()] = to } + fun get(tile: Tile): TileProperties { + return tiles.value[tile.x()][tile.y()] + } + //Returns a coordinate pair fun getRandomLocation(): Tile { return Tile((0.. { val adj = mutableSetOf() val dirs = Directions.ALL @@ -50,9 +50,9 @@ value class Tile(private val value: ULong) { val candidateTile = this + dir //Ensure that the tile is within bounds - if(candidateTile.isInBounds() && candidateTile.getProperties().visited() == explored) + if(candidateTile.isInBounds() && World.get(candidateTile).visited() == explored) { - println("$this+$dir --> $candidateTile") + //println("$this+$dir --> $candidateTile") adj.add(candidateTile) } } @@ -61,24 +61,17 @@ value class Tile(private val value: ULong) { return adj } - - - fun hasConnections(): Boolean { - return getProperties().connections != 0 - } - - //Arguments could be made for either World or Tile knowing whether a Tile is in bounds fun isInBounds(): Boolean { return x() >= 0 && y() >= 0 && - x() < World.tiles.value.size && - y() < World.tiles.value.get(0).size + x() < World.sizeX && + y() < World.sizeY } //Get the properties of the tile at the given coordinates fun getProperties(): TileProperties { - return World.tiles.value.get(x()).get(y()) + return World.get(this) } //Get tile at given direction @@ -91,6 +84,8 @@ value class Tile(private val value: ULong) { } + //Debug function to print the coordinates of this Tile + @SuppressWarnings fun getCoordinates(): Pair { return Pair(x(), y()) }