Disabled pillaging your own tiles (#4882)

This commit is contained in:
Arthur van der Staaij 2021-08-17 08:10:21 +02:00 committed by GitHub
parent 0436e67342
commit 0ce033b3a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 3 deletions

View File

@ -232,7 +232,6 @@ object UnitAutomation {
val tilesThatCanWalkToAndThenPillage = unitDistanceToTiles
.filter { it.value.totalDistance < unit.currentMovement }.keys
.filter { unit.movement.canMoveTo(it) && UnitActions.canPillage(unit, it) }
.filter { it.getOwner() != unit.civInfo }
if (tilesThatCanWalkToAndThenPillage.isEmpty()) return false
val tileToPillage = tilesThatCanWalkToAndThenPillage.maxByOrNull { it: TileInfo -> it.getDefensiveBonus() }!!

View File

@ -265,7 +265,7 @@ object UnitActions {
fun getPillageAction(unit: MapUnit): UnitAction? {
val tile = unit.currentTile
if (unit.isCivilian() || tile.improvement == null) return null
if (unit.isCivilian() || tile.improvement == null || tile.getOwner() == unit.civInfo) return null
return UnitAction(UnitActionType.Pillage,
action = {
@ -632,7 +632,7 @@ object UnitActions {
if (tileImprovement == null || tileImprovement.hasUnique("Unpillagable")) return false
val tileOwner = tile.getOwner()
// Can't pillage friendly tiles, just like you can't attack them - it's an 'act of war' thing
return tileOwner == null || tileOwner == unit.civInfo || unit.civInfo.isAtWarWith(tileOwner)
return tileOwner == null || unit.civInfo.isAtWarWith(tileOwner)
}
private fun addGiftAction(unit: MapUnit, actionList: ArrayList<UnitAction>, tile: TileInfo) {