Resolved #7008 - Civs get *random* luxury resources near their starting location

This commit is contained in:
Yair Morgenstern
2022-05-30 22:25:52 +03:00
parent ad7397de66
commit 983a9b705e

View File

@ -871,11 +871,9 @@ class MapRegions (val ruleset: Ruleset){
// Pick a luxury at random. Weight is reduced if the luxury has been picked before
val modifiedWeights = candidateLuxuries.map {
val weightingUnique = it.getMatchingUniques(UniqueType.ResourceWeighting, regionConditional).firstOrNull()
if (weightingUnique == null)
1f / (1f + amountRegionsWithLuxury[it.name]!!)
else
weightingUnique.params[0].toFloat() / (1f + amountRegionsWithLuxury[it.name]!!)
}
val relativeWeight = if (weightingUnique == null) 1f else weightingUnique.params[0].toFloat()
relativeWeight / (1f + amountRegionsWithLuxury[it.name]!!)
}.shuffled()
region.luxury = candidateLuxuries.randomWeighted(modifiedWeights).name
amountRegionsWithLuxury[region.luxury!!] = amountRegionsWithLuxury[region.luxury]!! + 1
}
@ -1780,4 +1778,4 @@ class Region (val tileMap: TileMap, val rect: Rectangle, val continentID: Int =
/** Returns number terrains with [name] */
fun getTerrainAmount(name: String) = terrainCounts[name] ?: 0
}
}