diff options
| author | Jakob L. Kreuze <jakob@memeware.net> | 2019-01-12 14:32:42 -0500 |
|---|---|---|
| committer | Jakob L. Kreuze <jakob@memeware.net> | 2019-01-12 14:32:42 -0500 |
| commit | ef496487ae49a1e98ea3c9de0531ca4716f7cebf (patch) | |
| tree | 139ac23a0c82f3b935dfc3f0aeee7d56cd3630bb /app/src/main/java/space/jakob/mines/GameView.kt | |
| parent | cc84e4eaec11580fcaf0b70a7782566917ed286e (diff) | |
Extract Grid to be primarily a member of GameActivity
Diffstat (limited to 'app/src/main/java/space/jakob/mines/GameView.kt')
| -rw-r--r-- | app/src/main/java/space/jakob/mines/GameView.kt | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/app/src/main/java/space/jakob/mines/GameView.kt b/app/src/main/java/space/jakob/mines/GameView.kt index d0a7ae0..84877e6 100644 --- a/app/src/main/java/space/jakob/mines/GameView.kt +++ b/app/src/main/java/space/jakob/mines/GameView.kt @@ -38,6 +38,7 @@ class GameView(context: Context, attrs: AttributeSet) : View(context, attrs) { val scaledTileWidth: Int get() = (minOf(width, height) / cameraBreadth).toInt() + // Reference to GameActivity's grid that should be treated as read-only. var grid: Grid? = null // All of the state for maintaining the view's current positioning. For an @@ -85,23 +86,10 @@ class GameView(context: Context, attrs: AttributeSet) : View(context, attrs) { } /** - * Reveal and @return the tile at (@param x, @param y). - */ - fun revealAt(x: Int, y: Int): Tile? = grid?.let { - val (x, y) = toGridCoordinates(x.toInt(), y.toInt()) - if (it.valid(x, y)) { - it.reveal(x, y) - return it[x, y] - } else { - return null - } - } - - /** * Flag and @return the tile at (@param x, @param y). */ fun flagAt(x: Int, y: Int): Tile? = grid?.let { - val (x, y) = toGridCoordinates(x.toInt(), y.toInt()) + if (it.valid(x, y)) { it.flag(x, y) return it[x, y] |