Open QuintillusCFC opened 1 year ago
Random seed: 1893199352 Commit: 9b0998bbaf288c987df3c630bfaa22ce76196769 Turn: 56
A Veteran Barbarian Warrior will attack Babylon and win, with one hitpoint left. Right-click on Babylon and you can see in the console that only one Catapult remains.
This is a follow-up to #286
Currently, if a non-combat unit is the only defending unit when a rival unit attempts to move into the city, it is destroyed (eventually it will be captured).
However, if there is exactly one defending unit, and it is defeated, the city is not destroyed. A lone Catapult may prevent capture, for example.
This appears to be due to the interaction of these code blocks:
And and CanEnterTile method in MapUnitExtensions (excerpt):
It is returning false because allowCombat is false since combat already ended.
A better way of doing this might be to utilize TileExtension's FindTopDefender method (which uses MapUnitExtension's
canDefendAgainst
method, and if there are no defenders, the unit can move in.But CanDefendAgainst will also need to be enhanced to account for non-defense-capable units.
Adding the
refactor
tag since there is some duplication of logic between methods, and the area can probably be simplified a bit.