mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-26 23:50:45 +07:00
Fixed crash when mod game had religion enabled but had no great prophet unit
Also slight deprecation
This commit is contained in:
parent
d59fe45f51
commit
619dfc5e09
@ -12,22 +12,15 @@ class CivInfoTransientUpdater(val civInfo: CivilizationInfo) {
|
||||
|
||||
val newViewableInvisibleTiles = HashSet<TileInfo>()
|
||||
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
|
||||
|
@ -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<String, Int> = hashMapOf()
|
||||
//
|
||||
|
||||
var abilityUsesLeft: HashMap<String, Int> = hashMapOf()
|
||||
var maxAbilityUses: HashMap<String, Int> = 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) {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user