mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-22 10:54:19 -04:00
Added units to civilopedia
Added more info to civilopedia
This commit is contained in:
parent
3eaf1afef4
commit
8350d000b1
@ -1,7 +1,7 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
name:"Worker",
|
name:"Worker",
|
||||||
description: "Can build improvements on tiles",
|
baseDescription: "Can build improvements on tiles",
|
||||||
movement:2,
|
movement:2,
|
||||||
unitType:"Civilian",
|
unitType:"Civilian",
|
||||||
hurryCostModifier:20,
|
hurryCostModifier:20,
|
||||||
@ -9,7 +9,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name:"Settler",
|
name:"Settler",
|
||||||
description: "Founds a new city",
|
baseDescription: "Founds a new city",
|
||||||
movement:2,
|
movement:2,
|
||||||
unitType:"Civilian",
|
unitType:"Civilian",
|
||||||
cost:106,
|
cost:106,
|
||||||
@ -17,7 +17,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name:"Scout",
|
name:"Scout",
|
||||||
description: "Has no abilites, can only explore",
|
baseDescription: "Has no abilites, can only explore",
|
||||||
unbuildable:true,
|
unbuildable:true,
|
||||||
unitType:"Melee",
|
unitType:"Melee",
|
||||||
strength:5,
|
strength:5,
|
||||||
@ -25,7 +25,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name:"Warrior",
|
name:"Warrior",
|
||||||
description: "A basic fighting unit",
|
baseDescription: "A basic fighting unit",
|
||||||
unitType:"Melee",
|
unitType:"Melee",
|
||||||
movement:2,
|
movement:2,
|
||||||
strength:8,
|
strength:8,
|
||||||
@ -34,7 +34,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name:"Archer",
|
name:"Archer",
|
||||||
description: "A basic fighting unit",
|
baseDescription: "A basic fighting unit",
|
||||||
unitType:"Ranged",
|
unitType:"Ranged",
|
||||||
movement:2,
|
movement:2,
|
||||||
strength:5,
|
strength:5,
|
||||||
@ -44,28 +44,28 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name:"Great Artist",
|
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,
|
unbuildable:true,
|
||||||
unitType:"Civilian",
|
unitType:"Civilian",
|
||||||
movement:2
|
movement:2
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name:"Great Scientist",
|
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,
|
unbuildable:true,
|
||||||
unitType:"Civilian",
|
unitType:"Civilian",
|
||||||
movement:2
|
movement:2
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name:"Great Merchant",
|
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,
|
unbuildable:true,
|
||||||
unitType:"Civilian",
|
unitType:"Civilian",
|
||||||
movement:2
|
movement:2
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name:"Great Engineer",
|
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,
|
unbuildable:true,
|
||||||
unitType:"Civilian",
|
unitType:"Civilian",
|
||||||
movement:2
|
movement:2
|
||||||
|
@ -4,7 +4,23 @@ import com.unciv.models.stats.NamedStats
|
|||||||
|
|
||||||
class Terrain : NamedStats(), ICivilopedia {
|
class Terrain : NamedStats(), ICivilopedia {
|
||||||
override val description: String
|
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
|
lateinit var type: TerrainType
|
||||||
|
|
||||||
var overrideStats = false
|
var overrideStats = false
|
||||||
@ -33,7 +49,4 @@ class Terrain : NamedStats(), ICivilopedia {
|
|||||||
var movementCost = 1
|
var movementCost = 1
|
||||||
|
|
||||||
var defenceBonus:Float = 0f
|
var defenceBonus:Float = 0f
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -6,9 +6,20 @@ import com.unciv.logic.map.MapUnit
|
|||||||
import com.unciv.logic.map.UnitType
|
import com.unciv.logic.map.UnitType
|
||||||
import com.unciv.models.stats.INamed
|
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
|
override lateinit var name: String
|
||||||
var description: String? = null
|
var baseDescription: String? = null
|
||||||
var cost: Int = 0
|
var cost: Int = 0
|
||||||
var hurryCostModifier: Int = 0
|
var hurryCostModifier: Int = 0
|
||||||
var movement: Int = 0
|
var movement: Int = 0
|
||||||
@ -27,9 +38,7 @@ class Unit : INamed, IConstruction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun getProductionCost(adoptedPolicies: HashSet<String>): Int {
|
override fun getProductionCost(adoptedPolicies: HashSet<String>): Int = cost
|
||||||
return cost
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getGoldCost(adoptedPolicies: HashSet<String>): Int {
|
override fun getGoldCost(adoptedPolicies: HashSet<String>): Int {
|
||||||
return (Math.pow((30 * cost).toDouble(), 0.75) * (1 + hurryCostModifier / 100) / 10).toInt() * 10
|
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) {
|
override fun postBuildEvent(construction: CityConstructions) {
|
||||||
construction.cityInfo.civInfo.placeUnitNearTile(construction.cityInfo.location, name)
|
construction.cityInfo.civInfo.placeUnitNearTile(construction.cityInfo.location, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun toString(): String = name
|
||||||
} // for json parsing, we need to have a default constructor
|
} // for json parsing, we need to have a default constructor
|
||||||
|
@ -55,7 +55,8 @@ open class Stats() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun toString(): String {
|
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<Stat, Float> {
|
fun toHashMap(): HashMap<Stat, Float> {
|
||||||
|
@ -38,17 +38,16 @@ class CivilopediaScreen : CameraStageBaseScreen() {
|
|||||||
map["Resources"] = GameBasics.TileResources.values
|
map["Resources"] = GameBasics.TileResources.values
|
||||||
map["Terrains"] = GameBasics.Terrains.values
|
map["Terrains"] = GameBasics.Terrains.values
|
||||||
map["Tile Improvements"] = GameBasics.TileImprovements.values
|
map["Tile Improvements"] = GameBasics.TileImprovements.values
|
||||||
|
map["Units"] = GameBasics.Units.values
|
||||||
|
|
||||||
val nameList = List<ICivilopedia>(CameraStageBaseScreen.skin)
|
val nameList = List<ICivilopedia>(CameraStageBaseScreen.skin)
|
||||||
|
|
||||||
val nameListClickListener = {
|
val nameListClickListener = {
|
||||||
if(nameList.selected!=null) {
|
if(nameList.selected!=null) label.setText(nameList.selected.description)
|
||||||
val building = nameList.selected
|
|
||||||
label.setText(building.description)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
nameList.addClickListener (nameListClickListener)
|
nameList.addClickListener (nameListClickListener)
|
||||||
|
|
||||||
|
nameList.style = List.ListStyle(nameList.style)
|
||||||
nameList.style.fontColorSelected = Color.BLACK
|
nameList.style.fontColorSelected = Color.BLACK
|
||||||
nameList.style.font.data.setScale(1.5f)
|
nameList.style.font.data.setScale(1.5f)
|
||||||
|
|
||||||
@ -56,13 +55,15 @@ class CivilopediaScreen : CameraStageBaseScreen() {
|
|||||||
var first = true
|
var first = true
|
||||||
for (str in map.keys) {
|
for (str in map.keys) {
|
||||||
val button = TextButton(str, CameraStageBaseScreen.skin)
|
val button = TextButton(str, CameraStageBaseScreen.skin)
|
||||||
|
button.style = TextButton.TextButtonStyle(button.style)
|
||||||
button.style.checkedFontColor = Color.BLACK
|
button.style.checkedFontColor = Color.BLACK
|
||||||
buttons.add(button)
|
buttons.add(button)
|
||||||
val buttonClicked = {
|
val buttonClicked = {
|
||||||
val newArray = Array<ICivilopedia>()
|
val newArray = Array<ICivilopedia>()
|
||||||
for (civ in map[str]!!) newArray.add(civ)
|
for (civilopediaEntry in map[str]!!) newArray.add(civilopediaEntry)
|
||||||
nameList.setItems(newArray)
|
nameList.setItems(newArray)
|
||||||
nameList.selected = nameList.items.get(0)
|
nameList.selected = nameList.items.get(0)
|
||||||
|
label.setText(nameList.selected.description)
|
||||||
|
|
||||||
for (btn in buttons) btn.isChecked = false
|
for (btn in buttons) btn.isChecked = false
|
||||||
button.isChecked = true
|
button.isChecked = true
|
||||||
@ -82,6 +83,7 @@ class CivilopediaScreen : CameraStageBaseScreen() {
|
|||||||
.pad(Value.percentWidth(0.02f, entryTable))
|
.pad(Value.percentWidth(0.02f, entryTable))
|
||||||
entryTable.add(label).colspan(4).width(Value.percentWidth(0.65f, entryTable)).height(Value.percentHeight(0.7f, entryTable))
|
entryTable.add(label).colspan(4).width(Value.percentWidth(0.65f, entryTable)).height(Value.percentHeight(0.7f, entryTable))
|
||||||
.pad(Value.percentWidth(0.02f, entryTable))
|
.pad(Value.percentWidth(0.02f, entryTable))
|
||||||
|
// Simply changing these to x*width, y*height won't work
|
||||||
|
|
||||||
buttonTable.width = stage.width
|
buttonTable.width = stage.width
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ class VictoryScreen : PickerScreen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(civInfo.gameInfo.civilizations.all { it.isPlayerCivilization() || it.isDefeated() }){
|
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()
|
won()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ class ConstructionPickerScreen(val city: CityInfo) : PickerScreen() {
|
|||||||
for (unit in GameBasics.Units.values.filterNot { it.unbuildable }) {
|
for (unit in GameBasics.Units.values.filterNot { it.unbuildable }) {
|
||||||
units.addActor(getProductionButton(unit.name,
|
units.addActor(getProductionButton(unit.name,
|
||||||
unit.name + "\r\n" + cityConstructions.turnsToConstruction(unit.name) + " turns",
|
unit.name + "\r\n" + cityConstructions.turnsToConstruction(unit.name) + " turns",
|
||||||
unit.description, "Train " + unit.name))
|
unit.baseDescription, "Train " + unit.name))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (civInfo.tech.isResearched("Education"))
|
if (civInfo.tech.isResearched("Education"))
|
||||||
|
@ -18,7 +18,7 @@ class GreatPersonPickerScreen : PickerScreen() {
|
|||||||
button.addClickListener {
|
button.addClickListener {
|
||||||
theChosenOne = unit
|
theChosenOne = unit
|
||||||
pick("Get " +unit.name)
|
pick("Get " +unit.name)
|
||||||
descriptionLabel.setText(unit.description)
|
descriptionLabel.setText(unit.baseDescription)
|
||||||
}
|
}
|
||||||
topTable.add(button).pad(10f)
|
topTable.add(button).pad(10f)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user