Ranged capture (#5975)

* Initial attempt

* Allow Ranged to move into unguarded Civilian Unit

* Comment for clarity

* Fix unit test so that it doesn't segfault and checks you can't move into military units

* Unify that all units can move on to (and through) unguarded civilians that you are at war with
Add TileInfo.getUnguardedCivilian() to quickly respond if there is an unguarded Civilian on the tile
Something is bugged in movement code

* Fix MapUnit.moveThroughTile() so that it doesn't segfault by fixing getUnguardedCivilian()

* captureCivilianUnit() call is now redundant in postBattleMoveToAttackedTile() since canMoveTo() will now return true and capture will happen during the moveToTile() call

Co-authored-by: temurakami <spellman23@gmail.com>
This commit is contained in:
itanasi
2022-01-24 02:28:46 -08:00
committed by GitHub
parent 336e190ff0
commit 1fd65b9ffa
5 changed files with 37 additions and 9 deletions

View File

@ -215,6 +215,18 @@ class UnitMovementAlgorithmsTests {
otherCiv.nation = Nation().apply { name = Constants.barbarians }
val otherUnit = MapUnit()
otherUnit.civInfo = otherCiv
otherUnit.baseUnit = BaseUnit()
// melee check
otherUnit.baseUnit.strength = 1
tile.militaryUnit = otherUnit
for (type in ruleSet.unitTypes) {
unit.baseUnit = BaseUnit().apply { unitType = type.key; ruleset = ruleSet }
Assert.assertFalse("$type must not enter occupied tile", unit.movement.canPassThrough(tile))
}
// ranged check
otherUnit.baseUnit.rangedStrength = 1 // make non-Civilian ranged
tile.militaryUnit = otherUnit
for (type in ruleSet.unitTypes) {