Simplified civ info stats happiness breakdown

This commit is contained in:
yairm210 2021-11-22 20:53:08 +02:00
parent 4617bc21a7
commit 4113b810ff
2 changed files with 25 additions and 48 deletions

View File

@ -290,67 +290,54 @@ class CivInfoStats(val civInfo: CivilizationInfo) {
statMap["Natural Wonders"] = happinessPerNaturalWonder * civInfo.naturalWonders.size statMap["Natural Wonders"] = happinessPerNaturalWonder * civInfo.naturalWonders.size
if (civInfo.religionManager.religion != null) { if (civInfo.religionManager.religion != null) {
statMap["Religion"] = 0f var religionHappiness = 0f
for (unique in civInfo.religionManager.religion!!.getBeliefs(BeliefType.Founder) for (unique in civInfo.religionManager.religion!!.getBeliefs(BeliefType.Founder)
.flatMap { it.uniqueObjects }) { .flatMap { it.uniqueObjects }) {
if (unique.placeholderText == "[] for each global city following this religion") { if (unique.placeholderText == "[] for each global city following this religion") {
statMap["Religion"] = val followingCities =
statMap["Religion"]!! + civInfo.religionManager.numberOfCitiesFollowingThisReligion()
unique.stats.happiness * civInfo.religionManager.numberOfCitiesFollowingThisReligion() religionHappiness += unique.stats.happiness * followingCities
.toFloat()
} }
if (unique.placeholderText == "[] for every [] global followers []") { if (unique.placeholderText == "[] for every [] global followers []") {
statMap["Religion"] = val followers =
statMap["Religion"]!! + civInfo.religionManager.numberOfFollowersFollowingThisReligion(unique.params[2])
unique.stats.happiness * religionHappiness +=
civInfo.religionManager.numberOfFollowersFollowingThisReligion( unique.stats.happiness * (followers / unique.params[1].toInt())
unique.params[2]
).toFloat() /
unique.params[1].toFloat()
} }
} }
if (statMap["Religion"] == 0f) if (religionHappiness > 0) statMap["Religion"] = religionHappiness
statMap.remove("Religion")
} }
//From city-states //From city-states
var cityStatesHappiness = 0f
for (otherCiv in civInfo.getKnownCivs()) { for (otherCiv in civInfo.getKnownCivs()) {
val relationshipLevel = otherCiv.getDiplomacyManager(civInfo).relationshipLevel() val relationshipLevel = otherCiv.getDiplomacyManager(civInfo).relationshipLevel()
if (otherCiv.isCityState() && relationshipLevel >= RelationshipLevel.Friend) { if (!otherCiv.isCityState() || relationshipLevel < RelationshipLevel.Friend) continue
val eraInfo = civInfo.getEra()
if (!eraInfo.undefinedCityStateBonuses()) { val eraInfo = civInfo.getEra()
for (bonus in eraInfo.getCityStateBonuses(otherCiv.cityStateType, relationshipLevel)) { // Deprecated, assume Civ V values for compatibility
if (!bonus.conditionalsApply(otherCiv)) continue if (!eraInfo.undefinedCityStateBonuses()) {
if (bonus.isOfType(UniqueType.CityStateHappiness)) { for (bonus in eraInfo.getCityStateBonuses(otherCiv.cityStateType, relationshipLevel)) {
if (statMap.containsKey("City-States")) if (!bonus.conditionalsApply(otherCiv)) continue
statMap["City-States"] = if (bonus.isOfType(UniqueType.CityStateHappiness))
statMap["City-States"]!! + bonus.params[0].toFloat() cityStatesHappiness += bonus.params[0].toFloat()
else
statMap["City-States"] = bonus.params[0].toFloat()
}
}
} else {
// Deprecated, assume Civ V values for compatibility
if (otherCiv.cityStateType == CityStateType.Mercantile) {
val happinessBonus = if (civInfo.getEraNumber() in 0..1) 2f else 3f
if (statMap.containsKey("City-States"))
statMap["City-States"] = statMap["City-States"]!! + happinessBonus
else
statMap["City-States"] = happinessBonus
}
} }
} else if (otherCiv.cityStateType == CityStateType.Mercantile) {
// compatibility mode for
cityStatesHappiness += if (civInfo.getEraNumber() in 0..1) 2f else 3f
} }
} }
// Just in case // Just in case
if (statMap.containsKey("City-States")) { if (cityStatesHappiness > 0) {
for (unique in civInfo.getMatchingUniques("[]% [] from City-States")) { for (unique in civInfo.getMatchingUniques("[]% [] from City-States")) {
if (unique.params[1] == Stat.Happiness.name) if (unique.params[1] == Stat.Happiness.name)
statMap["City-States"] = statMap["City-States"]!! * unique.params[0].toPercent() cityStatesHappiness *= unique.params[0].toPercent()
} }
} }
if (cityStatesHappiness > 0) statMap["City-States"] = cityStatesHappiness
return statMap return statMap
} }

View File

@ -665,22 +665,12 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
unique.isOfType(UniqueType.StrengthNearCapital) && unique.params[0].toInt() > 0 -> unique.isOfType(UniqueType.StrengthNearCapital) && unique.params[0].toInt() > 0 ->
power *= (unique.params[0].toInt() / 4f).toPercent() // Bonus decreasing with distance from capital - not worth much most of the map??? power *= (unique.params[0].toInt() / 4f).toPercent() // Bonus decreasing with distance from capital - not worth much most of the map???
// Deprecated since 3.17.4
unique.isOfType(UniqueType.StrengthAttacking) // Attack - half the bonus
-> power += (power * unique.params[0].toInt()) / 200
unique.isOfType(UniqueType.StrengthDefending) // Defense - half the bonus
-> power += (power * unique.params[0].toInt()) / 200
//
unique.placeholderText == "May Paradrop up to [] tiles from inside friendly territory" // Paradrop - 25% bonus unique.placeholderText == "May Paradrop up to [] tiles from inside friendly territory" // Paradrop - 25% bonus
-> power += power / 4 -> power += power / 4
unique.isOfType(UniqueType.MustSetUp) // Must set up - 20 % penalty unique.isOfType(UniqueType.MustSetUp) // Must set up - 20 % penalty
-> power -= power / 5 -> power -= power / 5
unique.placeholderText == "[] additional attacks per turn" // Extra attacks - 20% bonus per extra attack unique.placeholderText == "[] additional attacks per turn" // Extra attacks - 20% bonus per extra attack
-> power += (power * unique.params[0].toInt()) / 5 -> power += (power * unique.params[0].toInt()) / 5
// Deprecated since 3.17.5
unique.isOfType(UniqueType.StrengthIn) // Bonus in terrain or feature - half the bonus
-> power += (power * unique.params[0].toInt()) / 200
//
} }
} }