Fixed bug where submarines could not attack embarked units (#4459)

* Fixed bug where submarines could not attack embarked units

* Implemented requested changes

* Fixed typo
This commit is contained in:
Xander Lenstra
2021-07-12 18:37:56 +02:00
committed by GitHub
parent 30082c8254
commit f97e64e54e
2 changed files with 13 additions and 5 deletions

View File

@ -1004,7 +1004,8 @@
"cost": 325, "cost": 325,
"requiredTech": "Refrigeration", "requiredTech": "Refrigeration",
"upgradesTo": "Nuclear Submarine", "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" "attackSound": "torpedo"
}, },
{ {
@ -1364,8 +1365,9 @@
"rangedStrength": 85, "rangedStrength": 85,
"cost": 425, "cost": 425,
"requiredTech": "Telecommunications", "requiredTech": "Telecommunications",
"uniques": ["+[75]% Strength when attacking", "Invisible to others", "Can only attack [Water] units", "uniques": ["+[75]% Strength when attacking", "Invisible to others",
"Can attack submarines", "Can enter ice tiles", "[+1] Visibility Range", "Can carry [2] [Missile] units"], "Can only attack [Water] tiles", "Can attack submarines", "Can enter ice tiles",
"[+1] Visibility Range", "Can carry [2] [Missile] units"],
"attackSound": "torpedo" "attackSound": "torpedo"
}, },
{ {

View File

@ -98,8 +98,14 @@ object BattleHelper {
if (combatant is MapUnitCombatant && if (combatant is MapUnitCombatant &&
combatant.unit.hasUnique("Can only attack [] units") && combatant.unit.hasUnique("Can only attack [] units") &&
combatant.unit.getMatchingUniques("Can only attack [] units").none { tileCombatant.matchesCategory(it.params[0]) }) combatant.unit.getMatchingUniques("Can only attack [] units").none { tileCombatant.matchesCategory(it.params[0]) }
return false )
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 //only submarine and destroyer can attack submarine
//garrisoned submarine can be attacked by anyone, or the city will be in invincible //garrisoned submarine can be attacked by anyone, or the city will be in invincible