mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-22 13:49:54 +07:00
Add unique for increased improvement rates rather than decreased build times (#12680)
* Add unique for increased improvement rates rather than decreased build times * Fix uniques * Ruleset text * Treat mad modder divide by zero
This commit is contained in:
@ -171,7 +171,7 @@
|
||||
"culture": 1,
|
||||
"greatPersonPoints": {"Great Engineer": 1},
|
||||
"isWonder": true,
|
||||
"uniques": ["[-25]% construction time for [All] improvements","[2] free [Worker] units appear"],
|
||||
"uniques": ["Can build [all] improvements at a [+25]% rate","[2] free [Worker] units appear"],
|
||||
"requiredTech": "Masonry",
|
||||
"quote": "'O, let not the pains of death which come upon thee enter into my body. I am the god Tem, and I am the foremost part of the sky, and the power which protecteth me is that which is with all the gods forever.' - The Book of the Dead, translated by Sir Ernest Alfred Wallis Budge"
|
||||
},
|
||||
|
@ -93,7 +93,7 @@
|
||||
{
|
||||
"name": "Citizenship",
|
||||
"uniques": [
|
||||
"[-25]% construction time for [All] improvements",
|
||||
"Can build [all] improvements at a [+25]% rate",
|
||||
"Free [Worker] appears",
|
||||
"[-100]% weight to this choice for AI decisions"
|
||||
],
|
||||
|
@ -152,7 +152,7 @@
|
||||
"culture": 1,
|
||||
"greatPersonPoints": {"Great Engineer": 1},
|
||||
"isWonder": true,
|
||||
"uniques": ["[-25]% construction time for [All] improvements","[2] free [Worker] units appear"],
|
||||
"uniques": ["Can build [all] improvements at a [+25]% rate","[2] free [Worker] units appear"],
|
||||
"requiredTech": "Masonry",
|
||||
"quote": "'O, let not the pains of death which come upon thee enter into my body. I am the god Tem, and I am the foremost part of the sky, and the power which protecteth me is that which is with all the gods forever.' - The Book of the Dead, translated by Sir Ernest Alfred Wallis Budge"
|
||||
},
|
||||
|
@ -93,7 +93,7 @@
|
||||
{
|
||||
"name": "Citizenship",
|
||||
"uniques": [
|
||||
"[-25]% construction time for [All] improvements",
|
||||
"Can build [all] improvements at a [+25]% rate",
|
||||
"Free [Worker] appears"
|
||||
],
|
||||
"row": 1,
|
||||
|
@ -31,10 +31,16 @@ class TileImprovement : RulesetStatsObject() {
|
||||
|
||||
fun getTurnsToBuild(civInfo: Civilization, unit: MapUnit): Int {
|
||||
val state = StateForConditionals(civInfo, unit = unit)
|
||||
|
||||
val buildSpeedUniques = unit.getMatchingUniques(UniqueType.SpecificImprovementTime, state, checkCivInfoUniques = true)
|
||||
.filter { matchesFilter(it.params[1], state) }
|
||||
return buildSpeedUniques
|
||||
.fold(turnsToBuild.toFloat() * civInfo.gameInfo.speed.improvementBuildLengthModifier) { calculatedTurnsToBuild, unique ->
|
||||
.filter { matchesFilter(it.params[1], state) }
|
||||
val buildSpeedIncreases = unit.getMatchingUniques(UniqueType.ImprovementTimeIncrease, state, checkCivInfoUniques = true)
|
||||
.filter { matchesFilter(it.params[0], state) }
|
||||
val increase = buildSpeedIncreases.sumOf { it.params[1].toDouble() }.toFloat().toPercent()
|
||||
val buildTime = if (increase == 0f) 0f
|
||||
else (civInfo.gameInfo.speed.improvementBuildLengthModifier * turnsToBuild / increase)
|
||||
|
||||
return buildSpeedUniques.fold(buildTime) { calculatedTurnsToBuild, unique ->
|
||||
calculatedTurnsToBuild * unique.params[0].toPercent()
|
||||
}.roundToInt()
|
||||
.coerceAtLeast(1)
|
||||
|
@ -133,6 +133,7 @@ enum class UniqueType(
|
||||
RoadMaintenance("[relativeAmount]% maintenance on road & railroads", UniqueTarget.Global),
|
||||
NoImprovementMaintenanceInSpecificTiles("No Maintenance costs for improvements in [tileFilter] tiles", UniqueTarget.Global),
|
||||
SpecificImprovementTime("[relativeAmount]% construction time for [improvementFilter] improvements", UniqueTarget.Global, UniqueTarget.Unit),
|
||||
ImprovementTimeIncrease("Can build [improvementFilter] improvements at a [relativeAmount]% rate", UniqueTarget.Global, UniqueTarget.Unit),
|
||||
|
||||
/// Building Maintenance
|
||||
GainFreeBuildings("Gain a free [buildingName] [cityFilter]", UniqueTarget.Global, UniqueTarget.Triggerable,
|
||||
|
Reference in New Issue
Block a user