1
0
mirror of https://github.com/yairm210/Unciv.git synced 2025-01-13 00:04:38 +07:00

Block Embarked from capturing Civilians on Water ()

* 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
core/src/com/unciv/logic/map
tests/src/com/unciv/logic/map

View File

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

View File

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

View File

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