Fixed ruins having two faith bonuses that could apply at the same time (#5545)

* Fixed ruins having two faith bonuses that could apply at the same time

* Added turn restrictions on ruins
This commit is contained in:
Xander Lenstra 2021-10-25 18:09:39 +02:00 committed by GitHub
parent 4c19347a89
commit 5d9c1266d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 10 deletions

View File

@ -20,7 +20,7 @@
{ {
"name": "your exploring unit receives training", "name": "your exploring unit receives training",
"notification": "An ancient tribe trained us in their ways of combat!", "notification": "An ancient tribe trained us in their ways of combat!",
"uniques": ["This Unit gains [10] XP"] "uniques": ["This Unit gains [10] XP", "Only available after [10] turns"]
}, },
{ {
"name": "survivors (adds population to a city)", "name": "survivors (adds population to a city)",
@ -58,13 +58,13 @@
{ {
"name": "discover holy symbols", "name": "discover holy symbols",
"notification": "We have found holy symbols in the ruins, giving us a deeper understanding of religion! (+[faithAmount] Faith)", "notification": "We have found holy symbols in the ruins, giving us a deeper understanding of religion! (+[faithAmount] Faith)",
"uniques": ["Hidden when religion is disabled", "Gain enough Faith for a Pantheon"], "uniques": ["Hidden when religion is disabled", "Gain enough Faith for a Pantheon", "Hidden after founding a Pantheon", "Only available after [20] turns"],
"color": "#CDDDF4" "color": "#CDDDF4"
}, },
{ {
"name": "an ancient prophecy", "name": "an ancient prophecy",
"notification": "We have found an ancient prophecy in the ruins, greatly increasing our spiritual connection! (+[faithAmount] Faith)", "notification": "We have found an ancient prophecy in the ruins, greatly increasing our spiritual connection! (+[faithAmount] Faith)",
"uniques": ["Hidden when religion is disabled", "Gain enough Faith for [33]% of a Great Prophet", "Hidden after generating a Great Prophet"], "uniques": ["Hidden when religion is disabled", "Gain enough Faith for [33]% of a Great Prophet", "Hidden after generating a Great Prophet", "Hidden before founding a Pantheon", "Only available after [20] turns"],
"color": "#CDDDF4" "color": "#CDDDF4"
} }
] ]

View File

@ -2,8 +2,10 @@ package com.unciv.logic.civilization.RuinsManager
import com.unciv.Constants import com.unciv.Constants
import com.unciv.logic.civilization.CivilizationInfo import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.logic.civilization.ReligionState
import com.unciv.logic.map.MapUnit import com.unciv.logic.map.MapUnit
import com.unciv.models.ruleset.RuinReward import com.unciv.models.ruleset.RuinReward
import com.unciv.models.ruleset.unique.Unique
import com.unciv.models.ruleset.unique.UniqueTriggerActivation import com.unciv.models.ruleset.unique.UniqueTriggerActivation
import com.unciv.models.ruleset.unique.UniqueType import com.unciv.models.ruleset.unique.UniqueType
import kotlin.random.Random import kotlin.random.Random
@ -43,13 +45,15 @@ class RuinsManager {
for (possibleReward in possibleRewards) { for (possibleReward in possibleRewards) {
if (civInfo.gameInfo.difficulty in possibleReward.excludedDifficulties) continue if (civInfo.gameInfo.difficulty in possibleReward.excludedDifficulties) continue
if (possibleReward.hasUnique(UniqueType.HiddenWithoutReligion) && !civInfo.gameInfo.isReligionEnabled()) continue if (possibleReward.hasUnique(UniqueType.HiddenWithoutReligion) && !civInfo.gameInfo.isReligionEnabled()) continue
if ("Hidden after generating a Great Prophet" in possibleReward.uniques if (possibleReward.hasUnique(UniqueType.HiddenAfterGreatProphet)
&& civInfo.civConstructions.boughtItemsWithIncreasingPrice[civInfo.religionManager.getGreatProphetEquivalent()] ?: 0 > 0 && civInfo.civConstructions.boughtItemsWithIncreasingPrice[civInfo.religionManager.getGreatProphetEquivalent()] ?: 0 > 0
) continue ) continue
if (possibleReward.uniqueObjects.any { unique -> if (possibleReward.hasUnique(UniqueType.HiddenAfterPantheon) && civInfo.religionManager.religionState >= ReligionState.Pantheon)
unique.placeholderText == "Only available after [] turns" continue
&& unique.params[0].toInt() < civInfo.gameInfo.turns if (possibleReward.hasUnique(UniqueType.HiddenBeforePantheon) && civInfo.religionManager.religionState == ReligionState.None)
}) continue continue
if (possibleReward.getMatchingUniques(UniqueType.AvailableAfterCertainTurns).any { it.params[0].toInt() < civInfo.gameInfo.turns })
continue
var atLeastOneUniqueHadEffect = false var atLeastOneUniqueHadEffect = false
for (unique in possibleReward.uniqueObjects) { for (unique in possibleReward.uniqueObjects) {

View File

@ -265,8 +265,6 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget) {
CannotEnterOcean("Cannot enter ocean tiles", UniqueTarget.Unit), CannotEnterOcean("Cannot enter ocean tiles", UniqueTarget.Unit),
CannotEnterOceanUntilAstronomy("Cannot enter ocean tiles until Astronomy", UniqueTarget.Unit), CannotEnterOceanUntilAstronomy("Cannot enter ocean tiles until Astronomy", UniqueTarget.Unit),
HiddenWithoutReligion("Hidden when religion is disabled", UniqueTarget.Unit, UniqueTarget.Building, UniqueTarget.Ruins),
///////////////////////////////////////// TILE UNIQUES ///////////////////////////////////////// ///////////////////////////////////////// TILE UNIQUES /////////////////////////////////////////
@ -408,6 +406,15 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget) {
TimedAttackStrength("+[amount]% attack strength to all [mapUnitFilter] Units for [amount] turns", UniqueTarget.Global), // used in Policy TimedAttackStrength("+[amount]% attack strength to all [mapUnitFilter] Units for [amount] turns", UniqueTarget.Global), // used in Policy
FreeStatBuildings("Provides the cheapest [stat] building in your first [amount] cities for free", UniqueTarget.Global), // used in Policy FreeStatBuildings("Provides the cheapest [stat] building in your first [amount] cities for free", UniqueTarget.Global), // used in Policy
FreeSpecificBuildings("Provides a [buildingName] in your first [amount] cities for free", UniqueTarget.Global), // used in Policy FreeSpecificBuildings("Provides a [buildingName] in your first [amount] cities for free", UniqueTarget.Global), // used in Policy
///////////////////////////////////////////// META /////////////////////////////////////////////
HiddenWithoutReligion("Hidden when religion is disabled", UniqueTarget.Unit, UniqueTarget.Building, UniqueTarget.Ruins),
HiddenBeforePantheon("Hidden before founding a Pantheon", UniqueTarget.Ruins),
HiddenAfterPantheon("Hidden after founding a Pantheon", UniqueTarget.Ruins),
HiddenAfterGreatProphet("Hidden after generating a Great Prophet", UniqueTarget.Ruins),
AvailableAfterCertainTurns("Only available after [amount] turns", UniqueTarget.Ruins),
; ;
/** For uniques that have "special" parameters that can accept multiple types, we can override them manually /** For uniques that have "special" parameters that can accept multiple types, we can override them manually