modding: "Not shown on world screen" applies to promotions and statuses

This commit is contained in:
yairm210 2025-03-10 09:57:13 +02:00
parent b552344547
commit 9e658eb012
3 changed files with 10 additions and 12 deletions

View File

@ -610,7 +610,7 @@ enum class UniqueType(
"The current stockpiled amount can be affected with trigger uniques."), "The current stockpiled amount can be affected with trigger uniques."),
CityResource("City-level resource", UniqueTarget.Resource, docDescription = "This resource is calculated on a per-city level rather than a per-civ level"), CityResource("City-level resource", UniqueTarget.Resource, docDescription = "This resource is calculated on a per-city level rather than a per-civ level"),
CannotBeTraded("Cannot be traded", UniqueTarget.Resource), CannotBeTraded("Cannot be traded", UniqueTarget.Resource),
NotShownOnWorldScreen("Not shown on world screen", UniqueTarget.Resource, flags = UniqueFlag.setOfHiddenToUsers), NotShownOnWorldScreen("Not shown on world screen", UniqueTarget.Resource, UniqueTarget.Promotion, flags = UniqueFlag.setOfHiddenToUsers),
ResourceWeighting("Generated with weight [amount]", UniqueTarget.Resource, flags = UniqueFlag.setOfHiddenToUsers, ResourceWeighting("Generated with weight [amount]", UniqueTarget.Resource, flags = UniqueFlag.setOfHiddenToUsers,
docDescription = "The probability for this resource to be chosen is (this resource weight) / (sum weight of all eligible resources). " + docDescription = "The probability for this resource to be chosen is (this resource weight) / (sum weight of all eligible resources). " +

View File

@ -3,6 +3,7 @@ package com.unciv.ui.screens.worldscreen.unit.presenter
import com.badlogic.gdx.math.Vector2 import com.badlogic.gdx.math.Vector2
import com.badlogic.gdx.utils.Align import com.badlogic.gdx.utils.Align
import com.unciv.logic.map.mapunit.MapUnit import com.unciv.logic.map.mapunit.MapUnit
import com.unciv.models.ruleset.unique.UniqueType
import com.unciv.models.translations.tr import com.unciv.models.translations.tr
import com.unciv.ui.components.extensions.surroundWithCircle import com.unciv.ui.components.extensions.surroundWithCircle
import com.unciv.ui.components.extensions.toLabel import com.unciv.ui.components.extensions.toLabel
@ -121,10 +122,13 @@ class UnitPresenter(private val unitTable: UnitTable, private val worldScreen: W
unitIconHolder.add(UnitIconGroup(unit, 30f)).pad(5f) unitIconHolder.add(UnitIconGroup(unit, 30f)).pad(5f)
for (promotion in unit.promotions.getPromotions(true)) for (promotion in unit.promotions.getPromotions(true))
if (!promotion.hasUnique(UniqueType.NotShownOnWorldScreen))
promotionsTable.add(ImageGetter.getPromotionPortrait(promotion.name, 20f)) promotionsTable.add(ImageGetter.getPromotionPortrait(promotion.name, 20f))
.padBottom(2f) .padBottom(2f)
for (status in unit.statusMap.values) { for (status in unit.statusMap.values) {
if (status.uniques.any { it.type == UniqueType.NotShownOnWorldScreen }) continue
val group = ImageGetter.getPromotionPortrait(status.name) val group = ImageGetter.getPromotionPortrait(status.name)
val turnsLeft = "${status.turnsLeft}${Fonts.turn}".toLabel(fontSize = 8) val turnsLeft = "${status.turnsLeft}${Fonts.turn}".toLabel(fontSize = 8)
.surroundWithCircle(15f, color = ImageGetter.CHARCOAL) .surroundWithCircle(15f, color = ImageGetter.CHARCOAL)

View File

@ -581,11 +581,8 @@ class GlobalUniquesTests {
val city = game.addCity(civInfo, game.getTile(Vector2.Zero), true) val city = game.addCity(civInfo, game.getTile(Vector2.Zero), true)
city.cityStats.update() city.cityStats.update()
// Because of some weird design choices, -3.6 is correct, though I would expect it to be -6 instead.
// As I'm not certain enough in my feeling that it should be -6, I'm changing the test to fit the code instead of the other way around.
// I've also written some text about this in CityStats.updateCityHappiness(). ~xlenstra
println(city.cityStats.happinessList) println(city.cityStats.happinessList)
Assert.assertTrue(abs(city.cityStats.happinessList["Cities"]!! - -3.6f) < epsilon) // Float rounding errors Assert.assertTrue(abs(city.cityStats.happinessList["Cities"]!! - -6f) < epsilon) // Float rounding errors
} }
@Test @Test
@ -594,10 +591,8 @@ class GlobalUniquesTests {
val city = game.addCity(civInfo, game.getTile(Vector2.Zero), true, initialPopulation = 4) val city = game.addCity(civInfo, game.getTile(Vector2.Zero), true, initialPopulation = 4)
city.cityStats.update() city.cityStats.update()
// This test suffers from the same problems as `unhappinessFromCitiesPercentageTest()`.
// This should be -2, I believe, as every pop should add -1 happiness and 4 pop with -50% unhappiness = -2 unhappiness.
println(city.cityStats.happinessList) println(city.cityStats.happinessList)
Assert.assertTrue(abs(city.cityStats.happinessList["Population"]!! - -1.2f) < epsilon) Assert.assertTrue(abs(city.cityStats.happinessList["Population"]!! - -2f) < epsilon)
val building = game.createBuilding("[-50]% Unhappiness from [Specialists] [in all cities]") val building = game.createBuilding("[-50]% Unhappiness from [Specialists] [in all cities]")
val specialist = game.createSpecialist() val specialist = game.createSpecialist()
@ -607,8 +602,7 @@ class GlobalUniquesTests {
city.cityStats.update() city.cityStats.update()
println(city.cityStats.happinessList) println(city.cityStats.happinessList)
// This test suffers from the same problems as above. It should be -1, I believe. Assert.assertTrue(abs(city.cityStats.happinessList["Population"]!! - -1f) < epsilon)
Assert.assertTrue(abs(city.cityStats.happinessList["Population"]!! - -0.6f) < epsilon)
} }