summaryrefslogtreecommitdiff
path: root/app/src/main/java/space/jakob/mines/GameView.kt
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/space/jakob/mines/GameView.kt')
-rw-r--r--app/src/main/java/space/jakob/mines/GameView.kt16
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]