Spruced up Civilopedia - phase 5 - buildings (#4391)

* Spruced up Civilopedia - phase 5 - buildings

* Finish merging master into Civilopedia-Buildings

* Spruced up Civilopedia - phase 5 - buildings - patch

* Spruced up Civilopedia - phase 5 - buildings - patch2

* Spruced up Civilopedia - phase 5 - buildings - patch3

* Spruced up Civilopedia - phase 5 - buildings - patch4

* Spruced up Civilopedia - phase 5 - buildings - patch5
This commit is contained in:
SomeTroglodyte 2021-07-19 20:48:51 +02:00 committed by GitHub
parent 118c1fc888
commit 50cec97354
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 183 additions and 36 deletions

View File

@ -33,6 +33,7 @@ Requires [buildingName] to be built in the city = Benötigt den Bau von [buildin
Requires [buildingName] to be built in all cities = Benötigt den Bau von [buildingName] in allen Städten
Provides a free [buildingName] in the city = Stellt das Gebäude [buildingName] in der Stadt kostenlos bereit
Requires worked [resource] near city = Benötigt eine Bewirtschaftung von [resource] in der Nähe der Stadt
Requires at least one of the following resources worked near the city: = Benötigt mindestens eine der folgenden Ressourcen bewirtschaftet in der Nähe der Stadt:
Wonder is being built elsewhere = Das Wunder wird woanders gebaut
National Wonder is being built elsewhere = Das Nationale Wunder wird woanders gebaut
Requires a [buildingName] in all cities = Benötigt das Gebäude [buildingName] in allen Städten
@ -42,6 +43,7 @@ Consumes [amount] [resource] = Verbraucht [amount] [resource]
Required tech: [requiredTech] = Benötigt Technologie: [requiredTech]
Requires [PolicyOrNationalWonder] = Benötigt [PolicyOrNationalWonder]
Cannot be purchased = Kann nicht gekauft werden
See also = Siehe auch
Current construction = Aktuelle Produktion
Construction queue = Produktionswarteschlange
@ -599,6 +601,7 @@ Maintenance cost = Wartungskosten
Pick construction = Produktion auswählen
Pick improvement = Verbesserung auswählen
Provides [resource] = Stellt [resource] zur Verfügung
Provides [amount] [resource] = Stellt [amount] × [resource] zur Verfügung
Replaces [improvement] = Ersetzt [improvement]
Pick now! = Wähle jetzt!
Build [building] = [building] bauen
@ -1007,6 +1010,7 @@ Dogfighting I = Kurvenkampf I
Dogfighting II = Kurvenkampf II
Dogfighting III = Kurvenkampf III
Choose name for [unitName] = Wähle Namen für [unitName]
[unitFilter] units gain the [promotion] promotion = [unitFilter] Einheiten erhalten die [promotion] Beförderung
# Multiplayer Turn Checker Service
@ -1063,6 +1067,7 @@ Must be on [terrain] = Muss sich auf [terrain] befinden
Can only be built on [tileFilter] tiles = Kann nur auf [tileFilter]-Feldern gebaut werden
Cannot be built on [tileFilter] tiles = Kann nicht auf [tileFilter]-Feldern gebaut werden
Does not need removal of [feature] = Hierfür muß [feature] nicht entfernt werden
Gain a free [building] [cityFilter] = Erhalte [building] umsonst [cityFilter]
# City filters
in this city = in dieser Stadt
@ -1145,7 +1150,7 @@ The Great Lighthouse = Der Große Leuchtturm
Stable = Stall
Cost increases by [amount] per owned city = Kosten erhöhen sich um [amount] per Stadt in Eurem Besitz
Cost increases by [amount] per owned city = Kosten erhöhen sich um [amount] pro Stadt in Eurem Besitz
Circus Maximus = Circus Maximus
Remove extra unhappiness from annexed cities = Entferne zusätzliche Unzufriedenheit von annektierten Städten
@ -1163,7 +1168,7 @@ Terracotta Army = Terrakotta-Armee
National College = Nationale Hochschule
'The ancient Oracle said that I was the wisest of all the Greeks. It is because I alone, of all the Greeks, know that I know nothing' - Socrates = 'Das alte Orakel sagte, dass ich der weiseste aller Griechen sei. Weil ich allein, von allen Griechen, weiß, dass ich nichts weiß.' - Sokrates
Free Social Policy = Kostenloser Sozialpolitik
Free Social Policy = Kostenlose Sozialpolitik
The Oracle = Das Orakel
Amphitheater = Amphitheater
@ -1173,7 +1178,7 @@ Burial Tomb = Grabstätte
Mud Pyramid Mosque = Lehmmoschee
[amount]% great person generation [cityFilter] = [amount]% für die Generierung Großer Persönlichkeiten [cityFilter]
[amount]% great person generation [cityFilter] = Große Persönlichkeiten generieren [amount]% schneller [cityFilter]
National Epic = Nationalepos
Market = Markt
@ -1192,7 +1197,7 @@ Aqueduct = Aquädukt
'The art of war teaches us to rely not on the likelihood of the enemy's not attacking, but rather on the fact that we have made our position unassailable.' - Sun Tzu = 'Die Kunst des Krieges lehrt uns, uns nicht auf die Wahrscheinlichkeit zu verlassen, dass der Feind nicht angreift, sondern auf die Tatsache, dass wir unsere Position unangreifbar gemacht haben.' - Sun Tzu
Enemy land units must spend 1 extra movement point when inside your territory (obsolete upon Dynamite) = Feindliche Landeinheiten müssen 1 extra Bewegungspunkt innerhalb deines Territoriums ausgeben (veraltet durch Dynamit)
Great Wall = die Große Mauer
Great Wall = Die Große Mauer
All newly-trained [unitType] units [cityFilter] receive the [promotion] promotion = Alle neu ausgebildeten [unitType] Einheiten [cityFilter] erhalten die [promotion] Beförderung
Heroic Epic = Heldenepos
@ -1215,7 +1220,7 @@ National Treasury = Nationale Schatzkammer
'Few romances can ever surpass that of the granite citadel on top of the beetling precipices of Machu Picchu, the crown of Inca Land.' - Hiram Bingham = 'Nur wenige Romanzen können jemals die der Granitzitadelle über den bedrohlichen Steilhängen von Machu Picchu, der Krönung des Landes der Inka, übersteigen.' - Hiram Bingham
Gold from all trade routes +25% = Gold von allen Handelsrouten um 25% erhöht
Must have an owned [tileFilter] within [amount] tiles = Benötigt ein [tileFilter] im Besitz innerhalb von [amount] Feldern
Must have an owned [tileFilter] within [amount] tiles = Benötigt [tileFilter] im Besitz innerhalb von [amount] Feldern
Machu Picchu = Machu Picchu
Workshop = Werkstatt
@ -1266,7 +1271,7 @@ Satrap's Court = Satraps Gerichtshaus
Hanse = Hanse
'Most of us can, as we choose, make of this world either a palace or a prison' - John Lubbock = 'Die meisten von uns können, wie sie wollen, aus dieser Welt entweder einen Palast oder ein Gefängnis machen.' - John Lubbock
Unhappiness from population decreased by [amount]% = Unzufriedenheit der Bevölkerung verringert um [amount]%
Unhappiness from population decreased by [amount]% = Unzufriedenheit durch Überbevölkerung verringert um [amount]%
Forbidden Palace = Verbotener Palast
Theatre = Theater

View File

@ -21,6 +21,10 @@ Oh no! It looks like something went DISASTROUSLY wrong! This is ABSOLUTELY not s
# Buildings
Unsellable =
Not displayed as an available construction unless [building] is built =
Not displayed as an available construction without [resource] =
Choose a free great person =
Get [unitName] =
@ -33,6 +37,7 @@ Requires [buildingName] to be built in the city =
Requires [buildingName] to be built in all cities =
Provides a free [buildingName] in the city =
Requires worked [resource] near city =
Requires at least one of the following resources worked near the city: =
Wonder is being built elsewhere =
National Wonder is being built elsewhere =
Requires a [buildingName] in all cities =
@ -42,6 +47,7 @@ Consumes [amount] [resource] =
Required tech: [requiredTech] =
Requires [PolicyOrNationalWonder] =
Cannot be purchased =
See also =
Current construction =
Construction queue =
@ -602,6 +608,7 @@ Maintenance cost =
Pick construction =
Pick improvement =
Provides [resource] =
Provides [amount] [resource] =
Replaces [improvement] =
Pick now! =
Build [building] =
@ -1007,6 +1014,7 @@ Dogfighting I =
Dogfighting II =
Dogfighting III =
Choose name for [unitName] =
[unitFilter] units gain the [promotion] promotion =
# Multiplayer Turn Checker Service
@ -1063,6 +1071,7 @@ Must be on [terrain] =
Can only be built on [tileFilter] tiles =
Cannot be built on [tileFilter] tiles =
Does not need removal of [feature] =
Gain a free [building] [cityFilter] =
# City filters
in this city =

View File

@ -10,11 +10,13 @@ class GreatPersonManager {
var greatGeneralPoints = 0
var freeGreatPeople = 0
val statToGreatPersonMapping = HashMap<Stat, String>().apply {
put(Stat.Science, "Great Scientist")
put(Stat.Production, "Great Engineer")
put(Stat.Gold, "Great Merchant")
put(Stat.Culture, "Great Artist")
companion object {
val statToGreatPersonMapping = hashMapOf<Stat, String>(
Stat.Science to "Great Scientist",
Stat.Production to "Great Scientist",
Stat.Gold to "Great Scientist",
Stat.Culture to "Great Scientist",
)
}
fun clone(): GreatPersonManager {

View File

@ -4,6 +4,7 @@ import com.unciv.logic.city.CityConstructions
import com.unciv.logic.city.CityInfo
import com.unciv.logic.city.IConstruction
import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.logic.civilization.GreatPersonManager
import com.unciv.models.Counter
import com.unciv.models.ruleset.tile.TileImprovement
import com.unciv.models.stats.NamedStats
@ -11,13 +12,15 @@ import com.unciv.models.stats.Stat
import com.unciv.models.stats.Stats
import com.unciv.models.translations.fillPlaceholders
import com.unciv.models.translations.tr
import com.unciv.ui.civilopedia.FormattedLine
import com.unciv.ui.civilopedia.ICivilopediaText
import java.util.*
import kotlin.collections.ArrayList
import kotlin.collections.HashMap
import kotlin.math.pow
class Building : NamedStats(), IConstruction {
class Building : NamedStats(), IConstruction, ICivilopediaText {
var requiredTech: String? = null
@ -65,6 +68,8 @@ class Building : NamedStats(), IConstruction {
var replacementTextForUniques = ""
val uniqueObjects: List<Unique> by lazy { uniques.map { Unique(it) } }
override var civilopediaText = listOf<FormattedLine>()
fun getShortDescription(ruleset: Ruleset): String { // should fit in one line
val infoList = mutableListOf<String>()
val str = getStats(null).toString()
@ -98,19 +103,12 @@ class Building : NamedStats(), IConstruction {
return finalUniques
}
fun getDescription(forBuildingPickerScreen: Boolean, cityInfo: CityInfo?, ruleset: Ruleset): String {
fun getDescription(cityInfo: CityInfo?, ruleset: Ruleset): String {
val stats = getStats(cityInfo)
val stringBuilder = StringBuilder()
if (uniqueTo != null) stringBuilder.appendLine("Unique to [$uniqueTo], replaces [$replaces]".tr())
if (!forBuildingPickerScreen) stringBuilder.appendLine("{Cost}: $cost".tr())
if (isWonder) stringBuilder.appendLine("Wonder".tr())
if (isNationalWonder) stringBuilder.appendLine("National Wonder".tr())
if (!forBuildingPickerScreen && requiredTech != null)
stringBuilder.appendLine("Required tech: [$requiredTech]".tr())
if (!forBuildingPickerScreen && requiredBuilding != null)
stringBuilder.appendLine("Requires [$requiredBuilding] to be built in the city".tr())
if (!forBuildingPickerScreen && requiredBuildingInAllCities != null)
stringBuilder.appendLine("Requires [$requiredBuildingInAllCities] to be built in all cities".tr())
for ((resource, amount) in getResourceRequirements()) {
if (amount == 1) stringBuilder.appendLine("Consumes 1 [$resource]".tr()) // For now, to keep the existing translations
else stringBuilder.appendLine("Consumes [$amount] [$resource]".tr())
@ -197,6 +195,131 @@ class Building : NamedStats(), IConstruction {
return stats
}
fun makeLink() = if (isWonder || isNationalWonder) "Wonder/$name" else "Building/$name"
override fun getCivilopediaTextHeader() = FormattedLine(name, header=2, icon=makeLink())
override fun hasCivilopediaTextLines() = true
override fun replacesCivilopediaDescription() = true
override fun getCivilopediaTextLines(ruleset: Ruleset): List<FormattedLine> {
fun Float.formatSignedInt() = (if (this > 0f) "+" else "") + this.toInt().toString()
val textList = ArrayList<FormattedLine>()
if (isWonder || isNationalWonder) {
textList += FormattedLine( if (isWonder) "Wonder" else "National Wonder", color="#CA4", header=3 )
}
if (uniqueTo != null) {
textList += FormattedLine()
textList += FormattedLine("Unique to [$uniqueTo]", link="Nation/$uniqueTo")
if (replaces != null) {
val replacesBuilding = ruleset.buildings[replaces]
textList += FormattedLine("Replaces [$replaces]", link=replacesBuilding?.makeLink() ?: "", indent=1)
}
}
if (cost > 0) {
textList += FormattedLine()
textList += FormattedLine("{Cost}: $cost")
}
if (requiredTech != null || requiredBuilding != null || requiredBuildingInAllCities != null)
textList += FormattedLine()
if (requiredTech != null)
textList += FormattedLine("Required tech: [$requiredTech]",
link="Technology/$requiredTech")
if (requiredBuilding != null)
textList += FormattedLine("Requires [$requiredBuilding] to be built in the city",
link="Building/$requiredBuilding")
if (requiredBuildingInAllCities != null)
textList += FormattedLine("Requires [$requiredBuildingInAllCities] to be built in all cities",
link="Building/$requiredBuildingInAllCities")
val resourceRequirements = getResourceRequirements()
if (resourceRequirements.isNotEmpty()) {
textList += FormattedLine()
for ((resource, amount) in resourceRequirements) {
textList += FormattedLine(
// the 1 variant should deprecate some time
if (amount == 1) "Consumes 1 [$resource]" else "Consumes [$amount] [$resource]",
link="Resources/$resource", color="#F42" )
}
}
if (providesFreeBuilding != null) {
textList += FormattedLine()
textList += FormattedLine("Provides a free [$providesFreeBuilding] in the city",
link="Building/$providesFreeBuilding")
}
val stats = this.clone()
val percentStats = getStatPercentageBonuses(null)
val specialists = newSpecialists()
if (uniques.isNotEmpty() || !stats.isEmpty() || !percentStats.isEmpty() || this.greatPersonPoints != null || specialists.isNotEmpty())
textList += FormattedLine()
if (uniques.isNotEmpty()) {
if (replacementTextForUniques.isNotEmpty())
textList += FormattedLine(replacementTextForUniques)
else
for (unique in getUniquesStrings()) textList += FormattedLine(unique)
}
if (!stats.isEmpty()) {
textList += FormattedLine(stats.toString())
}
if (!percentStats.isEmpty()) {
for ( (key, value) in percentStats.toHashMap()) {
if (value == 0f) continue
textList += FormattedLine(value.formatSignedInt() + "% {$key}")
}
}
if (greatPersonPoints != null) {
for ( (key, value) in greatPersonPoints!!.toHashMap()) {
if (value == 0f) continue
val gppName = GreatPersonManager.statToGreatPersonMapping[key]
?: continue
textList += FormattedLine(value.formatSignedInt() + " " + "[$gppName] points".tr(),
link = "Unit/$gppName")
}
}
if (specialists.isNotEmpty()) {
for ((specialistName, amount) in specialists)
textList += FormattedLine("+$amount " + "[$specialistName] slots".tr())
}
if (requiredNearbyImprovedResources != null) {
textList += FormattedLine()
textList += FormattedLine("Requires at least one of the following resources worked near the city:")
requiredNearbyImprovedResources!!.forEach {
textList += FormattedLine(it, indent = 1, link = "Resource/$it")
}
}
if (cityStrength != 0 || cityHealth != 0 || xpForNewUnits != 0 || maintenance != 0) textList += FormattedLine()
if (cityStrength != 0) textList += FormattedLine("{City strength} +$cityStrength")
if (cityHealth != 0) textList += FormattedLine("{City health} +$cityHealth")
if (xpForNewUnits != 0) textList += FormattedLine("+$xpForNewUnits {XP for new units}")
if (maintenance != 0) textList += FormattedLine("{Maintenance cost}: $maintenance {Gold}")
val seeAlso = ArrayList<FormattedLine>()
for ((other, building) in ruleset.buildings) {
if (building.replaces == name || building.providesFreeBuilding == name || uniques.contains("[$name]") ) {
seeAlso += FormattedLine(other, link=building.makeLink(), indent=1)
}
}
if (seeAlso.isNotEmpty()) {
textList += FormattedLine()
textList += FormattedLine("{See also}:")
textList += seeAlso
}
return textList
}
override fun canBePurchased(): Boolean {
return !isWonder && !isNationalWonder && "Cannot be purchased" !in uniques
}
@ -399,7 +522,7 @@ class Building : NamedStats(), IConstruction {
if (!civInfo.gameInfo.gameParameters.victoryTypes.contains(VictoryType.Scientific)
&& "Enables construction of Spaceship parts" in uniques)
return "Can't construct spaceship parts if scientific victory is not enabled!"
return ""
}

View File

@ -1,7 +1,6 @@
package com.unciv.ui.cityscreen
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.scenes.scene2d.Touchable
import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.utils.Align
import com.unciv.UncivGame
@ -65,9 +64,7 @@ class CityInfoTable(private val cityScreen: CityScreen) : Table(CameraStageBaseS
private fun addBuildingInfo(building: Building, destinationTable: Table) {
val icon = ImageGetter.getConstructionImage(building.name).surroundWithCircle(30f)
val buildingNameAndIconTable = ExpanderTab(building.name, 18, icon, false, 5f) {
//todo: getDescription signature changes with civilopedia phase 5
val detailsString = building.getDescription(true,
cityScreen.city, cityScreen.city.civInfo.gameInfo.ruleSet)
val detailsString = building.getDescription(cityScreen.city, cityScreen.city.civInfo.gameInfo.ruleSet)
it.add(detailsString.toLabel().apply { wrap = true })
.width(cityScreen.stage.width / 4 - 2 * pad).row() // when you set wrap, then you need to manually set the size of the label
if (building.isSellable()) {
@ -211,7 +208,7 @@ class CityInfoTable(private val cityScreen: CityScreen) : Table(CameraStageBaseS
private fun Table.addGreatPersonPointInfo(cityInfo: CityInfo) {
val greatPersonPoints = cityInfo.getGreatPersonPointsForNextTurn()
val statToGreatPerson = GreatPersonManager().statToGreatPersonMapping
val statToGreatPerson = GreatPersonManager.statToGreatPersonMapping
for (stat in Stat.values()) {
if (!statToGreatPerson.containsKey(stat)) continue
if (greatPersonPoints.all { it.value.get(stat) == 0f }) continue

View File

@ -59,7 +59,7 @@ class ConstructionInfoTable(val city: CityInfo): Table() {
val description: String = when (construction) {
is BaseUnit -> construction.getDescription()
is Building -> construction.getDescription(true, city, city.civInfo.gameInfo.ruleSet)
is Building -> construction.getDescription(city, city.civInfo.gameInfo.ruleSet)
is PerpetualConstruction -> construction.description.replace("[rate]", "[${construction.getConversionRate(city)}]").tr()
else -> "" // Should never happen
}

View File

@ -7,6 +7,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.*
import com.unciv.Constants
import com.unciv.UncivGame
import com.unciv.models.ruleset.Ruleset
import com.unciv.models.ruleset.VictoryType
import com.unciv.models.stats.INamed
import com.unciv.models.translations.tr
import com.unciv.ui.utils.*
@ -163,22 +164,31 @@ class CivilopediaScreen(
val imageSize = 50f
onBackButtonClicked { UncivGame.Current.setWorldScreen() }
val hideReligionItems = !game.gameInfo.hasReligionEnabled()
val noCulturalVictory = VictoryType.Cultural !in game.gameInfo.gameParameters.victoryTypes
categoryToEntries[CivilopediaCategories.Building] = ruleset.buildings.values
.filter { "Will not be displayed in Civilopedia" !in it.uniques && !(it.isWonder || it.isNationalWonder) }
.filter { "Will not be displayed in Civilopedia" !in it.uniques
&& !(hideReligionItems && "Hidden when religion is disabled" in it.uniques)
&& !(noCulturalVictory && "Hidden when cultural victory is disabled" in it.uniques)
&& !(it.isWonder || it.isNationalWonder) }
.map {
CivilopediaEntry(
it.name,
it.getDescription(false, null, ruleset),
"",
CivilopediaCategories.Building.getImage?.invoke(it.name, imageSize),
(it as? ICivilopediaText).takeUnless { ct -> ct==null || ct.isCivilopediaTextEmpty() }
)
}
categoryToEntries[CivilopediaCategories.Wonder] = ruleset.buildings.values
.filter { "Will not be displayed in Civilopedia" !in it.uniques && (it.isWonder || it.isNationalWonder) }
.filter { "Will not be displayed in Civilopedia" !in it.uniques
&& !(hideReligionItems && "Hidden when religion is disabled" in it.uniques)
&& !(noCulturalVictory && "Hidden when cultural victory is disabled" in it.uniques)
&& (it.isWonder || it.isNationalWonder) }
.map {
CivilopediaEntry(
it.name,
it.getDescription(false, null, ruleset),
"",
CivilopediaCategories.Wonder.getImage?.invoke(it.name, imageSize),
(it as? ICivilopediaText).takeUnless { ct -> ct==null || ct.isCivilopediaTextEmpty() }
)

View File

@ -212,7 +212,7 @@ class FormattedLine (
}
if (textToDisplay.isNotEmpty()) {
val usedWidth = iconCount * (iconSize + iconPad)
val padIndent = when {
val indentWidth = when {
centered -> -usedWidth
indent == 0 && iconCount == 0 -> 0f
indent == 0 -> iconPad
@ -224,10 +224,10 @@ class FormattedLine (
label.setAlignment(align)
if (labelWidth == 0f)
table.add(label)
.padLeft(padIndent).align(align)
.padLeft(indentWidth).align(align)
else
table.add(label).width(labelWidth - usedWidth - padIndent)
.padLeft(padIndent).align(align)
table.add(label).width(labelWidth - usedWidth - indentWidth)
.padLeft(indentWidth).align(align)
}
return table
}

View File

@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.scenes.scene2d.ui.Slider
import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.logic.civilization.GreatPersonManager
import com.unciv.models.translations.tr
import com.unciv.ui.utils.*
import kotlin.math.roundToInt
@ -120,7 +121,7 @@ class StatsOverviewTable (
greatPeopleTable.add("Current points".tr())
greatPeopleTable.add("Points per turn".tr()).row()
val mapping = viewingPlayer.greatPeople.statToGreatPersonMapping
val mapping = GreatPersonManager.statToGreatPersonMapping
for(entry in mapping){
greatPeopleTable.add(entry.value.tr())
greatPeopleTable.add(greatPersonPoints[entry.key]!!.toInt().toString()+"/"+pointsToGreatPerson)