This commit is contained in:
Lucas Lima 2020-06-28 14:13:19 -03:00
parent c1ee9e3e80
commit 9bd6c6e624
No known key found for this signature in database
GPG key ID: 0259A3F43EC1027A

View file

@ -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
}
}