Added units to civilopedia
Added more info to civilopedia
This commit is contained in:
parent
3eaf1afef4
commit
8350d000b1
8 changed files with 55 additions and 28 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -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<String>): Int {
|
||||
return cost
|
||||
}
|
||||
override fun getProductionCost(adoptedPolicies: HashSet<String>): Int = cost
|
||||
|
||||
override fun getGoldCost(adoptedPolicies: HashSet<String>): 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
|
||||
|
|
|
@ -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<Stat, Float> {
|
||||
|
|
|
@ -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<ICivilopedia>(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<ICivilopedia>()
|
||||
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
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"))
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue