mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-13 00:04:38 +07:00
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:
parent
70517b9c3d
commit
20f34eb5f5
@ -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)
|
||||||
|
@ -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))
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user