From f97e64e54e7f4422c66d3a4afc29434c74cf1681 Mon Sep 17 00:00:00 2001 From: Xander Lenstra <71121390+xlenstra@users.noreply.github.com> Date: Mon, 12 Jul 2021 18:37:56 +0200 Subject: [PATCH] Fixed bug where submarines could not attack embarked units (#4459) * Fixed bug where submarines could not attack embarked units * Implemented requested changes * Fixed typo --- android/assets/jsons/Civ V - Vanilla/Units.json | 8 +++++--- core/src/com/unciv/logic/automation/BattleHelper.kt | 10 ++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/android/assets/jsons/Civ V - Vanilla/Units.json b/android/assets/jsons/Civ V - Vanilla/Units.json index 5a52b24d2d..bdfe604846 100644 --- a/android/assets/jsons/Civ V - Vanilla/Units.json +++ b/android/assets/jsons/Civ V - Vanilla/Units.json @@ -1004,7 +1004,8 @@ "cost": 325, "requiredTech": "Refrigeration", "upgradesTo": "Nuclear Submarine", - "uniques": ["+[75]% Strength when attacking", "Invisible to others", "Can only attack [Water] units", "Can attack submarines", "Can enter ice tiles"], + "uniques": ["+[75]% Strength when attacking", "Invisible to others", "Can only attack [Water] tiles", + "Can attack submarines", "Can enter ice tiles"], "attackSound": "torpedo" }, { @@ -1364,8 +1365,9 @@ "rangedStrength": 85, "cost": 425, "requiredTech": "Telecommunications", - "uniques": ["+[75]% Strength when attacking", "Invisible to others", "Can only attack [Water] units", - "Can attack submarines", "Can enter ice tiles", "[+1] Visibility Range", "Can carry [2] [Missile] units"], + "uniques": ["+[75]% Strength when attacking", "Invisible to others", + "Can only attack [Water] tiles", "Can attack submarines", "Can enter ice tiles", + "[+1] Visibility Range", "Can carry [2] [Missile] units"], "attackSound": "torpedo" }, { diff --git a/core/src/com/unciv/logic/automation/BattleHelper.kt b/core/src/com/unciv/logic/automation/BattleHelper.kt index b284ee3924..7455d5812a 100644 --- a/core/src/com/unciv/logic/automation/BattleHelper.kt +++ b/core/src/com/unciv/logic/automation/BattleHelper.kt @@ -98,8 +98,14 @@ object BattleHelper { if (combatant is MapUnitCombatant && combatant.unit.hasUnique("Can only attack [] units") && - combatant.unit.getMatchingUniques("Can only attack [] units").none { tileCombatant.matchesCategory(it.params[0]) }) - return false + combatant.unit.getMatchingUniques("Can only attack [] units").none { tileCombatant.matchesCategory(it.params[0]) } + ) + return false + if (combatant is MapUnitCombatant && + combatant.unit.hasUnique("Can only attack [] tiles") && + combatant.unit.getMatchingUniques("Can only attack [] tiles").none { tile.matchesFilter(it.params[0]) } + ) + return false //only submarine and destroyer can attack submarine //garrisoned submarine can be attacked by anyone, or the city will be in invincible