All resource stats from buildings converted to building uniques

This commit is contained in:
Yair Morgenstern
2021-02-22 23:00:48 +02:00
parent 0ef44fc4da
commit 4bd40125b0
4 changed files with 59 additions and 52 deletions

View File

@ -20,9 +20,11 @@
{ {
"name": "Granary", "name": "Granary",
"food": 2, "food": 2,
"resourceBonusStats": {"food": 1},
"maintenance": 1, "maintenance": 1,
"hurryCostModifier": 25, "hurryCostModifier": 25,
"uniques": ["[+1 Food] from [Deer] tiles in this city",
"[+1 Food] from [Bananas] tiles in this city",
"[+1 Food] from [Wheat] tiles in this city"]
"requiredTech": "Pottery" "requiredTech": "Pottery"
}, },
{ {
@ -30,10 +32,11 @@
"happiness": 1, "happiness": 1,
"production": 1, "production": 1,
"requiredNearbyImprovedResources": ["Marble", "Stone"], "requiredNearbyImprovedResources": ["Marble", "Stone"],
"resourceBonusStats": {"production": 1},
"maintenance": 1, "maintenance": 1,
"hurryCostModifier": 0, "hurryCostModifier": 0,
"uniques": ["Must not be on [Plains]"], "uniques": ["Must not be on [Plains]",
"[+1 Production] from [Stone] tiles in this city",
"[+1 Production] from [Marble] tiles in this city"],
"requiredTech": "Calendar" "requiredTech": "Calendar"
}, },
{ {
@ -189,8 +192,8 @@
"name": "Lighthouse", "name": "Lighthouse",
"hurryCostModifier": 25, "hurryCostModifier": 25,
"maintenance": 1, "maintenance": 1,
"resourceBonusStats": {"food": 1}, "uniques": ["Must be next to [Coast]", "[+1 Food] from [Ocean] tiles in this city",
"uniques": ["Must be next to [Coast]", "[+1 Food] from [Ocean] tiles in this city", "[+1 Food] from [Coast] tiles in this city"], "[+1 Food] from [Coast] tiles in this city", "[+1 Food] from [Fish] tiles in this city" ],
"requiredTech": "Optics" "requiredTech": "Optics"
}, },
{ {
@ -207,9 +210,11 @@
"name": "Stable", "name": "Stable",
"maintenance": 1, "maintenance": 1,
"requiredNearbyImprovedResources": ["Horses","Sheep","Cattle"], "requiredNearbyImprovedResources": ["Horses","Sheep","Cattle"],
"resourceBonusStats": {"production": 1},
"hurryCostModifier": 25, "hurryCostModifier": 25,
"uniques": ["+[15]% Production when constructing [Mounted] units [in this city]"] "uniques": ["+[15]% Production when constructing [Mounted] units [in this city]",
"[+1 Production] from [Cattle] tiles in this city",
"[+1 Production] from [Horses] tiles in this city",
"[+1 Production] from [Sheep] tiles in this city"]
"requiredTech": "Horseback Riding" "requiredTech": "Horseback Riding"
}, },
{ {
@ -335,9 +340,9 @@
{ {
"name": "Mint", "name": "Mint",
"maintenance": 0, "maintenance": 0,
"requiredNearbyImprovedResources": ["Gold","Silver"], "requiredNearbyImprovedResources": ["Gold", "Silver"]
"resourceBonusStats": {"gold": 2},
"hurryCostModifier": 25, "hurryCostModifier": 25,
"uniques": ["[+2 Gold] from [Gold] tiles in this city", "[+2 Gold] from [Silver] tiles in this city"],
"requiredTech": "Currency" "requiredTech": "Currency"
}, },
/* /*
@ -392,7 +397,7 @@
"name": "Monastery", "name": "Monastery",
"maintenance": 0, "maintenance": 0,
"requiredNearbyImprovedResources": ["Wine","Incense"], "requiredNearbyImprovedResources": ["Wine","Incense"],
"resourceBonusStats": {"culture": 2}, "uniques": ["[+2 Culture] from [Wine] tiles in this city", "[+2 Culture] from [Incense] tiles in this city"],
"hurryCostModifier": 25, "hurryCostModifier": 25,
"requiredTech": "Theology" "requiredTech": "Theology"
}, },
@ -461,10 +466,10 @@
"maintenance": 1, "maintenance": 1,
"hurryCostModifier": 25, "hurryCostModifier": 25,
"requiredNearbyImprovedResources": ["Iron"], "requiredNearbyImprovedResources": ["Iron"],
"resourceBonusStats": {"production": 1},
"requiredTech": "Metal Casting", "requiredTech": "Metal Casting",
"uniques": ["+[15]% Production when constructing [Spaceship part] units [in this city]", "uniques": ["+[15]% Production when constructing [Spaceship part] units [in this city]",
"+[15]% Production when constructing [Land] units [in this city]"] "+[15]% Production when constructing [Land] units [in this city]",
"[+1 Production] from [Iron] tiles in this city"]
}, },
{ {
"name": "Harbor", "name": "Harbor",

View File

@ -7,7 +7,6 @@
"food": 1, "food": 1,
"improvement": "Pasture", "improvement": "Pasture",
"improvementStats": {"production": 1}, "improvementStats": {"production": 1},
"building": "Stable"
}, },
{ {
"name": "Sheep", "name": "Sheep",
@ -15,8 +14,7 @@
"terrainsCanBeFoundOn": ["Plains","Hill"], "terrainsCanBeFoundOn": ["Plains","Hill"],
"food": 1, "food": 1,
"improvement": "Pasture", "improvement": "Pasture",
"improvementStats": {"food": 1}, "improvementStats": {"food": 1}
"building": "Stable"
}, },
{ {
"name": "Deer", "name": "Deer",
@ -24,8 +22,7 @@
"terrainsCanBeFoundOn": ["Forest","Tundra"], "terrainsCanBeFoundOn": ["Forest","Tundra"],
"food": 1, "food": 1,
"improvement": "Camp", "improvement": "Camp",
"improvementStats": {"production": 1}, "improvementStats": {"production": 1}
"building": "Granary"
}, },
{ {
"name": "Bananas", "name": "Bananas",
@ -33,8 +30,7 @@
"terrainsCanBeFoundOn": ["Jungle"], "terrainsCanBeFoundOn": ["Jungle"],
"food": 1, "food": 1,
"improvement": "Plantation", "improvement": "Plantation",
"improvementStats": {"food": 2,"production": -1}, "improvementStats": {"food": 2,"production": -1}
"building": "Granary"
}, },
{ {
"name": "Wheat", "name": "Wheat",
@ -42,8 +38,7 @@
"terrainsCanBeFoundOn": ["Plains","Flood plains","Desert"], "terrainsCanBeFoundOn": ["Plains","Flood plains","Desert"],
"food": 1, "food": 1,
"improvement": "Farm", "improvement": "Farm",
"improvementStats": {"food": 1}, "improvementStats": {"food": 1}
"building": "Granary"
}, },
{ {
"name": "Stone", "name": "Stone",
@ -52,7 +47,6 @@
"production": 1, "production": 1,
"improvement": "Quarry", "improvement": "Quarry",
"improvementStats": {"production": 1}, "improvementStats": {"production": 1},
"building": "Stone Works"
}, },
{ {
"name": "Fish", "name": "Fish",
@ -60,8 +54,7 @@
"terrainsCanBeFoundOn": ["Coast"], "terrainsCanBeFoundOn": ["Coast"],
"food": 1, "food": 1,
"improvement": "Fishing Boats", "improvement": "Fishing Boats",
"improvementStats": {"food": 1}, "improvementStats": {"food": 1}
"building": "Lighthouse"
}, },
/* /*
{ {
@ -70,8 +63,7 @@
"terrainsCanBeFoundOn": ["Plains","Grassland"], "terrainsCanBeFoundOn": ["Plains","Grassland"],
"food": 1, "food": 1,
"improvement": "Camp", "improvement": "Camp",
"improvementStats": {"food": 1}, "improvementStats": {"food": 1}
"building": "Granary"
}, },
*/ */
@ -83,8 +75,7 @@
"terrainsCanBeFoundOn": ["Plains","Grassland","Hill","Desert"], "terrainsCanBeFoundOn": ["Plains","Grassland","Hill","Desert"],
"production": 1, "production": 1,
"improvement": "Pasture", "improvement": "Pasture",
"improvementStats": {"production": 1}, "improvementStats": {"production": 1}
"building": "Stable"
}, },
{ {
"name": "Iron", "name": "Iron",
@ -93,8 +84,7 @@
"terrainsCanBeFoundOn": ["Grassland","Plains","Desert","Tundra","Snow","Hill"], "terrainsCanBeFoundOn": ["Grassland","Plains","Desert","Tundra","Snow","Hill"],
"production": 1, "production": 1,
"improvement": "Mine", "improvement": "Mine",
"improvementStats": {"production": 1}, "improvementStats": {"production": 1}
"building": "Forge"
}, },
{ {
"name": "Coal", "name": "Coal",
@ -172,8 +162,7 @@
"terrainsCanBeFoundOn": ["Grassland","Plains","Desert","Hill"], "terrainsCanBeFoundOn": ["Grassland","Plains","Desert","Hill"],
"gold": 2, "gold": 2,
"improvement": "Mine", "improvement": "Mine",
"improvementStats": {"gold": 1}, "improvementStats": {"gold": 1}
"building": "Mint"
}, },
{ {
"name": "Silver", "name": "Silver",
@ -181,8 +170,7 @@
"terrainsCanBeFoundOn": ["Desert","Tundra","Hill"], "terrainsCanBeFoundOn": ["Desert","Tundra","Hill"],
"gold": 2, "gold": 2,
"improvement": "Mine", "improvement": "Mine",
"improvementStats": {"gold": 1}, "improvementStats": {"gold": 1}
"building": "Mint"
}, },
{ {
"name": "Incense", "name": "Incense",
@ -190,8 +178,7 @@
"terrainsCanBeFoundOn": ["Plains","Desert"], "terrainsCanBeFoundOn": ["Plains","Desert"],
"gold": 2, "gold": 2,
"improvement": "Plantation", "improvement": "Plantation",
"improvementStats": {"gold": 1}, "improvementStats": {"gold": 1}
"building": "Monastery"
}, },
{ {
"name": "Ivory", "name": "Ivory",
@ -223,8 +210,7 @@
"terrainsCanBeFoundOn": ["Grassland","Plains"], "terrainsCanBeFoundOn": ["Grassland","Plains"],
"gold": 2, "gold": 2,
"improvement": "Plantation", "improvement": "Plantation",
"improvementStats": {"gold": 1}, "improvementStats": {"gold": 1}
"building": "Monastery"
}, },
{ {
"name": "Sugar", "name": "Sugar",
@ -241,8 +227,7 @@
"gold": 2, "gold": 2,
"improvement": "Quarry", "improvement": "Quarry",
"improvementStats": {"gold": 1,"production": 1}, "improvementStats": {"gold": 1,"production": 1},
"unique": "+15% production towards Wonder construction", "unique": "+15% production towards Wonder construction"
"building": "Stone Works"
}, },
{ {
"name": "Whales", "name": "Whales",
@ -270,7 +255,6 @@
"gold": 1, "gold": 1,
"improvement": "Plantation", "improvement": "Plantation",
"improvementStats": {"food": 1,"gold": 1}, "improvementStats": {"food": 1,"gold": 1},
"building": "Granary"
}, },
{ {
"name": "Copper", "name": "Copper",

View File

@ -8,6 +8,7 @@ import com.unciv.models.ruleset.tile.TileImprovement
import com.unciv.models.stats.NamedStats import com.unciv.models.stats.NamedStats
import com.unciv.models.stats.Stat import com.unciv.models.stats.Stat
import com.unciv.models.stats.Stats import com.unciv.models.stats.Stats
import com.unciv.models.translations.fillPlaceholders
import com.unciv.models.translations.tr import com.unciv.models.translations.tr
import java.util.* import java.util.*
import kotlin.collections.ArrayList import kotlin.collections.ArrayList
@ -66,6 +67,7 @@ class Building : NamedStats(), IConstruction {
/** /**
* The bonus stats that a resource gets when this building is built * The bonus stats that a resource gets when this building is built
*/ */
@Deprecated("Since 3.13.3 - replaced with '[stats] from [resource] tiles in this city'")
var resourceBonusStats: Stats? = null var resourceBonusStats: Stats? = null
fun getShortDescription(ruleset: Ruleset): String { // should fit in one line fun getShortDescription(ruleset: Ruleset): String { // should fit in one line
@ -75,21 +77,35 @@ class Building : NamedStats(), IConstruction {
for (stat in getStatPercentageBonuses(null).toHashMap()) for (stat in getStatPercentageBonuses(null).toHashMap())
if (stat.value != 0f) infoList += "+${stat.value.toInt()}% ${stat.key.toString().tr()}" if (stat.value != 0f) infoList += "+${stat.value.toInt()}% ${stat.key.toString().tr()}"
val improvedResources = ruleset.tileResources.values.filter { it.building == name }.map { it.name.tr() } val improvedResources = ruleset.tileResources.values.asSequence().filter { it.building == name }.map { it.name.tr() }
if (improvedResources.isNotEmpty()) { if (improvedResources.any()) {
// buildings that improve resources // buildings that improve resources
infoList += improvedResources.joinToString() + " {provide} ".tr() + resourceBonusStats.toString() infoList += improvedResources.joinToString() + " {provide} " + resourceBonusStats.toString()
} }
if (requiredNearbyImprovedResources != null) if (requiredNearbyImprovedResources != null)
infoList += ("Requires worked [" + requiredNearbyImprovedResources!!.joinToString("/") { it.tr() } + "] near city").tr() infoList += "Requires worked [" + requiredNearbyImprovedResources!!.joinToString("/") { it.tr() } + "] near city"
if (uniques.isNotEmpty()) { if (uniques.isNotEmpty()) {
if (replacementTextForUniques != "") infoList += replacementTextForUniques if (replacementTextForUniques != "") infoList += replacementTextForUniques
else infoList += uniques.joinToString { it.tr() } else infoList += getUniquesStrings()
} }
if (cityStrength != 0) infoList += "{City strength} +".tr() + cityStrength if (cityStrength != 0) infoList += "{City strength} +$cityStrength"
if (cityHealth != 0) infoList += "{City health} +".tr() + cityHealth if (cityHealth != 0) infoList += "{City health} +$cityHealth"
if (xpForNewUnits != 0) infoList += "+$xpForNewUnits {XP for new units}".tr() if (xpForNewUnits != 0) infoList += "+$xpForNewUnits {XP for new units}"
return infoList.joinToString() return infoList.joinToString("; ") { it.tr() }
}
fun getUniquesStrings(): ArrayList<String> {
val tileBonusHashmap = HashMap<String, ArrayList<String>>()
val finalUniques = ArrayList<String>()
for (unique in uniqueObjects)
if (unique.placeholderText == "[] from [] tiles in this city") {
val stats = unique.params[0]
if (!tileBonusHashmap.containsKey(stats)) tileBonusHashmap[stats] = ArrayList()
tileBonusHashmap[stats]!!.add(unique.params[1])
} else finalUniques += unique.text
for ((key, value) in tileBonusHashmap)
finalUniques += "[stats] from [tileFilter] tiles in this city".fillPlaceholders(key, value.joinToString { it.tr() })
return finalUniques
} }
fun getDescription(forBuildingPickerScreen: Boolean, civInfo: CivilizationInfo?, ruleset: Ruleset): String { fun getDescription(forBuildingPickerScreen: Boolean, civInfo: CivilizationInfo?, ruleset: Ruleset): String {
@ -113,10 +129,10 @@ class Building : NamedStats(), IConstruction {
stringBuilder.appendLine("Provides a free [$providesFreeBuilding] in the city".tr()) stringBuilder.appendLine("Provides a free [$providesFreeBuilding] in the city".tr())
if (uniques.isNotEmpty()) { if (uniques.isNotEmpty()) {
if (replacementTextForUniques != "") stringBuilder.appendLine(replacementTextForUniques) if (replacementTextForUniques != "") stringBuilder.appendLine(replacementTextForUniques)
else stringBuilder.appendLine(uniques.asSequence().map { it.tr() }.joinToString("\n")) else stringBuilder.appendLine(getUniquesStrings().asSequence().map { it.tr() }.joinToString("\n"))
} }
if (!stats.isEmpty()) if (!stats.isEmpty())
stringBuilder.appendln(stats) stringBuilder.appendLine(stats.toString())
val percentStats = getStatPercentageBonuses(civInfo) val percentStats = getStatPercentageBonuses(civInfo)
if (percentStats.production != 0f) stringBuilder.append("+" + percentStats.production.toInt() + "% {Production}\n".tr()) if (percentStats.production != 0f) stringBuilder.append("+" + percentStats.production.toInt() + "% {Production}\n".tr())

View File

@ -15,7 +15,9 @@ class TileResource : NamedStats() {
/** /**
* The building that improves this resource, if any. E.G.: Granary for wheat, Stable for cattle. * The building that improves this resource, if any. E.G.: Granary for wheat, Stable for cattle.
*
*/ */
@Deprecated("Since 3.13.3 - replaced with '[stats] from [resource] tiles in this city' unique in the building")
var building: String? = null var building: String? = null
var revealedBy: String? = null var revealedBy: String? = null
var unique: String? = null var unique: String? = null