From 9bd6c6e6240af50ae2c2d35b528c4dd5dbc350e9 Mon Sep 17 00:00:00 2001 From: Lucas Lima Date: Sun, 28 Jun 2020 14:13:19 -0300 Subject: [PATCH] Fix lint --- .../level/repository/MinefieldRepository.kt | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/common/src/main/java/dev/lucasnlm/antimine/common/level/repository/MinefieldRepository.kt b/common/src/main/java/dev/lucasnlm/antimine/common/level/repository/MinefieldRepository.kt index 2b54fb2b..73e2939c 100644 --- a/common/src/main/java/dev/lucasnlm/antimine/common/level/repository/MinefieldRepository.kt +++ b/common/src/main/java/dev/lucasnlm/antimine/common/level/repository/MinefieldRepository.kt @@ -37,15 +37,13 @@ class MinefieldRepository : IMinefieldRepository { val fieldSize = dimensionRepository.areaSize() val display = dimensionRepository.displaySize() + val calculatedWidth = ((display.width / fieldSize).toInt() - HORIZONTAL_STANDARD_GAP) + val calculatedHeight = ((display.height / fieldSize).toInt() - VERTICAL_STANDARD_GAP) + val finalWidth = calculatedWidth.coerceAtLeast(MIN_STANDARD_WIDTH) + val finalHeight = calculatedHeight.coerceAtLeast(MIN_STANDARD_HEIGHT) + val finalMines = (finalWidth * finalHeight * CUSTOM_LEVEL_RATIO).toInt() - val finalWidth = ((display.width / fieldSize).toInt() - 1).coerceAtLeast(6) - val finalHeight = ((display.height / fieldSize).toInt() - 3).coerceAtLeast(9) - - return Minefield( - finalWidth, - finalHeight, - (finalWidth * finalHeight * customLevelRatio).toInt() - ) + return Minefield(finalWidth, finalHeight, finalMines) } override fun randomSeed(): Long = Random.nextLong() @@ -54,6 +52,11 @@ class MinefieldRepository : IMinefieldRepository { private val beginnerMinefield = Minefield(9, 9, 10) private val intermediateMinefield = Minefield(16, 16, 40) private val expertMinefield = Minefield(24, 24, 99) - private const val customLevelRatio = 0.2 + + private const val CUSTOM_LEVEL_RATIO = 0.2 + private const val HORIZONTAL_STANDARD_GAP = 1 + private const val VERTICAL_STANDARD_GAP = 3 + private const val MIN_STANDARD_WIDTH = 6 + private const val MIN_STANDARD_HEIGHT = 9 } }