Techs display short info on buildings and units

This commit is contained in:
Yair Morgenstern 2018-05-21 22:07:30 +03:00
parent 398b612d8c
commit 1de4c2c9f2
8 changed files with 52 additions and 76 deletions

View file

@ -19,8 +19,7 @@
maintenance:1 maintenance:1
}, },
{ {
name:"Granary", name:"Granary",
baseDescription: "",
food:2, food:2,
resourceBonusStats:{food:1}, resourceBonusStats:{food:1},
maintenance:1, maintenance:1,
@ -28,8 +27,7 @@
requiredTech:"Pottery" requiredTech:"Pottery"
}, },
{ {
name:"Stone Works", name:"Stone Works",
baseDescription: "",
happiness:1, happiness:1,
production:1 production:1
requiredNearbyImprovedResources:["Marble","Stone"] requiredNearbyImprovedResources:["Marble","Stone"]
@ -40,7 +38,6 @@
}, },
{ {
name:"Stonehenge", name:"Stonehenge",
baseDescription: "",
culture:6, culture:6,
isWonder:true, isWonder:true,
greatPersonPoints:{production:1}, greatPersonPoints:{production:1},
@ -62,12 +59,11 @@
baseDescription: "Adds 1 science for each 2 population in the city.", baseDescription: "Adds 1 science for each 2 population in the city.",
hurryCostModifier:25, hurryCostModifier:25,
maintenance:1, maintenance:1,
unique:"Science Per 2 Population", unique:"+1 Science Per 2 Population",
requiredTech:"Writing" requiredTech:"Writing"
}, },
{ {
name:"Circus", name:"Circus",
baseDescription: "",
requiredNearbyImprovedResources:["Ivory","Horses"] requiredNearbyImprovedResources:["Ivory","Horses"]
happiness:2, happiness:2,
hurryCostModifier:25, hurryCostModifier:25,
@ -84,7 +80,6 @@
}, },
{ {
name:"Temple", name:"Temple",
baseDescription: "",
culture:3, culture:3,
specialistSlots:{culture:1}, specialistSlots:{culture:1},
requiredBuilding:"Monument", requiredBuilding:"Monument",
@ -103,7 +98,6 @@
}, },
{ {
name:"National College", name:"National College",
baseDescription: "",
science:3, science:3,
culture:1, culture:1,
isWonder:true, isWonder:true,
@ -121,8 +115,7 @@
requiredTech:"Civil Service" requiredTech:"Civil Service"
}, },
{ {
name:"Stable", name:"Stable",
baseDescription: "",
maintenance:1, maintenance:1,
requiredNearbyImprovedResources:["Horses","Sheep","Cattle"] requiredNearbyImprovedResources:["Horses","Sheep","Cattle"]
resourceBonusStats:{production:1}, resourceBonusStats:{production:1},
@ -131,7 +124,6 @@
}, },
{ {
name:"Circus Maximus", name:"Circus Maximus",
baseDescription: "",
happiness:5, happiness:5,
culture:1, culture:1,
isWonder:true, isWonder:true,
@ -140,7 +132,6 @@
}, },
{ {
name:"Hanging Gardens", name:"Hanging Gardens",
baseDescription: "",
greatPersonPoints:{culture:1}, greatPersonPoints:{culture:1},
food:10, food:10,
culture:1, culture:1,
@ -148,8 +139,7 @@
requiredTech:"Mathematics" requiredTech:"Mathematics"
}, },
{ {
name:"Colloseum", name:"Colloseum",
baseDescription: "",
maintenance:1, maintenance:1,
happiness:2, happiness:2,
hurryCostModifier:25, hurryCostModifier:25,
@ -157,7 +147,6 @@
}, },
{ {
name:"Market", name:"Market",
baseDescription: "",
gold:2, gold:2,
specialistSlots:{gold:1}, specialistSlots:{gold:1},
hurryCostModifier:25, hurryCostModifier:25,
@ -166,7 +155,6 @@
}, },
{ {
name:"Monastery", name:"Monastery",
baseDescription: "",
maintenance:0, maintenance:0,
requiredNearbyImprovedResources:["Wine","Incense"], requiredNearbyImprovedResources:["Wine","Incense"],
resourceBonusStats:{culture:2}, resourceBonusStats:{culture:2},
@ -175,7 +163,6 @@
}, },
{ {
name:"Notre Dame", name:"Notre Dame",
baseDescription: "",
culture:1, culture:1,
happiness:10, happiness:10,
greatPersonPoints:{gold:1}, greatPersonPoints:{gold:1},
@ -193,7 +180,6 @@
}, },
{ {
name:"Mint", name:"Mint",
baseDescription: "",
maintenance:0, maintenance:0,
requiredNearbyImprovedResources:["Gold","Silver"], requiredNearbyImprovedResources:["Gold","Silver"],
resourceBonusStats:{gold:2}, resourceBonusStats:{gold:2},
@ -219,8 +205,7 @@
requiredTech:"Engineering" requiredTech:"Engineering"
}, },
{ {
name:"Workshop", name:"Workshop",
baseDescription: "",
maintenance:2, maintenance:2,
production:2, production:2,
specialistSlots:{production:1}, specialistSlots:{production:1},
@ -230,7 +215,6 @@
}, },
{ {
name:"Forge", name:"Forge",
baseDescription: "",
maintenance:1, maintenance:1,
hurryCostModifier:25, hurryCostModifier:25,
requiredNearbyImprovedResources:["Iron"], requiredNearbyImprovedResources:["Iron"],
@ -279,7 +263,6 @@
}, },
{ {
name:"Ironworks", name:"Ironworks",
baseDescription: "",
production:8, production:8,
culture:1, culture:1,
isWonder:true, isWonder:true,
@ -297,7 +280,6 @@
}, },
{ {
name:"Opera House", name:"Opera House",
baseDescription: "",
culture:4, culture:4,
specialistSlots:{culture:1}, specialistSlots:{culture:1},
hurryCostModifier:10, hurryCostModifier:10,
@ -315,7 +297,6 @@
}, },
{ {
name:"Bank", name:"Bank",
baseDescription: "",
gold:2, gold:2,
specialistSlots:{gold:1}, specialistSlots:{gold:1},
hurryCostModifier:15, hurryCostModifier:15,
@ -333,7 +314,6 @@
}, },
{ {
name:"Theatre", name:"Theatre",
baseDescription: "",
happiness:3, happiness:3,
hurryCostModifier:10, hurryCostModifier:10,
maintenance:2, maintenance:2,
@ -351,7 +331,6 @@
}, },
{ {
name:"Windmill", name:"Windmill",
baseDescription: "",
production:2, production:2,
specialistSlots:{production:1}, specialistSlots:{production:1},
hurryCostModifier:25, hurryCostModifier:25,
@ -361,7 +340,6 @@
}, },
{ {
name:"Museum", name:"Museum",
baseDescription: "",
culture:5, culture:5,
specialistSlots:{culture:1}, specialistSlots:{culture:1},
requiredBuilding:"Opera House", requiredBuilding:"Opera House",
@ -371,7 +349,6 @@
}, },
{ {
name:"Hermitage", name:"Hermitage",
baseDescription: "",
percentStatBonus:{culture:50}, percentStatBonus:{culture:50},
culture:5, culture:5,
isWonder:true, isWonder:true,
@ -395,12 +372,11 @@
requiredBuilding:"University", requiredBuilding:"University",
maintenance:3, maintenance:3,
hurryCostModifier:0, hurryCostModifier:0,
unique:"Science Per 2 Population", unique:"+1 Science Per 2 Population",
requiredTech:"Scientific Theory" requiredTech:"Scientific Theory"
}, },
{ {
name:"Hospital", name:"Hospital",
baseDescription: "",
food:5, food:5,
requiredBuilding:"Aqueduct", requiredBuilding:"Aqueduct",
maintenance:2, maintenance:2,
@ -409,7 +385,6 @@
}, },
{ {
name:"Factory", name:"Factory",
baseDescription: "",
production:4, production:4,
percentStatBonus:{production:10}, percentStatBonus:{production:10},
specialistSlots:{production:1}, specialistSlots:{production:1},
@ -421,7 +396,6 @@
}, },
{ {
name:"Stock Exchange", name:"Stock Exchange",
baseDescription: "",
gold:3, gold:3,
percentStatBonus:{gold:25}, percentStatBonus:{gold:25},
specialistSlots:{gold:2}, specialistSlots:{gold:2},
@ -439,7 +413,6 @@
}, },
{ {
name:"Broadcast Tower", name:"Broadcast Tower",
baseDescription: "",
culture:3, culture:3,
percentStatBonus:{culture:33}, percentStatBonus:{culture:33},
requiredBuilding:"Museum", requiredBuilding:"Museum",
@ -464,7 +437,6 @@
}, },
{ {
name:"Research Lab", name:"Research Lab",
baseDescription: "",
science:4, science:4,
percentStatBonus:{science:50}, percentStatBonus:{science:50},
specialistSlots:{science:1}, specialistSlots:{science:1},
@ -481,7 +453,6 @@
}, },
{ {
name:"Stadium", name:"Stadium",
baseDescription: "",
happiness:4, happiness:4,
requiredBuilding:"Theatre", requiredBuilding:"Theatre",
maintenance:2, maintenance:2,

View file

@ -19,7 +19,6 @@
}, },
{ {
name:"Scout", name:"Scout",
baseDescription: "",
cost:25, cost:25,
unitType:"Melee", unitType:"Melee",
strength:5, strength:5,
@ -28,7 +27,6 @@
}, },
{ {
name:"Warrior", name:"Warrior",
baseDescription: "A basic fighting unit",
unitType:"Melee", unitType:"Melee",
movement:2, movement:2,
strength:8, strength:8,
@ -38,7 +36,6 @@
}, },
{ {
name:"Archer", name:"Archer",
baseDescription: "A basic fighting unit",
unitType:"Archery", unitType:"Archery",
movement:2, movement:2,
strength:5, strength:5,
@ -48,7 +45,6 @@
}, },
{ {
name:"Chariot Archer", name:"Chariot Archer",
baseDescription: "",
unitType:"Archery", unitType:"Archery",
movement:4, movement:4,
strength:6, strength:6,
@ -61,7 +57,6 @@
}, },
{ {
name:"Spearman", name:"Spearman",
baseDescription: "",
unitType:"Melee", unitType:"Melee",
movement:2, movement:2,
strength:11, strength:11,
@ -75,7 +70,6 @@
/* Classical Era */ /* Classical Era */
{ {
name:"Catapult", name:"Catapult",
baseDescription: "",
unitType:"Siege", unitType:"Siege",
movement:2, movement:2,
strength:7, strength:7,
@ -87,7 +81,6 @@
}, },
{ {
name:"Swordsman", name:"Swordsman",
baseDescription: "",
unitType:"Melee", unitType:"Melee",
movement:2, movement:2,
strength:14, strength:14,
@ -98,7 +91,6 @@
}, },
{ {
name:"Horseman", name:"Horseman",
baseDescription:"",
unitType:"Mounted", unitType:"Mounted",
movement:4, movement:4,
strength:12, strength:12,
@ -112,7 +104,6 @@
// Medieval Era // Medieval Era
{ {
name:"Crossbowman", name:"Crossbowman",
baseDescription: "",
unitType:"Archery", unitType:"Archery",
movement:2, movement:2,
strength:13, strength:13,
@ -123,7 +114,6 @@
}, },
{ {
name:"Trebuchet", name:"Trebuchet",
baseDescription: "",
unitType:"Siege", unitType:"Siege",
movement:2, movement:2,
strength:12, strength:12,
@ -135,7 +125,6 @@
}, },
{ {
name:"Longswordsman", name:"Longswordsman",
baseDescription: "",
unitType:"Melee", unitType:"Melee",
movement:2, movement:2,
strength:21, strength:21,
@ -146,7 +135,6 @@
}, },
{ {
name:"Pikeman", name:"Pikeman",
baseDescription: "",
unitType:"Melee", unitType:"Melee",
movement:2, movement:2,
strength:16, strength:16,

View file

@ -27,7 +27,7 @@ class CityConstructions {
val stats = Stats() val stats = Stats()
for (building in getBuiltBuildings()) for (building in getBuiltBuildings())
stats.add(building.getStats(cityInfo.civInfo.policies.adoptedPolicies)) stats.add(building.getStats(cityInfo.civInfo.policies.adoptedPolicies))
stats.science += (cityInfo.buildingUniques.count({ it == "Science Per 2 Population" }) * cityInfo.population.population / 2).toFloat() stats.science += (cityInfo.buildingUniques.count({ it == "+1 Science Per 2 Population" }) * cityInfo.population.population / 2).toFloat()
return stats return stats
} }

View file

@ -9,7 +9,7 @@ import com.unciv.ui.VictoryScreen
import com.unciv.ui.pickerscreens.PolicyPickerScreen import com.unciv.ui.pickerscreens.PolicyPickerScreen
class Building : NamedStats(), IConstruction{ class Building : NamedStats(), IConstruction{
private lateinit var baseDescription: String private var baseDescription: String? = null
override val description: String override val description: String
get() = getDescription(false, hashSetOf()) get() = getDescription(false, hashSetOf())
@ -45,9 +45,16 @@ class Building : NamedStats(), IConstruction{
fun getRequiredTech(): Technology = GameBasics.Technologies[requiredTech]!! fun getRequiredTech(): Technology = GameBasics.Technologies[requiredTech]!!
fun getShortDescription(): String { // should fit in one line fun getShortDescription(): String { // should fit in one line
var str = getStats(hashSetOf()).toString() val infoList= mutableListOf<String>()
if(unique!=null) str += ", "+ unique!! val str = getStats(hashSetOf()).toString()
return str if(str.isNotEmpty()) infoList += str
val improvedResources = GameBasics.TileResources.values.filter { it.building==name }
if(improvedResources.isNotEmpty()){
// buildings that improve resources
infoList += resourceBonusStats.toString() +" from "+improvedResources.joinToString()
}
if(unique!=null) infoList += unique!!
return infoList.joinToString()
} }
fun getStats(adoptedPolicies: HashSet<String>): Stats { fun getStats(adoptedPolicies: HashSet<String>): Stats {
@ -97,7 +104,7 @@ class Building : NamedStats(), IConstruction{
stringBuilder.appendln("Requires a $requiredBuildingInAllCities to be built in all cities") stringBuilder.appendln("Requires a $requiredBuildingInAllCities to be built in all cities")
if (providesFreeBuilding != null) if (providesFreeBuilding != null)
stringBuilder.appendln("Provides a free $providesFreeBuilding in this city") stringBuilder.appendln("Provides a free $providesFreeBuilding in this city")
stringBuilder.appendln(baseDescription) if(baseDescription!=null) stringBuilder.appendln(baseDescription)
if (stats.toString() != "") if (stats.toString() != "")
stringBuilder.appendln(stats) stringBuilder.appendln(stats)
if (this.percentStatBonus != null) { if (this.percentStatBonus != null) {
@ -120,7 +127,7 @@ class Building : NamedStats(), IConstruction{
} }
if (maintenance != 0) if (maintenance != 0)
stringBuilder.appendln("Maintenance cost: $maintenance gold") stringBuilder.appendln("Maintenance cost: $maintenance gold")
return stringBuilder.toString() return stringBuilder.toString().trim()
} }
override fun getProductionCost(adoptedPolicies: HashSet<String>): Int { override fun getProductionCost(adoptedPolicies: HashSet<String>): Int {

View file

@ -8,21 +8,6 @@ class Technology : ICivilopedia {
val SB=StringBuilder() val SB=StringBuilder()
if(baseDescription!=null) SB.appendln(baseDescription) if(baseDescription!=null) SB.appendln(baseDescription)
val enabledUnits = GameBasics.Units.values.filter { it.requiredTech==name }
if(enabledUnits.isNotEmpty()) SB.appendln("Units enabled: "+enabledUnits.map { it.name }.joinToString())
val enabledBuildings = GameBasics.Buildings.values.filter { it.requiredTech==name }
val regularBuildings = enabledBuildings.filter { !it.isWonder }
if(regularBuildings.isNotEmpty())
SB.appendln("Buildings enabled: "+regularBuildings.map { it.name + " ("+it.getShortDescription()+")" }.joinToString())
val wonders = enabledBuildings.filter { it.isWonder }
if(wonders.isNotEmpty()) SB.appendln("Wonders enabled: "+wonders.map { it.name }.joinToString())
val revealedResource = GameBasics.TileResources.values.filter { it.revealedBy==name }.firstOrNull() // can only be one
if(revealedResource!=null) SB.appendln("Reveals $revealedResource on map")
val tileImprovements = GameBasics.TileImprovements.values.filter { it.techRequired==name }
if(tileImprovements.isNotEmpty()) SB.appendln("Tile improvements enabled: "+tileImprovements.map { it.name }.joinToString())
val improvedImprovements = GameBasics.TileImprovements.values.filter { it.improvingTech==name }.groupBy { it.improvingTechStats.toString()!! } val improvedImprovements = GameBasics.TileImprovements.values.filter { it.improvingTech==name }.groupBy { it.improvingTechStats.toString()!! }
improvedImprovements.forEach{ improvedImprovements.forEach{
@ -30,6 +15,22 @@ class Technology : ICivilopedia {
SB.appendln(impimpString) SB.appendln(impimpString)
} }
val enabledUnits = GameBasics.Units.values.filter { it.requiredTech==name }
if(enabledUnits.isNotEmpty()) SB.appendln("Units enabled: "+enabledUnits.map { it.name + " ("+it.getShortDescription()+")" }.joinToString())
val enabledBuildings = GameBasics.Buildings.values.filter { it.requiredTech==name }
val regularBuildings = enabledBuildings.filter { !it.isWonder }
if(regularBuildings.isNotEmpty())
SB.appendln("Buildings enabled: "+regularBuildings.map { "\n * "+it.name + " ("+it.getShortDescription()+")" }.joinToString())
val wonders = enabledBuildings.filter { it.isWonder }
if(wonders.isNotEmpty()) SB.appendln("Wonders enabled: "+wonders.map { "\n * "+it.name+ " ("+it.getShortDescription()+")" }.joinToString())
val revealedResource = GameBasics.TileResources.values.filter { it.revealedBy==name }.firstOrNull() // can only be one
if(revealedResource!=null) SB.appendln("Reveals $revealedResource on map")
val tileImprovements = GameBasics.TileImprovements.values.filter { it.techRequired==name }
if(tileImprovements.isNotEmpty()) SB.appendln("Tile improvements enabled: "+tileImprovements.map { it.name }.joinToString())
return SB.toString().trim() return SB.toString().trim()
} }
lateinit var name: String lateinit var name: String

View file

@ -12,9 +12,18 @@ class Unit : INamed, IConstruction, ICivilopedia {
return getDescription(false) return getDescription(false)
} }
fun getShortDescription(): String {
val infoList= mutableListOf<String>()
if(baseDescription!=null) infoList+=baseDescription!!
if(strength!=0) infoList += "strength: $strength"
if(rangedStrength!=0) infoList += "ranged strength: $rangedStrength"
if(movement!=2) infoList+="movement: $movement"
return infoList.joinToString()
}
fun getDescription(forPickerScreen:Boolean): String { fun getDescription(forPickerScreen:Boolean): String {
val sb = StringBuilder() val sb = StringBuilder()
if(baseDescription!="") sb.appendln(baseDescription) if(baseDescription!=null) sb.appendln(baseDescription)
if(!forPickerScreen) { if(!forPickerScreen) {
if (unbuildable) sb.appendln("Unbuildable") if (unbuildable) sb.appendln("Unbuildable")
else sb.appendln("Cost: $cost") else sb.appendln("Cost: $cost")

View file

@ -30,8 +30,8 @@ open class PickerScreen : CameraStageBaseScreen() {
descriptionLabel = Label("", CameraStageBaseScreen.skin) descriptionLabel = Label("", CameraStageBaseScreen.skin)
descriptionLabel.setWrap(true) descriptionLabel.setWrap(true)
descriptionLabel.setFontScale(game.settings.labelScale) descriptionLabel.setFontScale(game.settings.labelScale)
descriptionLabel.width = stage.width / 2 val labelScroll = ScrollPane(descriptionLabel)
bottomTable.add(descriptionLabel).pad(5f).width(stage.width / 2) bottomTable.add(labelScroll).pad(5f).width(stage.width / 2)
rightSideButton = TextButton("", CameraStageBaseScreen.skin) rightSideButton = TextButton("", CameraStageBaseScreen.skin)
rightSideButton.disable() rightSideButton.disable()

View file

@ -83,8 +83,8 @@ class BattleTable(val worldScreen: WorldScreen): Table() {
if (defenderModifiers.size > i) add(defenderModifiers[i]) else add() if (defenderModifiers.size > i) add(defenderModifiers[i]) else add()
row().pad(5f) row().pad(5f)
} }
add(battle.getAttackingStrength(attacker,defender).toString()) add("%.2f".format(battle.getAttackingStrength(attacker,defender)))
add(battle.getDefendingStrength(attacker,defender).toString()) add("%.2f".format(battle.getDefendingStrength(attacker,defender)))
row().pad(5f) row().pad(5f)
var damageToDefender = battle.calculateDamageToDefender(attacker,defender) var damageToDefender = battle.calculateDamageToDefender(attacker,defender)