From d2dac66f40e6a5e14f95c991dbdde2339c5f23a8 Mon Sep 17 00:00:00 2001 From: SeventhM <127357473+SeventhM@users.noreply.github.com> Date: Wed, 5 Jul 2023 12:57:06 -0700 Subject: [PATCH] Avoid crashes with incorrect condtionals (#9753) --- core/src/com/unciv/models/ruleset/unique/Unique.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/src/com/unciv/models/ruleset/unique/Unique.kt b/core/src/com/unciv/models/ruleset/unique/Unique.kt index db1a700c5d..6354ffa2ed 100644 --- a/core/src/com/unciv/models/ruleset/unique/Unique.kt +++ b/core/src/com/unciv/models/ruleset/unique/Unique.kt @@ -44,8 +44,10 @@ class Unique(val text: String, val sourceObjectType: UniqueTarget? = null, val s fun hasTriggerConditional(): Boolean { if(conditionals.none()) return false - return conditionals.any{ conditional -> conditional.type!!.targetTypes - .any{ it.canAcceptUniqueTarget(UniqueTarget.TriggerCondition) } } + return conditionals.any{ conditional -> conditional.type?.targetTypes + ?.any{ it.canAcceptUniqueTarget(UniqueTarget.TriggerCondition) } + ?: false + } } fun isOfType(uniqueType: UniqueType) = uniqueType == type