From 1420ad845ceec658af2cd73c1487f7e7e8f68568 Mon Sep 17 00:00:00 2001 From: itanasi <44038014+itanasi@users.noreply.github.com> Date: Tue, 8 Feb 2022 01:42:24 -0800 Subject: [PATCH] Notify when Barbs don't give more XP (#6115) * Updates to allow BarbXP gain check * Remove from ICombatant * Revert Battle.kt * Fix code in BattleTable * Add template.properties entry * Fix space issue * Silly autoformatting Co-authored-by: temurakami --- android/assets/jsons/translations/template.properties | 1 + core/src/com/unciv/logic/battle/ICombatant.kt | 2 +- .../src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index f63aae3ee2..5d40339fe9 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -873,6 +873,7 @@ Attack = Bombard = NUKE = Captured! = +Cannot gain more XP from Barbarians = # Battle modifier categories diff --git a/core/src/com/unciv/logic/battle/ICombatant.kt b/core/src/com/unciv/logic/battle/ICombatant.kt index 2b924f386d..2b41c3ff4b 100644 --- a/core/src/com/unciv/logic/battle/ICombatant.kt +++ b/core/src/com/unciv/logic/battle/ICombatant.kt @@ -30,4 +30,4 @@ interface ICombatant { return this is CityCombatant } fun isCivilian() = this is MapUnitCombatant && this.unit.isCivilian() -} \ No newline at end of file +} diff --git a/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt b/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt index 07b01d00c1..8184af5606 100644 --- a/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt +++ b/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt @@ -163,6 +163,14 @@ class BattleTable(val worldScreen: WorldScreen): Table() { row().pad(2f) } + // from Battle.addXp(), check for can't gain more XP from Barbarians + val modConstants = attacker.getCivInfo().gameInfo.ruleSet.modOptions.constants + if (attacker is MapUnitCombatant && (attacker as MapUnitCombatant).unit.promotions.totalXpProduced() >= modConstants.maxXPfromBarbarians + && defender.getCivInfo().isBarbarian()){ + add("Cannot gain more XP from Barbarians".tr().toLabel(fontSize = 16).apply { wrap=true }).width(quarterScreen) + row() + } + var damageToDefender = BattleDamage.calculateDamageToDefender(attacker,null,defender) var damageToAttacker = BattleDamage.calculateDamageToAttacker(attacker,null,defender)