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

View File

@ -665,22 +665,12 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
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???
// 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
-> power += power / 4
unique.isOfType(UniqueType.MustSetUp) // Must set up - 20 % penalty
-> power -= power / 5
unique.placeholderText == "[] additional attacks per turn" // Extra attacks - 20% bonus per extra attack
-> 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
//
}
}