From 619dfc5e09cebf31c55349ee51a2308845dc8339 Mon Sep 17 00:00:00 2001 From: yairm210 Date: Sat, 11 Sep 2021 23:05:07 +0300 Subject: [PATCH] Fixed crash when mod game had religion enabled but had no great prophet unit Also slight deprecation --- .../civilization/CivInfoTransientUpdater.kt | 19 ++++-------- core/src/com/unciv/logic/map/MapUnit.kt | 29 ------------------- core/src/com/unciv/models/ruleset/Unique.kt | 1 + 3 files changed, 7 insertions(+), 42 deletions(-) diff --git a/core/src/com/unciv/logic/civilization/CivInfoTransientUpdater.kt b/core/src/com/unciv/logic/civilization/CivInfoTransientUpdater.kt index 74940e0322..e35d04b0c6 100644 --- a/core/src/com/unciv/logic/civilization/CivInfoTransientUpdater.kt +++ b/core/src/com/unciv/logic/civilization/CivInfoTransientUpdater.kt @@ -12,22 +12,15 @@ class CivInfoTransientUpdater(val civInfo: CivilizationInfo) { val newViewableInvisibleTiles = HashSet() newViewableInvisibleTiles.addAll(civInfo.getCivUnits() - // "Can attack submarines" unique deprecated since 3.16.9 - .filter { attacker -> attacker.hasUnique("Can see invisible [] units") || attacker.hasUnique("Can attack submarines") } + .filter { attacker -> attacker.hasUnique("Can see invisible [] units") } .flatMap { attacker -> attacker.viewableTiles .asSequence() - .filter { tile -> - ( tile.militaryUnit != null - && attacker.getMatchingUniques("Can see invisible [] units") - .any { unique -> tile.militaryUnit!!.matchesFilter(unique.params[0]) } - ) || ( - tile.militaryUnit != null - // "Can attack submarines" unique deprecated since 3.16.9 - && attacker.hasUnique("Can attack submarines") - && tile.militaryUnit!!.matchesFilter("Submarine") - ) - } + .filter { tile -> + tile.militaryUnit != null + && attacker.getMatchingUniques("Can see invisible [] units") + .any { unique -> tile.militaryUnit!!.matchesFilter(unique.params[0]) } + } } ) civInfo.viewableInvisibleUnitsTiles = newViewableInvisibleTiles diff --git a/core/src/com/unciv/logic/map/MapUnit.kt b/core/src/com/unciv/logic/map/MapUnit.kt index cfcf83a66e..23e5b676a1 100644 --- a/core/src/com/unciv/logic/map/MapUnit.kt +++ b/core/src/com/unciv/logic/map/MapUnit.kt @@ -134,11 +134,6 @@ class MapUnit { var due: Boolean = true var isTransported: Boolean = false - // Deprecated since 3.16.11 - @Deprecated("Deprecated since 3.16.11", replaceWith = ReplaceWith("abilityUsesLeft")) - var abilityUsedCount: HashMap = hashMapOf() - // - var abilityUsesLeft: HashMap = hashMapOf() var maxAbilityUses: HashMap = hashMapOf() @@ -159,9 +154,6 @@ class MapUnit { toReturn.attacksThisTurn = attacksThisTurn toReturn.promotions = promotions.clone() toReturn.isTransported = isTransported - // Deprecated since 3.16.11 - toReturn.abilityUsedCount.putAll(abilityUsedCount) - // toReturn.abilityUsesLeft.putAll(abilityUsesLeft) toReturn.maxAbilityUses.putAll(maxAbilityUses) toReturn.religion = religion @@ -458,28 +450,7 @@ class MapUnit { baseUnit = ruleset.units[name] ?: throw java.lang.Exception("Unit $name is not found!") - // "Religion Spread" ability deprecated since 3.16.7, replaced with "Spread Religion" - if ("Religion Spread" in abilityUsedCount) { - abilityUsedCount[Constants.spreadReligionAbilityCount] = abilityUsedCount["Religion Spread"]!! - abilityUsedCount.remove("Religion Spread") - } - // - updateUniques() - - // abilityUsedCount deprecated since 3.16.11, this is replacement code - if (abilityUsedCount.isNotEmpty()) { - for (ability in abilityUsedCount) { - val maxUsesOfThisAbility = getMatchingUniques("Can [] [] times") - .filter { it.params[0] == ability.key } - .sumOf { it.params[1].toInt() } - abilityUsesLeft[ability.key] = maxUsesOfThisAbility - ability.value - maxAbilityUses[ability.key] = maxUsesOfThisAbility - } - abilityUsedCount.clear() - } - // - } fun useMovementPoints(amount: Float) { diff --git a/core/src/com/unciv/models/ruleset/Unique.kt b/core/src/com/unciv/models/ruleset/Unique.kt index 988adad9d2..6936981962 100644 --- a/core/src/com/unciv/models/ruleset/Unique.kt +++ b/core/src/com/unciv/models/ruleset/Unique.kt @@ -381,6 +381,7 @@ object UniqueTriggerActivation { return true } "Gain enough Faith for []% of a Great Prophet" -> { + if (civInfo.religionManager.getGreatProphetEquivalent() == null) return false val gainedFaith = (civInfo.religionManager.faithForNextGreatProphet() * (unique.params[0].toFloat() / 100f)).toInt() if (gainedFaith == 0) return false