mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-15 18:28:42 +07:00
Use stat characters in Civilopedia Unit/Building costs (#4736)
This commit is contained in:
@ -1509,7 +1509,7 @@
|
|||||||
"name": "Great Prophet",
|
"name": "Great Prophet",
|
||||||
"unitType": "Civilian",
|
"unitType": "Civilian",
|
||||||
"uniques": ["Can construct [Holy site] if it hasn't spread religion yet", "Can spread religion [4] times",
|
"uniques": ["Can construct [Holy site] if it hasn't spread religion yet", "Can spread religion [4] times",
|
||||||
"May found a religion", "Great Person - [Faith]", "Unbuildable"],
|
"May found a religion", "Great Person - [Faith]", "Unbuildable", "Hidden when religion is disabled"],
|
||||||
"movement": 2
|
"movement": 2
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -13,6 +13,7 @@ import com.unciv.models.translations.fillPlaceholders
|
|||||||
import com.unciv.models.translations.tr
|
import com.unciv.models.translations.tr
|
||||||
import com.unciv.ui.civilopedia.FormattedLine
|
import com.unciv.ui.civilopedia.FormattedLine
|
||||||
import com.unciv.ui.civilopedia.ICivilopediaText
|
import com.unciv.ui.civilopedia.ICivilopediaText
|
||||||
|
import com.unciv.ui.utils.Fonts
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.collections.ArrayList
|
import kotlin.collections.ArrayList
|
||||||
import kotlin.collections.HashMap
|
import kotlin.collections.HashMap
|
||||||
@ -221,8 +222,9 @@ class Building : NamedStats(), IConstruction, ICivilopediaText {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cost > 0) {
|
if (cost > 0) {
|
||||||
textList += FormattedLine()
|
val stats = mutableListOf("$cost${Fonts.production}")
|
||||||
textList += FormattedLine("{Cost}: $cost")
|
if (canBePurchased()) stats += "${(getBaseGoldCost()*0.1).toInt()*10}${Fonts.gold}"
|
||||||
|
textList += FormattedLine(stats.joinToString(", ", "{Cost}: "))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (requiredTech != null || requiredBuilding != null || requiredBuildingInAllCities != null)
|
if (requiredTech != null || requiredBuilding != null || requiredBuildingInAllCities != null)
|
||||||
@ -349,6 +351,8 @@ class Building : NamedStats(), IConstruction, ICivilopediaText {
|
|||||||
return productionCost.toInt()
|
return productionCost.toInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getBaseGoldCost() = (30.0 * cost).pow(0.75) * (1 + hurryCostModifier / 100.0)
|
||||||
|
|
||||||
override fun getGoldCost(civInfo: CivilizationInfo): Int {
|
override fun getGoldCost(civInfo: CivilizationInfo): Int {
|
||||||
// https://forums.civfanatics.com/threads/rush-buying-formula.393892/
|
// https://forums.civfanatics.com/threads/rush-buying-formula.393892/
|
||||||
var cost = (30 * getProductionCost(civInfo)).toDouble().pow(0.75) * (1 + hurryCostModifier / 100f)
|
var cost = (30 * getProductionCost(civInfo)).toDouble().pow(0.75) * (1 + hurryCostModifier / 100f)
|
||||||
|
@ -97,10 +97,16 @@ class BaseUnit : INamed, IConstruction, ICivilopediaText {
|
|||||||
stats += "$range${Fonts.range}"
|
stats += "$range${Fonts.range}"
|
||||||
}
|
}
|
||||||
if (movement != 0 && !movesLikeAirUnits()) stats += "$movement${Fonts.movement}"
|
if (movement != 0 && !movesLikeAirUnits()) stats += "$movement${Fonts.movement}"
|
||||||
if (cost != 0) stats += "{Cost}: $cost"
|
|
||||||
if (stats.isNotEmpty())
|
if (stats.isNotEmpty())
|
||||||
textList += FormattedLine(stats.joinToString(", "))
|
textList += FormattedLine(stats.joinToString(", "))
|
||||||
|
|
||||||
|
if (cost > 0) {
|
||||||
|
stats.clear()
|
||||||
|
stats += "$cost${Fonts.production}"
|
||||||
|
if (canBePurchased()) stats += "${(getBaseGoldCost()*0.1).toInt()*10}${Fonts.gold}"
|
||||||
|
textList += FormattedLine(stats.joinToString(", ", "{Cost}: "))
|
||||||
|
}
|
||||||
|
|
||||||
if (replacementTextForUniques != "") {
|
if (replacementTextForUniques != "") {
|
||||||
textList += FormattedLine()
|
textList += FormattedLine()
|
||||||
textList += FormattedLine(replacementTextForUniques)
|
textList += FormattedLine(replacementTextForUniques)
|
||||||
@ -185,12 +191,12 @@ class BaseUnit : INamed, IConstruction, ICivilopediaText {
|
|||||||
return productionCost.toInt()
|
return productionCost.toInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getBaseGoldCost(civInfo: CivilizationInfo): Double {
|
private fun getBaseGoldCost() = (30.0 * cost).pow(0.75) * (1 + hurryCostModifier / 100.0)
|
||||||
return (30.0 * cost).pow(0.75) * (1 + hurryCostModifier / 100f) * civInfo.gameInfo.gameParameters.gameSpeed.modifier
|
private fun getGoldCostWithGameSpeed(civInfo: CivilizationInfo) =
|
||||||
}
|
getBaseGoldCost() * civInfo.gameInfo.gameParameters.gameSpeed.modifier
|
||||||
|
|
||||||
override fun getGoldCost(civInfo: CivilizationInfo): Int {
|
override fun getGoldCost(civInfo: CivilizationInfo): Int {
|
||||||
var cost = getBaseGoldCost(civInfo)
|
var cost = getGoldCostWithGameSpeed(civInfo)
|
||||||
for (unique in civInfo.getMatchingUniques("Gold cost of purchasing [] units -[]%")) {
|
for (unique in civInfo.getMatchingUniques("Gold cost of purchasing [] units -[]%")) {
|
||||||
if (matchesFilter(unique.params[0]))
|
if (matchesFilter(unique.params[0]))
|
||||||
cost *= 1f - unique.params[1].toFloat() / 100f
|
cost *= 1f - unique.params[1].toFloat() / 100f
|
||||||
@ -205,7 +211,7 @@ class BaseUnit : INamed, IConstruction, ICivilopediaText {
|
|||||||
return (cost / 10).toInt() * 10 // rounded down to nearest ten
|
return (cost / 10).toInt() * 10 // rounded down to nearest ten
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getDisbandGold(civInfo: CivilizationInfo) = getBaseGoldCost(civInfo).toInt() / 20
|
fun getDisbandGold(civInfo: CivilizationInfo) = getGoldCostWithGameSpeed(civInfo).toInt() / 20
|
||||||
|
|
||||||
override fun shouldBeDisplayed(construction: CityConstructions): Boolean {
|
override fun shouldBeDisplayed(construction: CityConstructions): Boolean {
|
||||||
val rejectionReason = getRejectionReason(construction)
|
val rejectionReason = getRejectionReason(construction)
|
||||||
|
@ -228,7 +228,9 @@ class CivilopediaScreen(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
categoryToEntries[CivilopediaCategories.Unit] = ruleset.units.values
|
categoryToEntries[CivilopediaCategories.Unit] = ruleset.units.values
|
||||||
.filter { "Will not be displayed in Civilopedia" !in it.uniques }
|
.filter { "Will not be displayed in Civilopedia" !in it.uniques
|
||||||
|
&& !(hideReligionItems && "Hidden when religion is disabled" in it.uniques)
|
||||||
|
}
|
||||||
.map {
|
.map {
|
||||||
CivilopediaEntry(
|
CivilopediaEntry(
|
||||||
it.name,
|
it.name,
|
||||||
|
Reference in New Issue
Block a user