mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-06 16:28:40 +07:00
Resolved #7008 - Civs get *random* luxury resources near their starting location
This commit is contained in:
@ -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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user