diff --git a/core/src/com/unciv/logic/map/mapunit/MapUnit.kt b/core/src/com/unciv/logic/map/mapunit/MapUnit.kt index 48355c20ab..a05dd0a3c7 100644 --- a/core/src/com/unciv/logic/map/mapunit/MapUnit.kt +++ b/core/src/com/unciv/logic/map/mapunit/MapUnit.kt @@ -584,8 +584,6 @@ class MapUnit : IsPartOfGameInfoSerialization { if (civ.matchesFilter(filter, cache.state, false)) return true if (nonUnitUniquesMap.hasUnique(filter, cache.state)) return true if (promotions.promotions.contains(filter)) return true - // Badly optimized, but it's rare that statuses is even non-empty - // Statuses really should be converted to a hashmap if (hasStatus(filter)) return true return false } diff --git a/tests/src/com/unciv/logic/battle/BattleTest.kt b/tests/src/com/unciv/logic/battle/BattleTest.kt index 055912ab35..98b9c61d88 100644 --- a/tests/src/com/unciv/logic/battle/BattleTest.kt +++ b/tests/src/com/unciv/logic/battle/BattleTest.kt @@ -514,4 +514,24 @@ class BattleTest { // then assertTrue(attackerUnit.isDestroyed) } + + + @Test + fun `should trigger damage triggers when ranged attacking`() { + // given + val unitType = testGame.createBaseUnit("Archery", + "[This Unit] takes [5] damage ") + unitType.rangedStrength = 10 + val attackerUnit = testGame.addUnit(unitType.name, attackerCiv, testGame.getTile(Vector2.Y)) + attackerUnit.currentMovement = 2f + defaultDefenderUnit.health = 1 + + // when + defaultDefenderUnit.setStatus("Test", 1) + Battle.attack(MapUnitCombatant(attackerUnit), MapUnitCombatant(defaultDefenderUnit)) + + // then + assertEquals(95, attackerUnit.health) + assertTrue(defaultDefenderUnit.isDestroyed) + } }