Block Embarked from capturing Civilians on Water (#6224)

* Correct logic for blocking Naval Melee from capturing Civilians on Land

* Even better solution now that we can move on to unguarded Civilian tiles. But still won't let us capture Civilians if we can't get there

* Make Embarked unable to capture Civilians

* Embarked can't capture Water Civilians

* Fix Gradle Test

* Better unit test without making variable not internal

* attempt not working

* Just make currentTile not internal

* remove debug

* erronious import

Co-authored-by: itanasi <spellman23@gmail.com>
This commit is contained in:
itanasi 2022-03-05 10:06:06 -08:00 committed by GitHub
parent 70517b9c3d
commit 20f34eb5f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View File

@ -40,7 +40,7 @@ class MapUnit {
lateinit var baseUnit: BaseUnit lateinit var baseUnit: BaseUnit
@Transient @Transient
internal lateinit var currentTile: TileInfo lateinit var currentTile: TileInfo
@Transient @Transient
val movement = UnitMovementAlgorithms(this) val movement = UnitMovementAlgorithms(this)

View File

@ -630,8 +630,10 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
val firstUnit = tile.getFirstUnit() val firstUnit = tile.getFirstUnit()
// Moving to non-empty tile // Moving to non-empty tile
if (firstUnit != null && unit.civInfo != firstUnit.civInfo) { if (firstUnit != null && unit.civInfo != firstUnit.civInfo) {
// Allow movement through unguarded, at-war Civilian Unit. Capture on the way // Allow movement through unguarded, at-war Civilian Unit. Capture on the way
if (tile.getUnguardedCivilian() != null && unit.civInfo.isAtWarWith(tile.civilianUnit!!.civInfo)) // But not for Embarked Units capturing on Water
if (!(unit.isEmbarked() && tile.isWater)
&& tile.getUnguardedCivilian() != null && unit.civInfo.isAtWarWith(tile.civilianUnit!!.civInfo))
return true return true
// Cannot enter hostile tile with any unit in there // Cannot enter hostile tile with any unit in there
if (unit.civInfo.isAtWarWith(firstUnit.civInfo)) if (unit.civInfo.isAtWarWith(firstUnit.civInfo))

View File

@ -208,6 +208,8 @@ class UnitMovementAlgorithmsTests {
fun canNOTPassThroughTileWithEnemyUnits() { fun canNOTPassThroughTileWithEnemyUnits() {
tile.baseTerrain = Constants.grassland tile.baseTerrain = Constants.grassland
tile.setTransients() tile.setTransients()
unit.currentTile = tile
val otherCiv = CivilizationInfo() val otherCiv = CivilizationInfo()
otherCiv.civName = Constants.barbarians // they are always enemies otherCiv.civName = Constants.barbarians // they are always enemies