mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 22:37:02 -04:00
Converted building GPP from stats to counter
This commit is contained in:
parent
2c050283b0
commit
0ed47f10a8
@ -323,15 +323,16 @@ class CityInfo {
|
|||||||
for ((specialistName, amount) in population.getNewSpecialists())
|
for ((specialistName, amount) in population.getNewSpecialists())
|
||||||
if (getRuleset().specialists.containsKey(specialistName)) { // To solve problems in total remake mods
|
if (getRuleset().specialists.containsKey(specialistName)) { // To solve problems in total remake mods
|
||||||
val specialist = getRuleset().specialists[specialistName]!!
|
val specialist = getRuleset().specialists[specialistName]!!
|
||||||
specialistsCounter.add(GreatPersonManager.statsToGreatPersonCounter(specialist.greatPersonPoints)
|
specialistsCounter.add(
|
||||||
.times(amount))
|
GreatPersonManager.statsToGreatPersonCounter(specialist.greatPersonPoints)
|
||||||
|
.times(amount)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
sourceToGPP["Specialists"] = specialistsCounter
|
sourceToGPP["Specialists"] = specialistsCounter
|
||||||
|
|
||||||
val buildingsCounter = Counter<String>()
|
val buildingsCounter = Counter<String>()
|
||||||
for (building in cityConstructions.getBuiltBuildings())
|
for (building in cityConstructions.getBuiltBuildings())
|
||||||
if (building.greatPersonPoints != null)
|
buildingsCounter.add(building.greatPersonPoints)
|
||||||
buildingsCounter.add(GreatPersonManager.statsToGreatPersonCounter(building.greatPersonPoints!!))
|
|
||||||
sourceToGPP["Buildings"] = buildingsCounter
|
sourceToGPP["Buildings"] = buildingsCounter
|
||||||
|
|
||||||
for ((source, gppCounter) in sourceToGPP) {
|
for ((source, gppCounter) in sourceToGPP) {
|
||||||
@ -349,11 +350,13 @@ class CityInfo {
|
|||||||
|
|
||||||
// Sweden UP
|
// Sweden UP
|
||||||
for (otherciv in civInfo.getKnownCivs()) {
|
for (otherciv in civInfo.getKnownCivs()) {
|
||||||
if (!civInfo.getDiplomacyManager(otherciv).hasFlag(DiplomacyFlags.DeclarationOfFriendship)) continue
|
if (!civInfo.getDiplomacyManager(otherciv)
|
||||||
|
.hasFlag(DiplomacyFlags.DeclarationOfFriendship)
|
||||||
|
) continue
|
||||||
|
|
||||||
for(ourunique in civInfo.getMatchingUniques("When declaring friendship, both parties gain a []% boost to great person generation"))
|
for (ourunique in civInfo.getMatchingUniques("When declaring friendship, both parties gain a []% boost to great person generation"))
|
||||||
allGppPercentageBonus += ourunique.params[0].toInt()
|
allGppPercentageBonus += ourunique.params[0].toInt()
|
||||||
for(theirunique in otherciv.getMatchingUniques("When declaring friendship, both parties gain a []% boost to great person generation"))
|
for (theirunique in otherciv.getMatchingUniques("When declaring friendship, both parties gain a []% boost to great person generation"))
|
||||||
allGppPercentageBonus += theirunique.params[0].toInt()
|
allGppPercentageBonus += theirunique.params[0].toInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -361,6 +364,20 @@ class CityInfo {
|
|||||||
gppCounter.add(unitName, gppCounter[unitName]!! * allGppPercentageBonus / 100)
|
gppCounter.add(unitName, gppCounter[unitName]!! * allGppPercentageBonus / 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Since existing buildings and specialists have *stat names* rather than Great Person names
|
||||||
|
// as the keys, convert every stat name to the appropriate Great Person name instead
|
||||||
|
|
||||||
|
for (counter in sourceToGPP.values)
|
||||||
|
for ((key, gppAmount) in counter.toMap()) { // since we're removing, copy to avoid concurrency problems
|
||||||
|
val relevantStatEntry = GreatPersonManager.statToGreatPersonMapping
|
||||||
|
.entries.firstOrNull { it.key.name.equals(key, true) }
|
||||||
|
if (relevantStatEntry == null) continue
|
||||||
|
|
||||||
|
counter.add(relevantStatEntry.value, gppAmount)
|
||||||
|
counter.remove(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return sourceToGPP
|
return sourceToGPP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,8 @@ open class Counter<K> : LinkedHashMap<K, Int>() {
|
|||||||
|
|
||||||
override operator fun get(key: K): Int? { // don't return null if empty
|
override operator fun get(key: K): Int? { // don't return null if empty
|
||||||
if (containsKey(key))
|
if (containsKey(key))
|
||||||
return super.get(key)
|
// .toInt(), because GDX deserializes Counter values as *floats* for some reason
|
||||||
|
return super.get(key)!!.toInt()
|
||||||
else return 0
|
else return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ import com.unciv.logic.city.CityConstructions
|
|||||||
import com.unciv.logic.city.CityInfo
|
import com.unciv.logic.city.CityInfo
|
||||||
import com.unciv.logic.city.IConstruction
|
import com.unciv.logic.city.IConstruction
|
||||||
import com.unciv.logic.civilization.CivilizationInfo
|
import com.unciv.logic.civilization.CivilizationInfo
|
||||||
import com.unciv.logic.civilization.GreatPersonManager
|
|
||||||
import com.unciv.models.Counter
|
import com.unciv.models.Counter
|
||||||
import com.unciv.models.ruleset.tile.TileImprovement
|
import com.unciv.models.ruleset.tile.TileImprovement
|
||||||
import com.unciv.models.stats.NamedStats
|
import com.unciv.models.stats.NamedStats
|
||||||
@ -42,7 +41,7 @@ class Building : NamedStats(), IConstruction, ICivilopediaText {
|
|||||||
return counter
|
return counter
|
||||||
}
|
}
|
||||||
|
|
||||||
var greatPersonPoints: Stats? = null
|
var greatPersonPoints= Counter<String>()
|
||||||
|
|
||||||
/** Extra cost percentage when purchasing */
|
/** Extra cost percentage when purchasing */
|
||||||
private var hurryCostModifier = 0
|
private var hurryCostModifier = 0
|
||||||
@ -136,13 +135,8 @@ class Building : NamedStats(), IConstruction, ICivilopediaText {
|
|||||||
if (percentStats.food != 0f) stringBuilder.append("+" + percentStats.food.toInt() + "% {Food}\n".tr())
|
if (percentStats.food != 0f) stringBuilder.append("+" + percentStats.food.toInt() + "% {Food}\n".tr())
|
||||||
if (percentStats.culture != 0f) stringBuilder.append("+" + percentStats.culture.toInt() + "% {Culture}\r\n".tr())
|
if (percentStats.culture != 0f) stringBuilder.append("+" + percentStats.culture.toInt() + "% {Culture}\r\n".tr())
|
||||||
|
|
||||||
if (this.greatPersonPoints != null) {
|
for((greatPersonName, value) in greatPersonPoints)
|
||||||
val gpp = this.greatPersonPoints!!
|
stringBuilder.appendLine("+$value "+"[$greatPersonName] points".tr())
|
||||||
if (gpp.production != 0f) stringBuilder.appendLine("+" + gpp.production.toInt() + " " + "[Great Engineer] points".tr())
|
|
||||||
if (gpp.gold != 0f) stringBuilder.appendLine("+" + gpp.gold.toInt() + " " + "[Great Merchant] points".tr())
|
|
||||||
if (gpp.science != 0f) stringBuilder.appendLine("+" + gpp.science.toInt() + " " + "[Great Scientist] points".tr())
|
|
||||||
if (gpp.culture != 0f) stringBuilder.appendLine("+" + gpp.culture.toInt() + " " + "[Great Artist] points".tr())
|
|
||||||
}
|
|
||||||
|
|
||||||
for ((specialistName, amount) in newSpecialists())
|
for ((specialistName, amount) in newSpecialists())
|
||||||
stringBuilder.appendLine("+$amount " + "[$specialistName] slots".tr())
|
stringBuilder.appendLine("+$amount " + "[$specialistName] slots".tr())
|
||||||
@ -260,7 +254,7 @@ class Building : NamedStats(), IConstruction, ICivilopediaText {
|
|||||||
val stats = this.clone()
|
val stats = this.clone()
|
||||||
val percentStats = getStatPercentageBonuses(null)
|
val percentStats = getStatPercentageBonuses(null)
|
||||||
val specialists = newSpecialists()
|
val specialists = newSpecialists()
|
||||||
if (uniques.isNotEmpty() || !stats.isEmpty() || !percentStats.isEmpty() || this.greatPersonPoints != null || specialists.isNotEmpty())
|
if (uniques.isNotEmpty() || !stats.isEmpty() || !percentStats.isEmpty() || this.greatPersonPoints.isNotEmpty() || specialists.isNotEmpty())
|
||||||
textList += FormattedLine()
|
textList += FormattedLine()
|
||||||
|
|
||||||
if (uniques.isNotEmpty()) {
|
if (uniques.isNotEmpty()) {
|
||||||
@ -282,14 +276,11 @@ class Building : NamedStats(), IConstruction, ICivilopediaText {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (greatPersonPoints != null) {
|
for((greatPersonName, value) in greatPersonPoints) {
|
||||||
for ( (key, value) in greatPersonPoints!!.toHashMap()) {
|
textList += FormattedLine(
|
||||||
if (value == 0f) continue
|
"+$value " + "[$greatPersonName] points".tr(),
|
||||||
val gppName = GreatPersonManager.statToGreatPersonMapping[key]
|
link = "Unit/$greatPersonName"
|
||||||
?: continue
|
)
|
||||||
textList += FormattedLine(value.formatSignedInt() + " " + "[$gppName] points".tr(),
|
|
||||||
link = "Unit/$gppName")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (specialists.isNotEmpty()) {
|
if (specialists.isNotEmpty()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user