From 61d48a5c37c357920a9f474b0d639ad76cd14968 Mon Sep 17 00:00:00 2001 From: itanasi <44038014+itanasi@users.noreply.github.com> Date: Wed, 3 Aug 2022 10:24:19 -0700 Subject: [PATCH] Add Damage numbers to Battle Notifications (#7587) * Initial changes * Adding damage numbers --- .../assets/jsons/translations/template.properties | 12 ++++++++++++ core/src/com/unciv/logic/battle/Battle.kt | 11 +++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index 1ff202b550..2112a3141b 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -762,17 +762,29 @@ Your Golden Age has ended. = [cityName] has been razed to the ground! = We have conquered the city of [cityName]! = An enemy [unit] has attacked [cityName] = +An enemy [unit] ([amount]) has attacked [cityName] ([amount2]) = An enemy [unit] has attacked our [ourUnit] = +An enemy [unit] ([amount]) has attacked our [ourUnit] ([amount2]) = Enemy city [cityName] has attacked our [ourUnit] = +Enemy city [cityName] ([amount]) has attacked our [ourUnit] ([amount2]) = An enemy [unit] has captured [cityName] = +An enemy [unit] ([amount]) has captured [cityName] ([amount2]) = An enemy [unit] has raided [cityName] = +An enemy [unit] ([amount]) has raided [cityName] ([amount2]) = An enemy [unit] has captured our [ourUnit] = +An enemy [unit] ([amount]) has captured our [ourUnit] ([amount2]) = An enemy [unit] has destroyed our [ourUnit] = +An enemy [unit] ([amount]) has destroyed our [ourUnit] ([amount2]) = Your [ourUnit] has destroyed an enemy [unit] = +Your [ourUnit] ([amount]) has destroyed an enemy [unit] ([amount2]) = An enemy [RangedUnit] has destroyed the defence of [cityName] = +An enemy [RangedUnit] ([amount]) has destroyed the defence of [cityName] ([amount2]) = Enemy city [cityName] has destroyed our [ourUnit] = +Enemy city [cityName] ([amount]) has destroyed our [ourUnit] ([amount2]) = An enemy [unit] was destroyed while attacking [cityName] = +An enemy [unit] ([amount]) was destroyed while attacking [cityName] ([amount2]) = An enemy [unit] was destroyed while attacking our [ourUnit] = +An enemy [unit] ([amount]) was destroyed while attacking our [ourUnit] ([amount2]) = Our [attackerName] ([amount]) was destroyed by an intercepting [interceptorName] ([amount2]) = Our [attackerName] ([amount]) was destroyed by an unknown interceptor = Our [interceptorName] ([amount]) intercepted and destroyed an enemy [attackerName] ([amount2]) = diff --git a/core/src/com/unciv/logic/battle/Battle.kt b/core/src/com/unciv/logic/battle/Battle.kt index c4fd07840a..b306247744 100644 --- a/core/src/com/unciv/logic/battle/Battle.kt +++ b/core/src/com/unciv/logic/battle/Battle.kt @@ -115,14 +115,14 @@ object Battle { val isAlreadyDefeatedCity = defender is CityCombatant && defender.isDefeated() - takeDamage(attacker, defender) + val damageDealt = takeDamage(attacker, defender) // check if unit is captured by the attacker (prize ships unique) // As ravignir clarified in issue #4374, this only works for aggressor val captureMilitaryUnitSuccess = tryCaptureUnit(attacker, defender, attackedTile) if (!captureMilitaryUnitSuccess) // capture creates a new unit, but `defender` still is the original, so this function would still show a kill message - postBattleNotifications(attacker, defender, attackedTile, attacker.getTile()) + postBattleNotifications(attacker, defender, attackedTile, attacker.getTile(), damageDealt) if (defender.getCivInfo().isBarbarian() && attackedTile.improvement == Constants.barbarianEncampment) defender.getCivInfo().gameInfo.barbarians.campAttacked(attackedTile.position) @@ -376,7 +376,8 @@ object Battle { attacker: ICombatant, defender: ICombatant, attackedTile: TileInfo, - attackerTile: TileInfo? = null + attackerTile: TileInfo? = null, + damageDealt: DamageDealt? = null ) { if (attacker.getCivInfo() != defender.getCivInfo()) { // If what happened was that a civilian unit was captured, that's dealt with in the captureCivilianUnit function @@ -400,7 +401,9 @@ object Battle { if (defender.isDefeated() && attacker.isRanged()) " the defence of [" + defender.getName() + "]" else " [" + defender.getName() + "]" else " our [" + defender.getName() + "]" - val notificationString = attackerString + whatHappenedString + defenderString + val attackerDealtString = if (damageDealt != null) " ([${damageDealt.attackerDealt}])" else "" + val defenderDealtString = if (damageDealt != null) " ([${damageDealt.defenderDealt}])" else "" + val notificationString = attackerString + attackerDealtString + whatHappenedString + defenderString + defenderDealtString val attackerIcon = if (attacker is CityCombatant) NotificationIcon.City else attacker.getName() val defenderIcon = if (defender is CityCombatant) NotificationIcon.City else defender.getName() val locations = LocationAction(attackedTile.position, attackerTile?.position)