mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-30 14:48:56 +07:00
Civilopedia - Difficulty (#4789)
* Civilopedia - Difficulty * Civilopedia - Difficulty - patch2 * Civilopedia - Difficulty - patch3
This commit is contained in:
@ -2,9 +2,11 @@ package com.unciv.models.ruleset
|
||||
|
||||
import com.unciv.Constants
|
||||
import com.unciv.models.stats.INamed
|
||||
import com.unciv.models.translations.tr
|
||||
import com.unciv.ui.civilopedia.ICivilopediaText
|
||||
import com.unciv.ui.civilopedia.FormattedLine
|
||||
import com.unciv.ui.utils.Fonts
|
||||
|
||||
class Difficulty: INamed {
|
||||
class Difficulty: INamed, ICivilopediaText {
|
||||
override lateinit var name: String
|
||||
var baseHappiness: Int = 0
|
||||
var extraHappinessPerLuxury: Float = 0f
|
||||
@ -32,35 +34,80 @@ class Difficulty: INamed {
|
||||
var turnBarbariansCanEnterPlayerTiles = 0
|
||||
var clearBarbarianCampReward = 25
|
||||
|
||||
fun getDescription(): String {
|
||||
val lines = ArrayList<String>()
|
||||
lines += "Player settings"
|
||||
lines += " - {Base Happiness}: $baseHappiness"
|
||||
lines += " - {Happiness per luxury}: $extraHappinessPerLuxury"
|
||||
lines += " - {Research cost modifier}: $researchCostModifier"
|
||||
lines += " - {Unit cost modifier}: $researchCostModifier"
|
||||
lines += " - {Building cost modifier}: $buildingCostModifier"
|
||||
lines += " - {Policy cost modifier}: $policyCostModifier"
|
||||
lines += " - {Unhappiness modifier}: $unhappinessModifier"
|
||||
lines += " - {Bonus vs. Barbarians}: $barbarianBonus"
|
||||
// lines += " - {Starting units}: $startingUnits"
|
||||
lines += ""
|
||||
lines += "AI settings"
|
||||
lines += " - {AI city growth modifier}: $aiCityGrowthModifier"
|
||||
lines += " - {AI unit cost modifier}: $aiUnitCostModifier"
|
||||
lines += " - {AI building cost modifier}: $aiBuildingCostModifier"
|
||||
lines += " - {AI wonder cost modifier}: $aiWonderCostModifier"
|
||||
lines += " - {AI building maintenance modifier}: $aiBuildingMaintenanceModifier"
|
||||
lines += " - {AI unit maintenance modifier}: $aiUnitMaintenanceModifier"
|
||||
// lines += " - {AI free techs}: $aiFreeTechs"
|
||||
// lines += " - {AI major civilizations starting units}: $aiMajorCivStartingUnits"
|
||||
// lines += " - {AI city-state starting units}: $aiCityStateStartingUnits"
|
||||
lines += " - {AI unhappiness modifier}: $aiUnhappinessModifier"
|
||||
lines += ""
|
||||
lines += "{Turns until barbarians enter player tiles}: $turnBarbariansCanEnterPlayerTiles"
|
||||
lines += "{Gold reward for clearing barbarian camps}: $clearBarbarianCampReward"
|
||||
// property defined in json but so far unused:
|
||||
// var aisExchangeTechs = false
|
||||
|
||||
return lines.joinToString("\n") { it.tr() }
|
||||
override var civilopediaText = listOf<FormattedLine>()
|
||||
|
||||
|
||||
override fun makeLink() = "Difficulty/$name"
|
||||
override fun replacesCivilopediaDescription() = true
|
||||
override fun hasCivilopediaTextLines() = true
|
||||
|
||||
private fun Float.toPercent() = (this * 100).toInt()
|
||||
override fun getCivilopediaTextLines(ruleset: Ruleset): List<FormattedLine> {
|
||||
val lines = ArrayList<FormattedLine>()
|
||||
lines += FormattedLine("Player settings", header = 3)
|
||||
lines += FormattedLine("{Base Happiness}: $baseHappiness ${Fonts.happiness}", indent = 1)
|
||||
lines += FormattedLine("{Extra happiness per luxury}: ${extraHappinessPerLuxury.toInt()} ${Fonts.happiness}", indent = 1)
|
||||
lines += FormattedLine("{Research cost modifier}: ${researchCostModifier.toPercent()}% ${Fonts.science}", indent = 1)
|
||||
lines += FormattedLine("{Unit cost modifier}: ${unitCostModifier.toPercent()}% ${Fonts.production}", indent = 1)
|
||||
lines += FormattedLine("{Building cost modifier}: ${buildingCostModifier.toPercent()}% ${Fonts.production}", indent = 1)
|
||||
lines += FormattedLine("{Policy cost modifier}: ${policyCostModifier.toPercent()}% ${Fonts.culture}", indent = 1)
|
||||
lines += FormattedLine("{Unhappiness modifier}: ${unhappinessModifier.toPercent()}%", indent = 1)
|
||||
lines += FormattedLine("{Bonus vs. Barbarians}: ${barbarianBonus.toPercent()}% ${Fonts.strength}", indent = 1)
|
||||
|
||||
if (playerBonusStartingUnits.isNotEmpty()) {
|
||||
lines += FormattedLine()
|
||||
lines += FormattedLine("{Bonus starting units}:", indent = 1)
|
||||
playerBonusStartingUnits.groupBy { it }.map {
|
||||
it.key to it.value.size // name to Pair.first and count to Pair.second
|
||||
}.forEach {
|
||||
// Through a virtual Unique was the simplest way to prevent white icons showing for stuff like eraSpecificUnit
|
||||
lines += FormattedLine(Unique(if (it.second == 1) "[${it.first}]" else "${it.second} [${it.first}]"), indent = 2)
|
||||
}
|
||||
}
|
||||
|
||||
lines += FormattedLine()
|
||||
lines += FormattedLine("AI settings", header = 3)
|
||||
lines += FormattedLine("{AI city growth modifier}: ${aiCityGrowthModifier.toPercent()}% ${Fonts.food}", indent = 1)
|
||||
lines += FormattedLine("{AI unit cost modifier}: ${aiUnitCostModifier.toPercent()}% ${Fonts.production}", indent = 1)
|
||||
lines += FormattedLine("{AI building cost modifier}: ${aiBuildingCostModifier.toPercent()}% ${Fonts.production}", indent = 1)
|
||||
lines += FormattedLine("{AI wonder cost modifier}: ${aiWonderCostModifier.toPercent()}% ${Fonts.production}", indent = 1)
|
||||
lines += FormattedLine("{AI building maintenance modifier}: ${aiBuildingMaintenanceModifier.toPercent()}% ${Fonts.gold}", indent = 1)
|
||||
lines += FormattedLine("{AI unit maintenance modifier}: ${aiUnitMaintenanceModifier.toPercent()}% ${Fonts.gold}", indent = 1)
|
||||
lines += FormattedLine("{AI unhappiness modifier}: ${aiUnhappinessModifier.toPercent()}%", indent = 1)
|
||||
|
||||
if (aiFreeTechs.isNotEmpty()) {
|
||||
lines += FormattedLine()
|
||||
lines += FormattedLine("{AI free techs}:", indent = 1)
|
||||
aiFreeTechs.forEach {
|
||||
lines += FormattedLine(it, link = "Technology/$it", indent = 2)
|
||||
}
|
||||
}
|
||||
if (aiMajorCivBonusStartingUnits.isNotEmpty()) {
|
||||
lines += FormattedLine()
|
||||
lines += FormattedLine("{Major AI civilization bonus starting units}:", indent = 1)
|
||||
aiMajorCivBonusStartingUnits.groupBy { it }.map {
|
||||
it.key to it.value.size
|
||||
}.forEach {
|
||||
lines += FormattedLine(Unique(if (it.second == 1) "[${it.first}]" else "${it.second} [${it.first}]"), indent = 2)
|
||||
}
|
||||
}
|
||||
if (aiCityStateBonusStartingUnits.isNotEmpty()) {
|
||||
lines += FormattedLine()
|
||||
lines += FormattedLine("{City state bonus starting units}:", indent = 1)
|
||||
aiCityStateBonusStartingUnits.groupBy { it }.map {
|
||||
it.key to it.value.size
|
||||
}.forEach {
|
||||
lines += FormattedLine(Unique(if (it.second == 1) "[${it.first}]" else "${it.second} [${it.first}]"), indent = 2)
|
||||
}
|
||||
}
|
||||
|
||||
lines += FormattedLine()
|
||||
lines += FormattedLine("{Turns until barbarians enter player tiles}: $turnBarbariansCanEnterPlayerTiles ${Fonts.turn}")
|
||||
lines += FormattedLine("{Gold reward for clearing barbarian camps}: $clearBarbarianCampReward ${Fonts.gold}")
|
||||
return lines
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -280,8 +280,9 @@ class CivilopediaScreen(
|
||||
.map {
|
||||
CivilopediaEntry(
|
||||
it.name,
|
||||
it.getDescription(),
|
||||
"",
|
||||
// CivilopediaCategories.Difficulty.getImage?.invoke(it.name, imageSize)
|
||||
flavour = (it as? ICivilopediaText)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ class FormattedLine (
|
||||
// have no backing field, be `by lazy` or use @Transient, Thank you.
|
||||
|
||||
/** Looks for linkable ruleset objects in [Unique] parameters and returns a linked [FormattedLine] if successful, a plain one otherwise */
|
||||
constructor(unique: Unique) : this(unique.text, getUniqueLink(unique))
|
||||
constructor(unique: Unique, indent: Int = 0) : this(unique.text, getUniqueLink(unique), indent = indent)
|
||||
|
||||
/** Link types that can be used for [FormattedLine.link] */
|
||||
enum class LinkType {
|
||||
|
Reference in New Issue
Block a user