diff --git a/android/assets/jsons/Units.json b/android/assets/jsons/Units.json index 3724b8d03c..d9fe2b81f3 100644 --- a/android/assets/jsons/Units.json +++ b/android/assets/jsons/Units.json @@ -1,7 +1,7 @@ [ { name:"Worker", - description: "Can build improvements on tiles", + baseDescription: "Can build improvements on tiles", movement:2, unitType:"Civilian", hurryCostModifier:20, @@ -9,7 +9,7 @@ }, { name:"Settler", - description: "Founds a new city", + baseDescription: "Founds a new city", movement:2, unitType:"Civilian", cost:106, @@ -17,7 +17,7 @@ }, { name:"Scout", - description: "Has no abilites, can only explore", + baseDescription: "Has no abilites, can only explore", unbuildable:true, unitType:"Melee", strength:5, @@ -25,7 +25,7 @@ }, { name:"Warrior", - description: "A basic fighting unit", + baseDescription: "A basic fighting unit", unitType:"Melee", movement:2, strength:8, @@ -34,7 +34,7 @@ }, { name:"Archer", - description: "A basic fighting unit", + baseDescription: "A basic fighting unit", unitType:"Ranged", movement:2, strength:5, @@ -44,28 +44,28 @@ }, { name:"Great Artist", - description: "Can start an 8-turn golden age or construct a Landmark (+6 culture)", + baseDescription: "Can start an 8-turn golden age or construct a Landmark (+6 culture)", unbuildable:true, unitType:"Civilian", movement:2 }, { name:"Great Scientist", - description: "Can discover a technology, or construct an Academy (+4 science)", + baseDescription: "Can discover a technology, or construct an Academy (+4 science)", unbuildable:true, unitType:"Civilian", movement:2 }, { name:"Great Merchant", - description: "Can undertake a trade mission, giving a large sum of gold, or construct a Customs House (+4 gold)", + baseDescription: "Can undertake a trade mission, giving a large sum of gold, or construct a Customs House (+4 gold)", unbuildable:true, unitType:"Civilian", movement:2 }, { name:"Great Engineer", - description: "Can speed up construction of a wonder, or construct a Manufactory (+4 production)", + baseDescription: "Can speed up construction of a wonder, or construct a Manufactory (+4 production)", unbuildable:true, unitType:"Civilian", movement:2 diff --git a/core/src/com/unciv/models/gamebasics/Terrain.kt b/core/src/com/unciv/models/gamebasics/Terrain.kt index 0e52c0098a..fca393f9c1 100644 --- a/core/src/com/unciv/models/gamebasics/Terrain.kt +++ b/core/src/com/unciv/models/gamebasics/Terrain.kt @@ -4,7 +4,23 @@ import com.unciv.models.stats.NamedStats class Terrain : NamedStats(), ICivilopedia { override val description: String - get() = this.clone().toString() + get(){ + val sb = StringBuilder() + sb.appendln(this.clone().toString()) + + if(occursOn!=null) + sb.appendln("Occurs on: "+occursOn!!.joinToString()) + + val resourcesFound = GameBasics.TileResources.values.filter { it.terrainsCanBeFoundOn.contains(name)}.joinToString() + if(resourcesFound.isNotEmpty()) + sb.appendln("May contain: $resourcesFound") + sb.appendln("Movement cost: $movementCost") + if(defenceBonus!=0f){ + sb.appendln("Defence bonus: "+(defenceBonus*100).toInt()+"%") + } + + return sb.toString() + } lateinit var type: TerrainType var overrideStats = false @@ -33,7 +49,4 @@ class Terrain : NamedStats(), ICivilopedia { var movementCost = 1 var defenceBonus:Float = 0f -} - - - +} \ No newline at end of file diff --git a/core/src/com/unciv/models/gamebasics/Unit.kt b/core/src/com/unciv/models/gamebasics/Unit.kt index 972d18bace..54b1bc4f21 100644 --- a/core/src/com/unciv/models/gamebasics/Unit.kt +++ b/core/src/com/unciv/models/gamebasics/Unit.kt @@ -6,9 +6,20 @@ import com.unciv.logic.map.MapUnit import com.unciv.logic.map.UnitType import com.unciv.models.stats.INamed -class Unit : INamed, IConstruction { +class Unit : INamed, IConstruction, ICivilopedia { + override val description: String + get(){ + val sb = StringBuilder() + sb.appendln(baseDescription) + if(unbuildable) sb.appendln("Unbuildable") + else sb.appendln("Cost: $cost") + if(strength!=0) sb.appendln("Strength: $strength") + if(rangedStrength!=0) sb.appendln("Ranged strength: $rangedStrength") + return sb.toString() + } + override lateinit var name: String - var description: String? = null + var baseDescription: String? = null var cost: Int = 0 var hurryCostModifier: Int = 0 var movement: Int = 0 @@ -27,9 +38,7 @@ class Unit : INamed, IConstruction { } - override fun getProductionCost(adoptedPolicies: HashSet): Int { - return cost - } + override fun getProductionCost(adoptedPolicies: HashSet): Int = cost override fun getGoldCost(adoptedPolicies: HashSet): Int { return (Math.pow((30 * cost).toDouble(), 0.75) * (1 + hurryCostModifier / 100) / 10).toInt() * 10 @@ -42,4 +51,6 @@ class Unit : INamed, IConstruction { override fun postBuildEvent(construction: CityConstructions) { construction.cityInfo.civInfo.placeUnitNearTile(construction.cityInfo.location, name) } + + override fun toString(): String = name } // for json parsing, we need to have a default constructor diff --git a/core/src/com/unciv/models/stats/Stats.kt b/core/src/com/unciv/models/stats/Stats.kt index 25a5a7fb56..5a7943b3ac 100644 --- a/core/src/com/unciv/models/stats/Stats.kt +++ b/core/src/com/unciv/models/stats/Stats.kt @@ -55,7 +55,8 @@ open class Stats() { } override fun toString(): String { - return toHashMap().filter { it.value != 0f }.map { it.key.toString() + ": " + it.value.toInt() }.joinToString() + return toHashMap().filter { it.value != 0f } + .map { (if(it.value>0)"+" else "") + it.value.toInt()+" "+it.key.toString() }.joinToString() } fun toHashMap(): HashMap { diff --git a/core/src/com/unciv/ui/CivilopediaScreen.kt b/core/src/com/unciv/ui/CivilopediaScreen.kt index adb8d9abfa..d851d21547 100644 --- a/core/src/com/unciv/ui/CivilopediaScreen.kt +++ b/core/src/com/unciv/ui/CivilopediaScreen.kt @@ -38,17 +38,16 @@ class CivilopediaScreen : CameraStageBaseScreen() { map["Resources"] = GameBasics.TileResources.values map["Terrains"] = GameBasics.Terrains.values map["Tile Improvements"] = GameBasics.TileImprovements.values + map["Units"] = GameBasics.Units.values val nameList = List(CameraStageBaseScreen.skin) val nameListClickListener = { - if(nameList.selected!=null) { - val building = nameList.selected - label.setText(building.description) - } + if(nameList.selected!=null) label.setText(nameList.selected.description) } nameList.addClickListener (nameListClickListener) + nameList.style = List.ListStyle(nameList.style) nameList.style.fontColorSelected = Color.BLACK nameList.style.font.data.setScale(1.5f) @@ -56,13 +55,15 @@ class CivilopediaScreen : CameraStageBaseScreen() { var first = true for (str in map.keys) { val button = TextButton(str, CameraStageBaseScreen.skin) + button.style = TextButton.TextButtonStyle(button.style) button.style.checkedFontColor = Color.BLACK buttons.add(button) val buttonClicked = { val newArray = Array() - for (civ in map[str]!!) newArray.add(civ) + for (civilopediaEntry in map[str]!!) newArray.add(civilopediaEntry) nameList.setItems(newArray) nameList.selected = nameList.items.get(0) + label.setText(nameList.selected.description) for (btn in buttons) btn.isChecked = false button.isChecked = true @@ -82,6 +83,7 @@ class CivilopediaScreen : CameraStageBaseScreen() { .pad(Value.percentWidth(0.02f, entryTable)) entryTable.add(label).colspan(4).width(Value.percentWidth(0.65f, entryTable)).height(Value.percentHeight(0.7f, entryTable)) .pad(Value.percentWidth(0.02f, entryTable)) + // Simply changing these to x*width, y*height won't work buttonTable.width = stage.width } diff --git a/core/src/com/unciv/ui/VictoryScreen.kt b/core/src/com/unciv/ui/VictoryScreen.kt index 605b7e3fd3..37513a1c2e 100644 --- a/core/src/com/unciv/ui/VictoryScreen.kt +++ b/core/src/com/unciv/ui/VictoryScreen.kt @@ -40,7 +40,7 @@ class VictoryScreen : PickerScreen() { } if(civInfo.gameInfo.civilizations.all { it.isPlayerCivilization() || it.isDefeated() }){ - descriptionLabel.setText("You have won a cultural victory!") + descriptionLabel.setText("You have won a conquest victory!") won() } } diff --git a/core/src/com/unciv/ui/pickerscreens/ConstructionPickerScreen.kt b/core/src/com/unciv/ui/pickerscreens/ConstructionPickerScreen.kt index adc219b06c..adde0e6315 100644 --- a/core/src/com/unciv/ui/pickerscreens/ConstructionPickerScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/ConstructionPickerScreen.kt @@ -60,7 +60,7 @@ class ConstructionPickerScreen(val city: CityInfo) : PickerScreen() { for (unit in GameBasics.Units.values.filterNot { it.unbuildable }) { units.addActor(getProductionButton(unit.name, unit.name + "\r\n" + cityConstructions.turnsToConstruction(unit.name) + " turns", - unit.description, "Train " + unit.name)) + unit.baseDescription, "Train " + unit.name)) } if (civInfo.tech.isResearched("Education")) diff --git a/core/src/com/unciv/ui/pickerscreens/GreatPersonPickerScreen.kt b/core/src/com/unciv/ui/pickerscreens/GreatPersonPickerScreen.kt index 157861cbd7..8564f735c3 100644 --- a/core/src/com/unciv/ui/pickerscreens/GreatPersonPickerScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/GreatPersonPickerScreen.kt @@ -18,7 +18,7 @@ class GreatPersonPickerScreen : PickerScreen() { button.addClickListener { theChosenOne = unit pick("Get " +unit.name) - descriptionLabel.setText(unit.description) + descriptionLabel.setText(unit.baseDescription) } topTable.add(button).pad(10f) }