diff options
Diffstat (limited to 'app/src/main/java/space/jakob/mines/Grid.kt')
| -rw-r--r-- | app/src/main/java/space/jakob/mines/Grid.kt | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/app/src/main/java/space/jakob/mines/Grid.kt b/app/src/main/java/space/jakob/mines/Grid.kt index b61f5f1..2eec411 100644 --- a/app/src/main/java/space/jakob/mines/Grid.kt +++ b/app/src/main/java/space/jakob/mines/Grid.kt @@ -31,12 +31,17 @@ class Grid(val width: Int, val height: Int, val tiles: Array<Tile>) { } private fun index(x: Int, y: Int) = y * width + x - private fun valid(x: Int, y: Int) = y in 0 until height && x in 0 until width private fun place(x: Int, y: Int, tile: Tile) { tiles[index(x, y)] = tile } /** + * Returns whether or not @see get on the given index would raise an + * @exception IllegalArgumentException + */ + fun valid(x: Int, y: Int) = y in 0 until height && x in 0 until width + + /** * Returns the tile at the given coordinates. * * @throws IllegalArgumentException if the X coordinate is outside |