Moar policies! Policy stat changes can now happen from wonders as well!

This commit is contained in:
Yair Morgenstern 2020-07-31 00:25:48 +03:00
parent 8fec837e64
commit 0f727e1929
5 changed files with 37 additions and 26 deletions

View file

@ -354,7 +354,7 @@
"culture": 1,
"greatPersonPoints": {"culture": 1},
"isWonder": true,
"uniques": ["+33% great person generation in all cities"],
"uniques": ["+[33]% great person generation in all cities"],
"requiredTech": "Theology",
"quote": "'For it soars to a height to match the sky, and as if surging up from among the other buildings it stands on high and looks down upon the remainder of the city, adorning it, because it is a part of it, but glorying in its own beauty' - Procopius, De Aedificis"
},

View file

@ -397,16 +397,19 @@
"name": "Freedom",
"era": "Renaissance era",
"effect": "+25% great people rate",
"unique": "+[25]% great person generation in all cities",
"policies": [
{
"name": "Constitution",
"effect": "+2 culture from each wonder",
"uniques": ["[+2 Culture] from every Wonder"]
"row": 1,
"column": 1
},
{
"name": "Universal Suffrage",
"effect": "+1 production per 5 population",
"uniques": ["[+1 Production] per [5] population in all cities"]
"row": 1,
"column": 3
},
@ -419,6 +422,7 @@
{
"name": "Free Speech",
"effect": "+1 culture for every 2 citizens",
"uniques": ["[+1 Culture] per [2] population in all cities"]
"requires": ["Constitution"],
"row": 2,
"column": 1

View file

@ -20,6 +20,7 @@ import com.unciv.models.ruleset.tile.ResourceSupplyList
import com.unciv.models.ruleset.tile.ResourceType
import com.unciv.models.ruleset.unit.BaseUnit
import com.unciv.models.stats.Stats
import com.unciv.models.translations.getPlaceholderParameters
import com.unciv.ui.utils.withoutItem
import java.util.*
import kotlin.collections.HashMap
@ -245,28 +246,26 @@ class CityInfo {
fun getBuildingUniques(): Sequence<String> = cityConstructions.getBuiltBuildings().flatMap { it.uniques.asSequence() }
fun containsBuildingUnique(unique:String) = cityConstructions.getBuiltBuildings().any { it.uniques.contains(unique) }
fun getGreatPersonMap():HashMap<String,Stats>{
val stats = HashMap<String,Stats>()
if(population.specialists.toString()!="")
fun getGreatPersonMap():HashMap<String,Stats> {
val stats = HashMap<String, Stats>()
if (population.specialists.toString() != "")
stats["Specialists"] = population.specialists.times(3f)
val buildingStats = Stats()
for (building in cityConstructions.getBuiltBuildings())
if (building.greatPersonPoints != null)
buildingStats.add(building.greatPersonPoints!!)
if(buildingStats.toString()!="")
if (buildingStats.toString() != "")
stats["Buildings"] = buildingStats
for(entry in stats){
if(civInfo.nation.unique == UniqueAbility.INGENUITY)
for (entry in stats) {
if (civInfo.nation.unique == UniqueAbility.INGENUITY)
entry.value.science *= 1.5f
if (civInfo.hasUnique("Great Merchants are earned 25% faster"))
entry.value.gold *= 1.25f
if (civInfo.hasUnique("+33% great person generation in all cities"))
stats[entry.key] = stats[entry.key]!!.times(1.33f)
if (civInfo.policies.hasEffect("+25% great people rate"))
stats[entry.key] = stats[entry.key]!!.times(1.25f)
for (unique in civInfo.getMatchingUniques("+[]% great person generation in all cities"))
stats[entry.key] = stats[entry.key]!!.times(1 + (unique.getPlaceholderParameters()[0].toFloat() / 100))
}
return stats

View file

@ -270,25 +270,32 @@ class CityStats {
return stats
}
private fun getStatsFromPolicies(adoptedPolicies: PolicyManager): Stats {
private fun getStatsFromUniques(uniques: Sequence<String>):Stats{
val stats = Stats()
if (adoptedPolicies.hasEffect("+3 culture in capital") && cityInfo.isCapital())
stats.culture += 3f
for(effect in adoptedPolicies.policyEffects) {
val placeholderText = effect.getPlaceholderText()
for(unique in uniques) {
val placeholderText = unique.getPlaceholderText()
if ((placeholderText == "[] in capital" && cityInfo.isCapital())
|| placeholderText == "[] in all cities"
|| (placeholderText == "[] in all cities with a garrison" && cityInfo.getCenterTile().militaryUnit != null))
stats.add(Stats.parse(effect.getPlaceholderParameters()[0]))
stats.add(Stats.parse(unique.getPlaceholderParameters()[0]))
if (placeholderText == "[] per [] population in all cities") {
val placeholderParams = unique.getPlaceholderParameters()
val amountOfEffects = (cityInfo.population.population / placeholderParams[1].toInt()).toFloat()
stats.add(Stats.parse(placeholderParams[0]).times(amountOfEffects))
}
}
return stats
}
private fun getStatsFromPolicies(adoptedPolicies: PolicyManager): Stats {
val stats = Stats()
stats.add(getStatsFromUniques(adoptedPolicies.policyEffects.asSequence()))
if (adoptedPolicies.hasEffect("+1 gold and -1 unhappiness for every 2 citizens in capital") && cityInfo.isCapital())
stats.gold += (cityInfo.population.population / 2).toFloat()
if (adoptedPolicies.hasEffect("+1 culture in every city"))
stats.culture += 1f
if (adoptedPolicies.hasEffect("+1 production in every city, +5% production when constructing buildings"))
stats.production += 1f
if (adoptedPolicies.hasEffect("+1 production per 5 population"))
stats.production += (cityInfo.population.population / 5).toFloat()
if (adoptedPolicies.hasEffect("+1 culture for every 2 citizens"))
stats.culture += (cityInfo.population.population / 2).toFloat()
@ -351,9 +358,9 @@ class CityStats {
if(currentConstruction is Building && !currentConstruction.isWonder)
for(unique in cityInfo.civInfo.getMatchingUniques("+[]% Production when constructing [] buildings")){
val placeholderParams = unique.getPlaceholderParameters()
val stat = Stat.valueOf(placeholderParams[0])
val stat = Stat.valueOf(placeholderParams[1])
if(currentConstruction.isStatRelated(stat))
stats.production += placeholderParams[1].toInt()
stats.production += placeholderParams[0].toInt()
}
if (currentConstruction is Building && currentConstruction.name == "Courthouse"
@ -400,6 +407,7 @@ class CityStats {
newBaseStatList["Buildings"] = cityInfo.cityConstructions.getStats()
newBaseStatList["Policies"] = getStatsFromPolicies(civInfo.policies)
newBaseStatList["National ability"] = getStatsFromNationUnique()
newBaseStatList["Wonders"] = getStatsFromUniques(civInfo.cities.asSequence().flatMap { it.getBuildingUniques() })
newBaseStatList["City-States"] = getStatsFromCityStates()
baseStatList = newBaseStatList

View file

@ -152,9 +152,9 @@ class Building : NamedStats(), IConstruction{
if(isStatRelated(Stat.valueOf(placeholderParams[1])))
stats.add(Stats.parse(placeholderParams[0]))
}
if (adoptedPolicies.contains("Constitution") && isWonder)
stats.culture += 2f
else
for(unique in civInfo.getMatchingUniques("[] from every Wonder"))
stats.add(Stats.parse(unique.getPlaceholderParameters()[0]))
if (adoptedPolicies.contains("Police State") && baseBuildingName == "Courthouse")
stats.happiness += 3