Resources in Civilopedia state unit and buildings that consume the resource - #1964

This commit is contained in:
Yair Morgenstern 2020-03-29 14:29:19 +03:00
parent 3ec27ec6c3
commit 806a0e2269
5 changed files with 418 additions and 390 deletions

File diff suppressed because it is too large Load diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 396 KiB

After

Width:  |  Height:  |  Size: 410 KiB

View file

@ -730,6 +730,8 @@ Placed on [terrainType] =
Can be found on =
Improved by [improvement] =
Bonus stats for improvement: =
Buildings that consume this resource: =
Units that consume this resource: =
Can be built on =
Defence bonus =
Movement cost =

View file

@ -1,5 +1,6 @@
package com.unciv.models.ruleset.tile
import com.unciv.models.ruleset.Ruleset
import com.unciv.models.stats.NamedStats
import com.unciv.models.stats.Stats
import com.unciv.models.translations.tr
@ -20,7 +21,7 @@ class TileResource : NamedStats() {
var unique: String? = null
fun getDescription(): String {
fun getDescription(ruleset: Ruleset): String {
val stringBuilder = StringBuilder()
stringBuilder.appendln(resourceType.name.tr())
stringBuilder.appendln(this.clone().toString())
@ -30,6 +31,17 @@ class TileResource : NamedStats() {
stringBuilder.appendln()
stringBuilder.appendln("Improved by [$improvement]".tr())
stringBuilder.appendln("Bonus stats for improvement: ".tr() + "$improvementStats".tr())
val buildingsThatConsumeThis = ruleset.buildings.values.filter { it.requiredResource==name }
if(buildingsThatConsumeThis.isNotEmpty())
stringBuilder.appendln("Buildings that consume this resource: ".tr()
+ buildingsThatConsumeThis.joinToString { it.name.tr() })
val unitsThatConsumeThis = ruleset.units.values.filter { it.requiredResource==name }
if(unitsThatConsumeThis.isNotEmpty())
stringBuilder.appendln("Units that consume this resource: ".tr()
+ unitsThatConsumeThis.joinToString { it.name.tr() })
if(unique!=null) stringBuilder.appendln(unique!!.tr())
return stringBuilder.toString()
}

View file

@ -62,7 +62,7 @@ class CivilopediaScreen(ruleset: Ruleset) : CameraStageBaseScreen() {
.map { CivilopediaEntry(it.name,it.getDescription(false, null,ruleset),
ImageGetter.getConstructionImage(it.name)) }
categoryToEntries["Resources"] = ruleset.tileResources.values
.map { CivilopediaEntry(it.name,it.getDescription(),
.map { CivilopediaEntry(it.name,it.getDescription(ruleset),
ImageGetter.getResourceImage(it.name,50f)) }
categoryToEntries["Terrains"] = ruleset.terrains.values
.map { CivilopediaEntry(it.name,it.getDescription(ruleset)) }