From a08a0e1489284f4d423de1e7c137fcb3958ac0d0 Mon Sep 17 00:00:00 2001 From: yairm210 Date: Wed, 11 Aug 2021 20:40:44 +0300 Subject: [PATCH] Added ruleset check for units whose type is not defined in the unitTypes --- core/src/com/unciv/logic/civilization/CivilizationInfo.kt | 4 +++- core/src/com/unciv/models/ruleset/Ruleset.kt | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt index 8875b98390..c9aa0ad754 100644 --- a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt +++ b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt @@ -369,7 +369,9 @@ class CivilizationInfo { otherCiv.addNotification(meetString, cityStateLocation, NotificationIcon.Gold) else otherCiv.addNotification(meetString, NotificationIcon.Gold) - otherCiv.addStats(giftAmount) + + for (stat in giftAmount.toHashMap().filter { it.value != 0f }) + otherCiv.addStat(stat.key, stat.value.toInt()) } fun discoverNaturalWonder(naturalWonderName: String) { diff --git a/core/src/com/unciv/models/ruleset/Ruleset.kt b/core/src/com/unciv/models/ruleset/Ruleset.kt index 0538dc28ed..099b0dcc9a 100644 --- a/core/src/com/unciv/models/ruleset/Ruleset.kt +++ b/core/src/com/unciv/models/ruleset/Ruleset.kt @@ -289,6 +289,7 @@ class Ruleset { fun isError() = status == CheckModLinksStatus.Error fun isNotOK() = status != CheckModLinksStatus.OK } + fun checkModLinks(): CheckModLinksResult { val lines = ArrayList() var warningCount = 0 @@ -338,8 +339,9 @@ class Ruleset { lines += "${unit.name} replaces ${unit.replaces} which does not exist!" for (promotion in unit.promotions) if (!unitPromotions.containsKey(promotion)) - lines += "${unit.replaces} contains promotion $promotion which does not exist!" - + lines += "${unit.name} contains promotion $promotion which does not exist!" + if (!unitTypes.containsKey(unit.unitType)) + lines += "${unit.name} is of type ${unit.unitType}, which does not exist!" } for (building in buildings.values) {