Skip to content

Commit 9e658eb

Browse files
committed
modding: "Not shown on world screen" applies to promotions and statuses
1 parent b552344 commit 9e658eb

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

Diff for: core/src/com/unciv/models/ruleset/unique/UniqueType.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ enum class UniqueType(
610610
"The current stockpiled amount can be affected with trigger uniques."),
611611
CityResource("City-level resource", UniqueTarget.Resource, docDescription = "This resource is calculated on a per-city level rather than a per-civ level"),
612612
CannotBeTraded("Cannot be traded", UniqueTarget.Resource),
613-
NotShownOnWorldScreen("Not shown on world screen", UniqueTarget.Resource, flags = UniqueFlag.setOfHiddenToUsers),
613+
NotShownOnWorldScreen("Not shown on world screen", UniqueTarget.Resource, UniqueTarget.Promotion, flags = UniqueFlag.setOfHiddenToUsers),
614614

615615
ResourceWeighting("Generated with weight [amount]", UniqueTarget.Resource, flags = UniqueFlag.setOfHiddenToUsers,
616616
docDescription = "The probability for this resource to be chosen is (this resource weight) / (sum weight of all eligible resources). " +

Diff for: core/src/com/unciv/ui/screens/worldscreen/unit/presenter/UnitPresenter.kt

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.unciv.ui.screens.worldscreen.unit.presenter
33
import com.badlogic.gdx.math.Vector2
44
import com.badlogic.gdx.utils.Align
55
import com.unciv.logic.map.mapunit.MapUnit
6+
import com.unciv.models.ruleset.unique.UniqueType
67
import com.unciv.models.translations.tr
78
import com.unciv.ui.components.extensions.surroundWithCircle
89
import com.unciv.ui.components.extensions.toLabel
@@ -121,10 +122,13 @@ class UnitPresenter(private val unitTable: UnitTable, private val worldScreen: W
121122
unitIconHolder.add(UnitIconGroup(unit, 30f)).pad(5f)
122123

123124
for (promotion in unit.promotions.getPromotions(true))
124-
promotionsTable.add(ImageGetter.getPromotionPortrait(promotion.name, 20f))
125-
.padBottom(2f)
125+
if (!promotion.hasUnique(UniqueType.NotShownOnWorldScreen))
126+
promotionsTable.add(ImageGetter.getPromotionPortrait(promotion.name, 20f))
127+
.padBottom(2f)
126128

127129
for (status in unit.statusMap.values) {
130+
if (status.uniques.any { it.type == UniqueType.NotShownOnWorldScreen }) continue
131+
128132
val group = ImageGetter.getPromotionPortrait(status.name)
129133
val turnsLeft = "${status.turnsLeft}${Fonts.turn}".toLabel(fontSize = 8)
130134
.surroundWithCircle(15f, color = ImageGetter.CHARCOAL)

Diff for: tests/src/com/unciv/uniques/GlobalUniquesTests.kt

+3-9
Original file line numberDiff line numberDiff line change
@@ -581,11 +581,8 @@ class GlobalUniquesTests {
581581
val city = game.addCity(civInfo, game.getTile(Vector2.Zero), true)
582582

583583
city.cityStats.update()
584-
// Because of some weird design choices, -3.6 is correct, though I would expect it to be -6 instead.
585-
// 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.
586-
// I've also written some text about this in CityStats.updateCityHappiness(). ~xlenstra
587584
println(city.cityStats.happinessList)
588-
Assert.assertTrue(abs(city.cityStats.happinessList["Cities"]!! - -3.6f) < epsilon) // Float rounding errors
585+
Assert.assertTrue(abs(city.cityStats.happinessList["Cities"]!! - -6f) < epsilon) // Float rounding errors
589586
}
590587

591588
@Test
@@ -594,10 +591,8 @@ class GlobalUniquesTests {
594591
val city = game.addCity(civInfo, game.getTile(Vector2.Zero), true, initialPopulation = 4)
595592

596593
city.cityStats.update()
597-
// This test suffers from the same problems as `unhappinessFromCitiesPercentageTest()`.
598-
// This should be -2, I believe, as every pop should add -1 happiness and 4 pop with -50% unhappiness = -2 unhappiness.
599594
println(city.cityStats.happinessList)
600-
Assert.assertTrue(abs(city.cityStats.happinessList["Population"]!! - -1.2f) < epsilon)
595+
Assert.assertTrue(abs(city.cityStats.happinessList["Population"]!! - -2f) < epsilon)
601596

602597
val building = game.createBuilding("[-50]% Unhappiness from [Specialists] [in all cities]")
603598
val specialist = game.createSpecialist()
@@ -607,8 +602,7 @@ class GlobalUniquesTests {
607602

608603
city.cityStats.update()
609604
println(city.cityStats.happinessList)
610-
// This test suffers from the same problems as above. It should be -1, I believe.
611-
Assert.assertTrue(abs(city.cityStats.happinessList["Population"]!! - -0.6f) < epsilon)
605+
Assert.assertTrue(abs(city.cityStats.happinessList["Population"]!! - -1f) < epsilon)
612606
}
613607

614608

0 commit comments

Comments
 (0)