Add Adopt [policy/belief] Unique (#13915)

* Initial Adopt [belief]

* Add tests

* clean up the code

* clean func
This commit is contained in:
Rob Loach 2025-09-13 15:29:15 -04:00 committed by GitHub
parent 65885cdc6f
commit 76e9935d83
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
49 changed files with 94 additions and 63 deletions

View File

@ -4239,7 +4239,7 @@ Free Great Person =
# Requires translation!
Discover [tech] =
# Requires translation!
Adopt [policy] =
Adopt [policy/belief] =
# Requires translation!
Remove [policy] =
# Requires translation!

View File

@ -3743,7 +3743,7 @@ Free Great Person =
# Requires translation!
Discover [tech] =
# Requires translation!
Adopt [policy] =
Adopt [policy/belief] =
# Requires translation!
Remove [policy] =
# Requires translation!

View File

@ -3904,7 +3904,7 @@ Free Great Person =
# Requires translation!
Discover [tech] =
# Requires translation!
Adopt [policy] =
Adopt [policy/belief] =
# Requires translation!
Remove [policy] =
# Requires translation!

View File

@ -4473,7 +4473,7 @@ Free Great Person =
# Requires translation!
Discover [tech] =
# Requires translation!
Adopt [policy] =
Adopt [policy/belief] =
# Requires translation!
Remove [policy] =
# Requires translation!

View File

@ -2493,7 +2493,7 @@ Free Great Person = Grande Personlidade Gratuita
[amount] population [cityFilter] = [amount] população [cityFilter]
[amount] population in a random city = [amount] de população em uma cidade aleatória
Discover [tech] = Descobre [tech]
Adopt [policy] = Adota [policy]
Adopt [policy/belief] = Adota [policy/belief]
Remove [policy] = Remover [policy]
Remove [policy] and refund [amount]% of its cost = Remover [policy] e reembolsar [amount]% do seu custo
Free Technology = Tecnologia Grátis

View File

@ -3549,7 +3549,7 @@ Free Great Person =
# Requires translation!
Discover [tech] =
# Requires translation!
Adopt [policy] =
Adopt [policy/belief] =
# Requires translation!
Remove [policy] =
# Requires translation!

View File

@ -2515,7 +2515,7 @@ Free Great Person = Gran personatge de franc
[amount] population [cityFilter] = [amount] de població [cityFilter]
[amount] population in a random city = [amount] de població en una ciutat aleatòria
Discover [tech] = Descobreix [tech]
Adopt [policy] = Adopta [policy]
Adopt [policy/belief] = Adopta [policy/belief]
Remove [policy] = Trau [policy]
Remove [policy] and refund [amount]% of its cost = Trau [policy] i retorna un [amount] % del seu cost.
Free Technology = Tecnologia de franc

View File

@ -2501,7 +2501,7 @@ Free Great Person = Besplatni Velikan
[amount] population [cityFilter] = [amount] stanovništva [cityFilter]
[amount] population in a random city = [amount] stanovnika u nasumičnom gradu
Discover [tech] = Otkrijte [tech]
Adopt [policy] = Usvoji [policy]
Adopt [policy/belief] = Usvoji [policy/belief]
Remove [policy] = Ukloni [policy]
Remove [policy] and refund [amount]% of its cost = Ukloni [policy] i povrati [amount]% njezine cijene
Free Technology = Besplatna Tehnologija

View File

@ -2827,7 +2827,7 @@ Free Great Person = Velká osobnost zdarma
# Requires translation!
Discover [tech] =
# Requires translation!
Adopt [policy] =
Adopt [policy/belief] =
# Requires translation!
Remove [policy] =
# Requires translation!

View File

@ -2527,7 +2527,7 @@ Free Great Person = Gratis Groot Persoon
[amount] population [cityFilter] = [amount] bevolking [cityFilter]
[amount] population in a random city = [amount] bevolking in een willekeurige stad
Discover [tech] = Ontdek [tech]
Adopt [policy] = Neem [policy] aan
Adopt [policy/belief] = Neem [policy/belief] aan
Remove [policy] = Verwijder [policy]
Remove [policy] and refund [amount]% of its cost = Verwijder [policy] en krijg [amount]% of de kosten terug
Free Technology = Gratis Technologie

View File

@ -4656,7 +4656,7 @@ Free Great Person =
# Requires translation!
Discover [tech] =
# Requires translation!
Adopt [policy] =
Adopt [policy/belief] =
# Requires translation!
Remove [policy] =
# Requires translation!

View File

@ -2681,7 +2681,7 @@ Free Great Person = Libreng Dakilang Tao
[amount] population [cityFilter] = [amount] populasyon [cityFilter]
[amount] population in a random city = [amount] population sa isang di-matukoy na lungsod
Discover [tech] = Tumuklas ng [tech]
Adopt [policy] = Magtatag ng [policy]
Adopt [policy/belief] = Magtatag ng [policy/belief]
# Requires translation!
Remove [policy] =
# Requires translation!

View File

@ -3707,7 +3707,7 @@ Free Great Person = Ilmainen Merkkihenkilö
# Requires translation!
Discover [tech] =
# Requires translation!
Adopt [policy] =
Adopt [policy/belief] =
# Requires translation!
Remove [policy] =
# Requires translation!

View File

@ -2492,7 +2492,7 @@ Free Great Person = Personnage Illustre gratuit
[amount] population [cityFilter] = [amount] Population [cityFilter]
[amount] population in a random city = [amount] Population dans une ville aléatoire
Discover [tech] = Découvrir [tech]
Adopt [policy] = Adopter [policy]
Adopt [policy/belief] = Adopter [policy/belief]
Remove [policy] = Abandonner [policy]
Remove [policy] and refund [amount]% of its cost = Abandonner [policy] et récupérer [amount]% de son coût
Free Technology = Technologie gratuite

View File

@ -2499,7 +2499,7 @@ Free Great Person = Gran Personaxe gratis
[amount] population [cityFilter] = [amount] poboación [cityFilter]
[amount] population in a random city = [amount] poboación nunha cidade aleatoria
Discover [tech] = Descobre [tech]
Adopt [policy] = Adopta [policy]
Adopt [policy/belief] = Adopta [policy/belief]
Remove [policy] = Eliminar [policy]
Remove [policy] and refund [amount]% of its cost = Elimina [policy] e reembolsa [amount]% do seu custo
Free Technology = Tecnoloxía gratis

View File

@ -2498,7 +2498,7 @@ Free Great Person = Kostenlose Große Persönlichkeit
[amount] population [cityFilter] = [amount] Bevölkerung [cityFilter]
[amount] population in a random city = [amount] Bevölkerung in einer zufälligen Stadt
Discover [tech] = Erforsche [tech]
Adopt [policy] = Verabschiede [policy]
Adopt [policy/belief] = Verabschiede [policy/belief]
Remove [policy] = Entferne [policy]
Remove [policy] and refund [amount]% of its cost = [policy] entfernen und [amount]% ihrer Kosten zurückerhalten
Free Technology = Kostenlose Technologie

View File

@ -4237,7 +4237,7 @@ Free Great Person =
# Requires translation!
Discover [tech] =
# Requires translation!
Adopt [policy] =
Adopt [policy/belief] =
# Requires translation!
Remove [policy] =
# Requires translation!

View File

@ -2646,7 +2646,7 @@ Free Great Person = Ajándék Híres ember
[amount] population [cityFilter] = [amount] lakos [cityFilter]
[amount] population in a random city = [amount] lakos valamelyik városba
Discover [tech] = [tech] felfedezése
Adopt [policy] = [policy] törvénybe iktatása
Adopt [policy/belief] = [policy/belief] törvénybe iktatása
Remove [policy] = [policy] törlése
Remove [policy] and refund [amount]% of its cost = [policy] törlése és [amount]% visszatérítése
Free Technology = Ajándék technológia

View File

@ -2492,7 +2492,7 @@ Free Great Person = Orang Hebat Gratis
[amount] population [cityFilter] = [amount] populasi [cityFilter]
[amount] population in a random city = [amount] populasi di kota acak
Discover [tech] = Menemukan [tech]
Adopt [policy] = Menerapkan [policy]
Adopt [policy/belief] = Menerapkan [policy/belief]
Remove [policy] = Cabut [policy]
Remove [policy] and refund [amount]% of its cost = Cabut [policy] dan kembalikan [amount]% dananya
Free Technology = Teknologi Gratis

View File

@ -2498,7 +2498,7 @@ Free Great Person = Ottieni un Grande Personaggio gratuito
[amount] population [cityFilter] = [amount] abitanti [cityFilter]
[amount] population in a random city = [amount] abitanti in una città casuale
Discover [tech] = Scopri [tech]
Adopt [policy] = Adotta [policy]
Adopt [policy/belief] = Adotta [policy/belief]
Remove [policy] = Rimuovi [policy]
Remove [policy] and refund [amount]% of its cost = Rimuovi [policy] e rimborsa il [amount]% del suo costo
Free Technology = Dona una tecnologia gratuita

View File

@ -2509,7 +2509,7 @@ Free Great Person = 無償の偉人
[amount] population [cityFilter] = [cityFilter]人口[amount]
[amount] population in a random city = ランダムな都市の人口[amount]
Discover [tech] = [tech]を発見
Adopt [policy] = [policy]を採用
Adopt [policy/belief] = [policy/belief]を採用
Remove [policy] = [policy]を削除
Remove [policy] and refund [amount]% of its cost = [policy]を削除してそのコストの[amount]%を返却する
Free Technology = テクロジーを無償で1つ獲得

View File

@ -2527,7 +2527,7 @@ Free Great Person = 원하는 위인 1명이 무료로 출현
[amount] population [cityFilter] = [cityFilter]에 인구 [amount]
[amount] population in a random city = 임의의 도시에 인구 [amount] 추가
Discover [tech] = [tech] 연구
Adopt [policy] = [policy] 채택
Adopt [policy/belief] = [policy/belief] 채택
Remove [policy] = [policy] 제거
Remove [policy] and refund [amount]% of its cost = [policy] 제거 및 비용의 [amount]% 환불
Free Technology = 무료 기술 획득

View File

@ -2696,7 +2696,7 @@ Free Great Person = Persona Magna gratuita
[amount] population [cityFilter] = [amount] multitudo [cityFilter]
[amount] population in a random city = [amount] multitudo in urbem quæ decernatur passive (i.e. de cæcitate)
Discover [tech] = Invenis [tech](m/s)
Adopt [policy] = Asciscas [policy](m/s/um/os)
Adopt [policy/belief] = Asciscas [policy/belief](m/s/um/os)
Remove [policy] = Expellas [policy](m/s/um/os)
Remove [policy] and refund [amount]% of its cost = Expellas [policy](m/s/um/os) et recipias [amount]% quam sumptum ejus
Free Technology = Technologia gratuita

View File

@ -3037,7 +3037,7 @@ Free Great Person = Didis Žmogus dovanai
# Requires translation!
Discover [tech] =
# Requires translation!
Adopt [policy] =
Adopt [policy/belief] =
# Requires translation!
Remove [policy] =
# Requires translation!

View File

@ -3518,7 +3518,7 @@ Free Great Person =
# Requires translation!
[amount] population in a random city =
Discover [tech] = Menemui [tech]
Adopt [policy] = Amalkan [policy]
Adopt [policy/belief] = Amalkan [policy/belief]
# Requires translation!
Remove [policy] =
# Requires translation!

View File

@ -2864,7 +2864,7 @@ Free Great Person = Kostnadsfri stor person
[amount] population [cityFilter] = [amount] folkemengd [cityFilter]
[amount] population in a random city = [amount] folketal i ein tilfeldig by
Discover [tech] = Oppdaga [tech]
Adopt [policy] = Vedtak [policy]
Adopt [policy/belief] = Vedtak [policy/belief]
Remove [policy] = Fjerna [policy]
# Requires translation!
Remove [policy] and refund [amount]% of its cost =

View File

@ -4066,7 +4066,7 @@ Free Great Person =
# Requires translation!
Discover [tech] =
# Requires translation!
Adopt [policy] =
Adopt [policy/belief] =
# Requires translation!
Remove [policy] =
# Requires translation!

View File

@ -3524,7 +3524,7 @@ Free Great Person =
[amount] population in a random city =
Discover [tech] = Kashf e [tech]
# Requires translation!
Adopt [policy] =
Adopt [policy/belief] =
Remove [policy] = Hazf e [policy]
# Requires translation!
Remove [policy] and refund [amount]% of its cost =

View File

@ -2534,7 +2534,7 @@ Free Great Person = Darmowy Wielki Człowiek
[amount] population [cityFilter] = [amount] do populacji [cityFilter]
[amount] population in a random city = [amount] populacji w losowym mieście
Discover [tech] = Odkrywa [tech]
Adopt [policy] = Przyjmuje [policy]
Adopt [policy/belief] = Przyjmuje [policy/belief]
Remove [policy] = Zrezygnuj z ustroju [policy]
Remove [policy] and refund [amount]% of its cost = Zrezygnuj z ustroju społecznego [policy] i otrzymaj z powrotem [amount]% jego kosztu
Free Technology = Otrzymasz 1 darmową technologię

View File

@ -2492,7 +2492,7 @@ Free Great Person = Pessoa Experiente grátis
[amount] population [cityFilter] = [amount] população [cityFilter]
[amount] population in a random city = [amount] população numa cidade aleatória
Discover [tech] = Descobre [tech]
Adopt [policy] = Adotar [policy]
Adopt [policy/belief] = Adotar [policy/belief]
Remove [policy] = Retirar [policy]
Remove [policy] and refund [amount]% of its cost = Retirar [policy] e reembolsar [amount]% do seu custo
Free Technology = Tecnologia grátis

View File

@ -2982,7 +2982,7 @@ Free Great Person = Persoană Extraordinară gratuit
# Requires translation!
Discover [tech] =
# Requires translation!
Adopt [policy] =
Adopt [policy/belief] =
# Requires translation!
Remove [policy] =
# Requires translation!

View File

@ -2505,7 +2505,7 @@ Free Great Person = Бесплатный Великий человек
[amount] population [cityFilter] = [amount] к населению [cityFilter]
[amount] population in a random city = [amount] населения в случайном городе
Discover [tech] = Открыть [tech]
Adopt [policy] = Принять [policy]
Adopt [policy/belief] = Принять [policy/belief]
Remove [policy] = Удалить [policy]
Remove [policy] and refund [amount]% of its cost = Удалите [policy] и верните [amount]% от его стоимости.
Free Technology = Бесплатная технология

View File

@ -3990,7 +3990,7 @@ Free Great Person = Промінент задарь
[amount] population [cityFilter] =
[amount] population in a random city = [amount] населення у випадковому місті
Discover [tech] = Изучити [tech]
Adopt [policy] = Узяти [policy]
Adopt [policy/belief] = Узяти [policy/belief]
# Requires translation!
Remove [policy] =
# Requires translation!

View File

@ -2499,7 +2499,7 @@ Free Great Person = 免费的伟人
[amount] population [cityFilter] = [cityFilter][amount]人口
[amount] population in a random city = 在一个随机城市中增加[amount]人口
Discover [tech] = 发现[tech]
Adopt [policy] = 立刻推行[policy]
Adopt [policy/belief] = 立刻推行[policy/belief]
Remove [policy] = 取消推行[policy]
Remove [policy] and refund [amount]% of its cost = 取消推行[policy]并返还[amount]%的文化花费
Free Technology = 获得1项免费科技

View File

@ -2496,7 +2496,7 @@ Free Great Person = Gran Personaje gratis
[amount] population [cityFilter] = [amount] población [cityFilter]
[amount] population in a random city = [amount] población en una ciudad aleatoria
Discover [tech] = Descubre [tech]
Adopt [policy] = Adopta [policy]
Adopt [policy/belief] = Adopta [policy/belief]
Remove [policy] = Remover [policy]
Remove [policy] and refund [amount]% of its cost = Deshacer [policy] y reembolsar [amount]% de su costo
Free Technology = Tecnología gratis

View File

@ -3045,7 +3045,7 @@ Free Great Person = Gratis Stor Person
# Requires translation!
Discover [tech] =
# Requires translation!
Adopt [policy] =
Adopt [policy/belief] =
# Requires translation!
Remove [policy] =
# Requires translation!

View File

@ -4172,7 +4172,7 @@ Free Great Person =
# Requires translation!
Discover [tech] =
# Requires translation!
Adopt [policy] =
Adopt [policy/belief] =
# Requires translation!
Remove [policy] =
# Requires translation!

View File

@ -2527,7 +2527,7 @@ Free Great Person = 免費的偉人
[amount] population [cityFilter] = [cityFilter][amount]人口
[amount] population in a random city = 於一個隨機的城市[amount]人口
Discover [tech] = 發現[tech]
Adopt [policy] = 採行[policy]
Adopt [policy/belief] = 採行[policy/belief]
Remove [policy] = 移除[policy]
Remove [policy] and refund [amount]% of its cost = 移除[policy]並退還其成本的[amount]%
Free Technology = 免費獲得1項科技

View File

@ -2522,7 +2522,7 @@ Free Great Person = Ücretsiz Harika Kişi
[amount] population [cityFilter] = [cityFilter] [amount] nüfus
[amount] population in a random city = Rastgele bir şehirdeki [amount] nüfus
Discover [tech] = [tech] teknolojisini keşfedin
Adopt [policy] = [policy] politikasını benimseyin
Adopt [policy/belief] = [policy/belief] politikasını benimseyin
Remove [policy] = [policy] politikasını kaldırın
Remove [policy] and refund [amount]% of its cost = [policy] politikasını kaldırın ve harcadığınız ücretin %[amount]'sini geri alın
Free Technology = Ücretsiz Teknoloji

View File

@ -2498,7 +2498,7 @@ Free Great Person = Безкоштовно зʼявляється Видатна
[amount] population [cityFilter] = [amount] населення [cityFilter]
[amount] population in a random city = [amount] населення у випадковому місті
Discover [tech] = Дослідити Технологію [tech]
Adopt [policy] = Прийняти Політику [policy]
Adopt [policy/belief] = Прийняти Політику [policy/belief]
Remove [policy] = Видалити [policy]
Remove [policy] and refund [amount]% of its cost = Видалити [policy] і повернути [amount]% від її вартості
Free Technology = Надає безкоштовну технологію

View File

@ -2492,7 +2492,7 @@ Free Great Person = Người Vĩ đại tự do
[amount] population [cityFilter] = [amount] dân số [cityFilter]
[amount] population in a random city = [amount] dân số trong một thành phố ngẫu nhiên
Discover [tech] = Khám phá [tech]
Adopt [policy] = Áp dụng [policy]
Adopt [policy/belief] = Áp dụng [policy/belief]
Remove [policy] = Loại bỏ [policy]
Remove [policy] and refund [amount]% of its cost = Loại bỏ [policy] và đền bù [amount]% chi phí của nó
Free Technology = Công nghệ miễn phí

View File

@ -4119,7 +4119,7 @@ Free Great Person =
# Requires translation!
Discover [tech] =
# Requires translation!
Adopt [policy] =
Adopt [policy/belief] =
# Requires translation!
Remove [policy] =
# Requires translation!

View File

@ -1138,6 +1138,7 @@ Gained [stats] =
You may choose a free Policy =
You may choose [amount] free Policies =
You gain the [policy] Policy =
You gain the [belief] Belief =
You enter a Golden Age =
You have gained [amount] [resourceName] =
You have lost [amount] [resourceName] =

View File

@ -70,6 +70,8 @@ class Religion() : INamed, IsPartOfGameInfoSerialization {
updateUniqueMaps()
}
fun addBelief(belief: Belief) = addBeliefs(listOf(belief))
@Readonly
fun getIconName() =
if (isPantheon()) "Pantheon"

View File

@ -48,7 +48,7 @@ open class UnitAction(
UniqueType.OneTimeEnterGoldenAge, UniqueType.OneTimeEnterGoldenAgeTurns -> ImageGetter.getUnitActionPortrait("StartGoldenAge", size)
UniqueType.GainFreeBuildings, UniqueType.RemoveBuilding, UniqueType.OneTimeSellBuilding, UniqueType.OneTimeFreeUnit, UniqueType.FreeSpecificBuildings -> ImageGetter.getConstructionPortrait(associatedUnique.params[0], size)
UniqueType.OneTimeAmountFreeUnits -> ImageGetter.getConstructionPortrait(associatedUnique.params[1], size)
UniqueType.OneTimeFreePolicy, UniqueType.OneTimeAmountFreePolicies, UniqueType.OneTimeAdoptPolicy, UniqueType.OneTimeRemovePolicy, UniqueType.OneTimeRemovePolicyRefund -> ImageGetter.getUnitActionPortrait("HurryPolicy", size)
UniqueType.OneTimeFreePolicy, UniqueType.OneTimeAmountFreePolicies, UniqueType.OneTimeAdoptPolicyOrBelief, UniqueType.OneTimeRemovePolicy, UniqueType.OneTimeRemovePolicyRefund -> ImageGetter.getUnitActionPortrait("HurryPolicy", size)
UniqueType.OneTimeRevealEntireMap, UniqueType.OneTimeRevealSpecificMapTiles, UniqueType.OneTimeRevealCrudeMap -> ImageGetter.getUnitActionPortrait("Explore", size)
UniqueType.OneTimeConsumeResources, UniqueType.OneTimeProvideResources, UniqueType.OneTimeGainResource -> ImageGetter.getResourcePortrait(associatedUnique.params[1], size)
UniqueType.OneTimeChangeTerrain -> ImageGetter.getUnitActionPortrait("Transform", size)

View File

@ -41,6 +41,7 @@ import com.unciv.utils.addToMapOfSets
import com.unciv.utils.randomWeighted
import kotlin.math.roundToInt
import kotlin.random.Random
import yairm210.purity.annotations.Readonly
// Buildings, techs, policies, ancient ruins and promotions can have 'triggered' effects
object UniqueTriggerActivation {
@ -96,7 +97,7 @@ object UniqueTriggerActivation {
val relevantCity by lazy {
city?: tile?.getCity()
}
fun getApplicableCities(cityFilter: String) =
@Readonly fun getApplicableCities(cityFilter: String) =
if (cityFilter == "in this city") sequenceOf(relevantCity).filterNotNull()
else civInfo.cities.asSequence().filter { it.matchesFilter(cityFilter) }
@ -321,22 +322,27 @@ object UniqueTriggerActivation {
true
}
}
UniqueType.OneTimeAdoptPolicy -> {
val policyName = unique.params[0]
if (civInfo.policies.isAdopted(policyName)) return null
val policy = civInfo.gameInfo.ruleset.policies[policyName] ?: return null
return {
civInfo.policies.freePolicies++
civInfo.policies.adopt(policy)
val notificationText = getNotificationText(
notification, triggerNotificationText,
"You gain the [$policyName] Policy"
)
if (notificationText != null)
civInfo.addNotification(notificationText, PolicyAction(policyName), NotificationCategory.General, NotificationIcon.Culture)
true
UniqueType.OneTimeAdoptPolicyOrBelief -> {
val name = unique.params[0]
val policy = civInfo.gameInfo.ruleset.policies[name]
val belief = civInfo.gameInfo.ruleset.beliefs[name]
when {
policy != null && !civInfo.policies.isAdopted(name) -> return {
civInfo.policies.freePolicies++
civInfo.policies.adopt(policy)
getNotificationText(notification, triggerNotificationText, "You gain the [$name] Policy")?.let {
civInfo.addNotification(it, PolicyAction(name), NotificationCategory.General, NotificationIcon.Culture)
}
true
}
belief != null && civInfo.religionManager.religion?.hasBelief(name) == false -> return {
civInfo.religionManager.religion?.addBelief(belief)
getNotificationText(notification, triggerNotificationText, "You gain the [$name] Belief")?.let {
civInfo.addNotification(it, NotificationCategory.Religion, NotificationIcon.Faith)
}
true
}
else -> return null
}
}
UniqueType.OneTimeRemovePolicy -> {
@ -1158,7 +1164,7 @@ object UniqueTriggerActivation {
if (tilesToTakeOver.none()) return null
/** Lower is better */
fun cityPriority(city: City) = city.getCenterTile().aerialDistanceTo(tile) + (if (city.isBeingRazed) 5 else 0)
@Readonly fun cityPriority(city: City) = city.getCenterTile().aerialDistanceTo(tile) + (if (city.isBeingRazed) 5 else 0)
val citiesWithAdjacentTiles = tilesToTakeOver.asSequence()
.flatMap { it.neighbors + it }
@ -1213,6 +1219,7 @@ object UniqueTriggerActivation {
}
}
@Readonly
private fun getNotificationText(notification: String?, triggerNotificationText: String?, effectNotificationText: String): String? {
return if (!notification.isNullOrEmpty()) notification
else if (triggerNotificationText != null)

View File

@ -827,7 +827,7 @@ enum class UniqueType(
OneTimeGainPopulation("[amount] population [cityFilter]", UniqueTarget.Triggerable), // used in CN tower
OneTimeGainPopulationRandomCity("[amount] population in a random city", UniqueTarget.Triggerable),
OneTimeDiscoverTech("Discover [tech]", UniqueTarget.Triggerable),
OneTimeAdoptPolicy("Adopt [policy]", UniqueTarget.Triggerable),
OneTimeAdoptPolicyOrBelief("Adopt [policy/belief]", UniqueTarget.Triggerable),
OneTimeRemovePolicy("Remove [policy]", UniqueTarget.Triggerable),
OneTimeRemovePolicyRefund("Remove [policy] and refund [amount]% of its cost", UniqueTarget.Triggerable),
OneTimeFreeTech("Free Technology", UniqueTarget.Triggerable), // used in Buildings

View File

@ -69,7 +69,7 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
Applicable to: Triggerable
??? example "Adopt [policy]"
??? example "Adopt [policy/belief]"
Example: "Adopt [Oligarchy]"
Applicable to: Triggerable

View File

@ -228,6 +228,27 @@ class GlobalUniquesTests {
Assert.assertTrue(civInfo.stats.getStatMapForNextTurn()["Policies"]!!.science == 30f)
}
@Test
fun uniqueTypeOneTimeAdoptPolicyOrBelief() {
val civ = game.addCiv()
val tile = game.getTile(Vector2.Zero)
val city = game.addCity(civ, tile, true)
// Policy
Assert.assertFalse(civ.policies.isAdopted("Legalism"))
city.cityConstructions.addBuilding(game.createBuilding("Adopt [Legalism]"))
Assert.assertTrue(civ.policies.isAdopted("Legalism"))
// Belief
Assert.assertFalse(civ.religionManager.religion?.hasBelief("Dance of the Aurora") ?: false)
city.cityConstructions.addBuilding(game.createBuilding("Adopt [Dance of the Aurora]")) // Expected to not work, since we require a Religion
Assert.assertFalse(civ.religionManager.religion?.hasBelief("Dance of the Aurora") ?: false)
game.addReligion(civ) // With the Religion, we should be able to adopt the belief
Assert.assertFalse(civ.religionManager.religion?.hasBelief("Dance of the Aurora") ?: false)
city.cityConstructions.addBuilding(game.createBuilding("Adopt [Dance of the Aurora]"))
Assert.assertTrue(civ.religionManager.religion?.hasBelief("Dance of the Aurora") ?: false)
}
@Test
fun statsFromGlobalCitiesFollowingReligion() {
val civ1 = game.addCiv()