generified []# of food is carried over

This commit is contained in:
Yair Morgenstern
2020-08-20 23:45:44 +03:00
parent 408077cd5f
commit 02c2da9347
2 changed files with 10 additions and 8 deletions

View File

@ -325,7 +325,7 @@
"name": "Aqueduct", "name": "Aqueduct",
"maintenance": 1, "maintenance": 1,
"hurryCostModifier": 25, "hurryCostModifier": 25,
"uniques": ["40% of food is carried over after a new citizen is born"], "uniques": ["[40]% of food is carried over after population increases"],
"requiredTech": "Engineering" "requiredTech": "Engineering"
}, },
{ {
@ -845,7 +845,7 @@
"requiredBuilding": "Hospital", "requiredBuilding": "Hospital",
"maintenance": 3, "maintenance": 3,
"requiredTech": "Pharmaceuticals", "requiredTech": "Pharmaceuticals",
"uniques": ["25% of food is carried over after a new citizen is born"] "uniques": ["[25]% of food is carried over after population increases"]
}, },
{ {
"name": "Nuclear Plant", "name": "Nuclear Plant",

View File

@ -47,12 +47,12 @@ class PopulationManager {
fun nextTurn(food: Int) { fun nextTurn(food: Int) {
foodStored += food foodStored += food
if(food < 0) if (food < 0)
cityInfo.civInfo.addNotification("["+cityInfo.name + "] is starving!", cityInfo.location, Color.RED) cityInfo.civInfo.addNotification("[" + cityInfo.name + "] is starving!", cityInfo.location, Color.RED)
if (foodStored < 0) if (foodStored < 0)
// starvation! // starvation!
{ {
if(population>1){ if (population > 1) {
population-- population--
} }
foodStored = 0 foodStored = 0
@ -61,11 +61,13 @@ class PopulationManager {
// growth! // growth!
{ {
foodStored -= getFoodToNextPopulation() foodStored -= getFoodToNextPopulation()
if (cityInfo.containsBuildingUnique("40% of food is carried over after a new citizen is born")) foodStored += (0.4f * getFoodToNextPopulation()).toInt() // Aqueduct special val percentOfFoodCarriedOver = cityInfo.cityConstructions.builtBuildingUniqueMap
if (cityInfo.containsBuildingUnique("25% of food is carried over after a new citizen is born")) foodStored += (0.25f * getFoodToNextPopulation()).toInt() // Medical Lab special .getUniques("[]% of food is carried over after population increases")
.sumBy { it.params[0].toInt() }
foodStored += (getFoodToNextPopulation() * percentOfFoodCarriedOver / 100f).toInt()
population++ population++
autoAssignPopulation() autoAssignPopulation()
cityInfo.civInfo.addNotification("["+cityInfo.name + "] has grown!", cityInfo.location, Color.GREEN) cityInfo.civInfo.addNotification("[" + cityInfo.name + "] has grown!", cityInfo.location, Color.GREEN)
} }
} }