From: TheSaminator Date: Sat, 2 Jul 2022 01:21:28 +0000 (-0400) Subject: Fix number X-Git-Url: https://gitweb.starshipfights.net/?a=commitdiff_plain;h=ff4088cf1e1159ff5f6f2eae33d11ae53d6c5cc9;p=starship-fights Fix number --- 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