All GameBasics are now LinkedHashLists, and so retain order as in the json files
This commit is contained in:
parent
f59102a2a0
commit
b659e3b37d
2 changed files with 17 additions and 18 deletions
|
@ -1,12 +1,12 @@
|
||||||
package com.unciv.models.gamebasics
|
package com.unciv.models.gamebasics
|
||||||
|
|
||||||
object GameBasics {
|
object GameBasics {
|
||||||
@JvmField var Buildings: HashMap<String, Building> = HashMap()
|
val Buildings = LinkedHashMap<String, Building>()
|
||||||
@JvmField var Terrains: HashMap<String, Terrain> = HashMap()
|
val Terrains = LinkedHashMap<String, Terrain>()
|
||||||
@JvmField var TileResources: HashMap<String, TileResource> = HashMap()
|
val TileResources = LinkedHashMap<String, TileResource>()
|
||||||
@JvmField var TileImprovements: HashMap<String, TileImprovement> = HashMap()
|
val TileImprovements = LinkedHashMap<String, TileImprovement>()
|
||||||
@JvmField var Technologies: HashMap<String, Technology> = HashMap()
|
val Technologies = LinkedHashMap<String, Technology>()
|
||||||
@JvmField var Helps: HashMap<String, BasicHelp> = HashMap()
|
val Helps = LinkedHashMap<String, BasicHelp>()
|
||||||
@JvmField var Units: HashMap<String, Unit> = HashMap()
|
val Units = LinkedHashMap<String, Unit>()
|
||||||
@JvmField var PolicyBranches: HashMap<String, PolicyBranch> = HashMap()
|
val PolicyBranches = LinkedHashMap<String, PolicyBranch>()
|
||||||
}
|
}
|
|
@ -56,24 +56,23 @@ class UnCivGame : Game() {
|
||||||
return Json().fromJson(tClass, jsonText)
|
return Json().fromJson(tClass, jsonText)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun <T : INamed> createHashmap(items: Array<T>): HashMap<String, T> {
|
private fun <T : INamed> createHashmap(items: Array<T>): LinkedHashMap<String, T> {
|
||||||
val hashMap = HashMap<String, T>()
|
val hashMap = LinkedHashMap<String, T>()
|
||||||
for (item in items)
|
for (item in items)
|
||||||
hashMap[item.name] = item
|
hashMap[item.name] = item
|
||||||
return hashMap
|
return hashMap
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupGameBasics() {
|
private fun setupGameBasics() {
|
||||||
GameBasics.Buildings = createHashmap(getFromJson(Array<Building>::class.java, "Buildings"))
|
GameBasics.Buildings += createHashmap(getFromJson(Array<Building>::class.java, "Buildings"))
|
||||||
GameBasics.Terrains = createHashmap(getFromJson(Array<Terrain>::class.java, "Terrains"))
|
GameBasics.Terrains += createHashmap(getFromJson(Array<Terrain>::class.java, "Terrains"))
|
||||||
GameBasics.TileResources = createHashmap(getFromJson(Array<TileResource>::class.java, "TileResources"))
|
GameBasics.TileResources += createHashmap(getFromJson(Array<TileResource>::class.java, "TileResources"))
|
||||||
GameBasics.TileImprovements = createHashmap(getFromJson(Array<TileImprovement>::class.java, "TileImprovements"))
|
GameBasics.TileImprovements += createHashmap(getFromJson(Array<TileImprovement>::class.java, "TileImprovements"))
|
||||||
GameBasics.Helps = createHashmap(getFromJson(Array<BasicHelp>::class.java, "BasicHelp"))
|
GameBasics.Helps += createHashmap(getFromJson(Array<BasicHelp>::class.java, "BasicHelp"))
|
||||||
GameBasics.Units = createHashmap(getFromJson(Array<Unit>::class.java, "Units"))
|
GameBasics.Units += createHashmap(getFromJson(Array<Unit>::class.java, "Units"))
|
||||||
GameBasics.PolicyBranches = createHashmap(getFromJson(Array<PolicyBranch>::class.java, "Policies"))
|
GameBasics.PolicyBranches += createHashmap(getFromJson(Array<PolicyBranch>::class.java, "Policies"))
|
||||||
|
|
||||||
val techColumns = getFromJson(Array<TechColumn>::class.java, "Techs")
|
val techColumns = getFromJson(Array<TechColumn>::class.java, "Techs")
|
||||||
GameBasics.Technologies = HashMap()
|
|
||||||
for (techColumn in techColumns) {
|
for (techColumn in techColumns) {
|
||||||
for (tech in techColumn.techs) {
|
for (tech in techColumn.techs) {
|
||||||
tech.cost = techColumn.techCost
|
tech.cost = techColumn.techCost
|
||||||
|
|
Loading…
Reference in a new issue