From ff4088cf1e1159ff5f6f2eae33d11ae53d6c5cc9 Mon Sep 17 00:00:00 2001 From: TheSaminator Date: Fri, 1 Jul 2022 21:21:28 -0400 Subject: [PATCH] Fix number --- .../net/starshipfights/campaign/cluster_params.kt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/commonMain/kotlin/net/starshipfights/campaign/cluster_params.kt b/src/commonMain/kotlin/net/starshipfights/campaign/cluster_params.kt index 769ed75..42b6ae4 100644 --- a/src/commonMain/kotlin/net/starshipfights/campaign/cluster_params.kt +++ b/src/commonMain/kotlin/net/starshipfights/campaign/cluster_params.kt @@ -4,6 +4,7 @@ import kotlinx.serialization.Serializable import kotlin.math.ceil import kotlin.math.floor import kotlin.math.roundToInt +import kotlin.random.Random enum class ClusterSize(val maxStars: Int, val maxHyperlaneDistanceFactor: Double) { SMALL(15, 1.5), MEDIUM(25, 2.0), LARGE(35, 2.5); @@ -27,13 +28,19 @@ enum class ClusterPlanetDensity(val chanceToAdd: Double) { } enum class ClusterCorruption(val corruptedStarsPortion: Double) { - SACROSANCT(0.05), MATERIAL(0.15), INFERNAL(0.25); + SACROSANCT(0.075), MATERIAL(0.15), INFERNAL(0.3); fun getNumCorruptedStars(size: ClusterSize): Int { - val min = floor(corruptedStarsPortion * size.maxStars).roundToInt() - val max = ceil(corruptedStarsPortion * size.maxStars).roundToInt() + val corruptedStars = corruptedStarsPortion * size.maxStars + val min = floor(corruptedStars).roundToInt() + val max = ceil(corruptedStars).roundToInt() - return (min..max).random() + val chance = corruptedStars - min + + return if (Random.nextDouble() < chance) + max + else + min } val displayName: String -- 2.25.1