Skip to content

Commit

Permalink
Merge pull request #17 from b0r1ngx/b0r1ngx/restrict-creating-mines-m…
Browse files Browse the repository at this point in the history
…ore-than-total-cells

Fix: Issue #16 (description: Restrict creating mines more than total cells)
  • Loading branch information
arkivanov authored Mar 21, 2024
2 parents a32a344 + 21882f6 commit 1d929d9
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,11 @@ internal class DefaultEditSettingsComponent(
val height = _model.value.height.toIntOrNull() ?: return
val maxMines = _model.value.maxMines.toIntOrNull() ?: return

onConfirmed(
GameSettings(
width = width,
height = height,
maxMines = maxMines,
)
)
val finalWidth = width.coerceIn(2..100)
val finalHeight = height.coerceIn(2..50)
val finalMines = maxMines.coerceIn(1 until finalWidth * finalHeight)

onConfirmed(GameSettings(width = finalWidth, height = finalHeight, maxMines = finalMines))
}

override fun onDismissRequested() {
Expand Down

0 comments on commit 1d929d9

Please sign in to comment.