mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-13 08:14:29 +07:00
Happiness change from bought buildings can reapply citizen focus (#9395)
* Happiness change from bought buildings can reapply citizen focus * Fix compilation error
This commit is contained in:
parent
1de866c7ed
commit
d31a2d83ba
@ -314,8 +314,7 @@ class ConstructionAutomation(val cityConstructions: CityConstructions){
|
||||
|
||||
private fun addHappinessBuildingChoice() {
|
||||
val happinessBuilding = nonWonders
|
||||
.filter { (it.isStatRelated(Stat.Happiness)
|
||||
|| it.hasUnique(UniqueType.RemoveAnnexUnhappiness))
|
||||
.filter { it.isStatRelated(Stat.Happiness)
|
||||
&& Automation.allowAutomatedConstruction(civInfo, cityInfo, it) }
|
||||
.filterBuildable()
|
||||
.minByOrNull { it.cost }
|
||||
|
@ -689,6 +689,13 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction {
|
||||
if (isStatRelated(Stat.Science) && civInfo.hasUnique(UniqueType.TechBoostWhenScientificBuildingsBuiltInCapital))
|
||||
civInfo.tech.addScience(civInfo.tech.scienceOfLast8Turns.sum() / 8)
|
||||
|
||||
// Happiness change _may_ invalidate best worked tiles (#9238), but if the building
|
||||
// isn't bought then reassignPopulation will run later in startTurn anyway
|
||||
if (boughtWith != null && isStatRelated(Stat.Happiness)) {
|
||||
cityConstructions.city.reassignPopulation()
|
||||
cityConstructions.city.updateCitizens = false
|
||||
}
|
||||
|
||||
cityConstructions.city.cityStats.update() // new building, new stats
|
||||
civInfo.cache.updateCivResources() // this building/unit could be a resource-requiring one
|
||||
civInfo.cache.updateCitiesConnectedToCapital(false) // could be a connecting building, like a harbor
|
||||
@ -721,6 +728,7 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction {
|
||||
if (getMatchingUniques(UniqueType.Stats).any { it.stats[stat] > 0 }) return true
|
||||
if (getMatchingUniques(UniqueType.StatsFromTiles).any { it.stats[stat] > 0 }) return true
|
||||
if (getMatchingUniques(UniqueType.StatsPerPopulation).any { it.stats[stat] > 0 }) return true
|
||||
if (stat == Stat.Happiness && hasUnique(UniqueType.RemoveAnnexUnhappiness)) return true
|
||||
return false
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user