mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-08 03:27:51 -04:00
chore: Added test that battle triggers work, investigating #13291
This commit is contained in:
parent
053691e18d
commit
4ff8442023
@ -584,8 +584,6 @@ class MapUnit : IsPartOfGameInfoSerialization {
|
|||||||
if (civ.matchesFilter(filter, cache.state, false)) return true
|
if (civ.matchesFilter(filter, cache.state, false)) return true
|
||||||
if (nonUnitUniquesMap.hasUnique(filter, cache.state)) return true
|
if (nonUnitUniquesMap.hasUnique(filter, cache.state)) return true
|
||||||
if (promotions.promotions.contains(filter)) 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
|
if (hasStatus(filter)) return true
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@ -514,4 +514,24 @@ class BattleTest {
|
|||||||
// then
|
// then
|
||||||
assertTrue(attackerUnit.isDestroyed)
|
assertTrue(attackerUnit.isDestroyed)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `should trigger damage triggers when ranged attacking`() {
|
||||||
|
// given
|
||||||
|
val unitType = testGame.createBaseUnit("Archery",
|
||||||
|
"[This Unit] takes [5] damage <upon damaging a [Test] unit>")
|
||||||
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user