mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-16 18:59:15 +07:00
Fix effect of new Beliefs not immediately visible in top bar (#6888)
* Fix effect of new Beliefs not immediately visible in top bar * Fix effect of new Beliefs not immediately visible - reviews
This commit is contained in:
@ -100,6 +100,7 @@ class ReligionManager {
|
||||
for (city in civInfo.cities)
|
||||
city.religion.addPressure(belief.name, 200 * city.population.population)
|
||||
religionState = ReligionState.Pantheon
|
||||
civInfo.updateStatsForNextTurn() // a belief can have an immediate effect on stats
|
||||
}
|
||||
|
||||
// https://www.reddit.com/r/civ/comments/2m82wu/can_anyone_detail_the_finer_points_of_great/
|
||||
@ -216,12 +217,14 @@ class ReligionManager {
|
||||
}
|
||||
|
||||
fun chooseBeliefs(iconName: String?, religionName: String?, beliefs: List<Belief>) {
|
||||
if (religionState == ReligionState.FoundingReligion) {
|
||||
foundReligion(iconName!!, religionName!!, beliefs)
|
||||
return
|
||||
when(religionState) {
|
||||
ReligionState.FoundingReligion ->
|
||||
foundReligion(iconName!!, religionName!!, beliefs)
|
||||
ReligionState.EnhancingReligion ->
|
||||
enhanceReligion(beliefs)
|
||||
else -> return
|
||||
}
|
||||
if (religionState == ReligionState.EnhancingReligion)
|
||||
enhanceReligion(beliefs)
|
||||
civInfo.updateStatsForNextTurn() // a belief can have an immediate effect on stats
|
||||
}
|
||||
|
||||
|
||||
|
@ -52,11 +52,10 @@ class GlobalUniquesTests {
|
||||
fun statsPerSpecialist() {
|
||||
val civInfo = game.addCiv()
|
||||
val tile = game.setTileFeatures(Vector2(0f,0f), Constants.desert)
|
||||
val cityInfo = game.addCity(civInfo, tile, true)
|
||||
val cityInfo = game.addCity(civInfo, tile, true, initialPopulation = 2)
|
||||
val building = game.createBuildingWithUnique("[+3 Gold] from every specialist [in this city]")
|
||||
val specialistName = game.addEmptySpecialist()
|
||||
building.specialistSlots.add(specialistName,2)
|
||||
cityInfo.population.addPopulation(2)
|
||||
building.specialistSlots.add(specialistName, 2)
|
||||
cityInfo.population.specialistAllocations[specialistName] = 2
|
||||
|
||||
cityInfo.cityConstructions.addBuilding(building.name)
|
||||
@ -68,9 +67,8 @@ class GlobalUniquesTests {
|
||||
fun statsPerPopulation() {
|
||||
val civInfo = game.addCiv()
|
||||
val tile = game.setTileFeatures(Vector2(0f,0f), Constants.desert)
|
||||
val cityInfo = game.addCity(civInfo, tile, true)
|
||||
val cityInfo = game.addCity(civInfo, tile, true, initialPopulation = 4)
|
||||
val building = game.createBuildingWithUnique("[+3 Gold] per [2] population [in this city]")
|
||||
cityInfo.population.addPopulation(4)
|
||||
|
||||
cityInfo.cityConstructions.addBuilding(building.name)
|
||||
cityInfo.cityStats.update()
|
||||
@ -81,10 +79,9 @@ class GlobalUniquesTests {
|
||||
fun statsPerXPopulation() {
|
||||
val civInfo = game.addCiv()
|
||||
val tile = game.setTileFeatures(Vector2(0f,0f), Constants.desert)
|
||||
val cityInfo = game.addCity(civInfo, tile, true)
|
||||
val cityInfo = game.addCity(civInfo, tile, true, initialPopulation = 2)
|
||||
val building = game.createBuildingWithUnique("[+3 Gold] in cities with [3] or more population")
|
||||
|
||||
cityInfo.population.addPopulation(2)
|
||||
cityInfo.cityConstructions.addBuilding(building.name)
|
||||
|
||||
cityInfo.cityStats.update()
|
||||
@ -160,12 +157,11 @@ class GlobalUniquesTests {
|
||||
game.makeHexagonalMap(1)
|
||||
val civInfo = game.addCiv()
|
||||
val tile = game.setTileFeatures(Vector2(0f,0f), Constants.desert)
|
||||
val cityInfo = game.addCity(civInfo, tile, true)
|
||||
val cityInfo = game.addCity(civInfo, tile, true, initialPopulation = 2)
|
||||
val specialist = game.addEmptySpecialist()
|
||||
val building = game.createBuildingWithUnique("[+3 Faith] from every [${specialist}]")
|
||||
|
||||
cityInfo.cityConstructions.addBuilding(building.name)
|
||||
cityInfo.population.addPopulation(2)
|
||||
cityInfo.population.specialistAllocations[specialist] = 2
|
||||
|
||||
cityInfo.cityStats.update()
|
||||
@ -218,8 +214,7 @@ class GlobalUniquesTests {
|
||||
religion.founderBeliefs.add(belief.name)
|
||||
val civ2 = game.addCiv()
|
||||
val tile = game.getTile(Vector2(0f,0f))
|
||||
val cityOfCiv2 = game.addCity(civ2, tile)
|
||||
cityOfCiv2.population.setPopulation(1) // Need someone to be converted
|
||||
val cityOfCiv2 = game.addCity(civ2, tile, initialPopulation = 1) // Need someone to be converted
|
||||
cityOfCiv2.religion.addPressure(religion.name, 1000)
|
||||
|
||||
Assert.assertTrue(cityOfCiv2.religion.getMajorityReligionName() == religion.name)
|
||||
@ -229,6 +224,24 @@ class GlobalUniquesTests {
|
||||
Assert.assertTrue(civ1.statsForNextTurn.science == 30f)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun happinessFromGlobalCitiesFollowingReligion() {
|
||||
val civ1 = game.addCiv()
|
||||
val religion = game.addReligion(civ1)
|
||||
val belief = game.addBelief(BeliefType.Founder, "[+42 Happiness] for each global city following this religion")
|
||||
religion.founderBeliefs.add(belief.name)
|
||||
val civ2 = game.addCiv()
|
||||
val tile = game.getTile(Vector2(0f,0f))
|
||||
val cityOfCiv2 = game.addCity(civ2, tile, initialPopulation = 1) // Need someone to be converted
|
||||
cityOfCiv2.religion.addPressure(religion.name, 1000)
|
||||
|
||||
civ1.updateStatsForNextTurn()
|
||||
|
||||
val baseHappiness = civ1.getDifficulty().baseHappiness
|
||||
// Since civ1 has no cities, there are no other happiness sources
|
||||
Assert.assertTrue(civ1.happinessForNextTurn == baseHappiness + 42)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun statsFromGlobalFollowers() {
|
||||
val civ1 = game.addCiv()
|
||||
@ -237,8 +250,7 @@ class GlobalUniquesTests {
|
||||
religion.founderBeliefs.add(belief.name)
|
||||
val civ2 = game.addCiv()
|
||||
val tile = game.getTile(Vector2(0f,0f))
|
||||
val cityOfCiv2 = game.addCity(civ2, tile)
|
||||
cityOfCiv2.population.setPopulation(9) // Need people to be converted
|
||||
val cityOfCiv2 = game.addCity(civ2, tile, initialPopulation = 9) // Need people to be converted
|
||||
cityOfCiv2.religion.addPressure(religion.name, 1000000000) // To completely overwhelm the default atheism in a city
|
||||
|
||||
civ1.updateStatsForNextTurn()
|
||||
|
@ -111,9 +111,15 @@ class TestGame {
|
||||
return civInfo
|
||||
}
|
||||
|
||||
fun addCity(civInfo: CivilizationInfo, tile: TileInfo, replacePalace: Boolean = false): CityInfo {
|
||||
fun addCity(
|
||||
civInfo: CivilizationInfo,
|
||||
tile: TileInfo,
|
||||
replacePalace: Boolean = false,
|
||||
initialPopulation: Int = 0
|
||||
): CityInfo {
|
||||
val cityInfo = CityInfo(civInfo, tile.position)
|
||||
cityInfo.population.addPopulation(-1) // Remove population
|
||||
if (initialPopulation != 1)
|
||||
cityInfo.population.addPopulation(initialPopulation - 1) // With defaults this will remove population
|
||||
|
||||
if (replacePalace && civInfo.cities.size == 1) {
|
||||
// Add a capital indicator without any other stats
|
||||
|
Reference in New Issue
Block a user