diff --git a/core/src/com/unciv/logic/automation/UnitAutomation.kt b/core/src/com/unciv/logic/automation/UnitAutomation.kt index 3f7f3226..0e901060 100644 --- a/core/src/com/unciv/logic/automation/UnitAutomation.kt +++ b/core/src/com/unciv/logic/automation/UnitAutomation.kt @@ -106,7 +106,7 @@ class UnitAutomation{ fun pillageImprovement(unit: MapUnit, unitDistanceToTiles: HashMap) : Boolean { val tilesInDistance = unitDistanceToTiles.filter {it.value < unit.currentMovement}.keys - .filter { unit.canMoveTo(it) && it.improvement != null } + .filter { unit.canMoveTo(it) && it.improvement != null && UnitActions().canPillage(unit,it) } if (tilesInDistance.isEmpty()) return false val tileToPillage = tilesInDistance.maxBy { it.getDefensiveBonus() }!! diff --git a/core/src/com/unciv/logic/trade/TradeEvaluation.kt b/core/src/com/unciv/logic/trade/TradeEvaluation.kt index 411d22d8..1c153006 100644 --- a/core/src/com/unciv/logic/trade/TradeEvaluation.kt +++ b/core/src/com/unciv/logic/trade/TradeEvaluation.kt @@ -4,7 +4,6 @@ import com.unciv.Constants import com.unciv.logic.automation.Automation import com.unciv.logic.automation.ThreatLevel import com.unciv.logic.civilization.CivilizationInfo -import com.unciv.logic.civilization.diplomacy.DiplomaticStatus import com.unciv.logic.civilization.diplomacy.RelationshipLevel import com.unciv.models.gamebasics.GameBasics import com.unciv.models.gamebasics.tile.ResourceType @@ -93,7 +92,7 @@ class TradeEvaluation{ val civToDeclareWarOn = civInfo.gameInfo.getCivilization(nameOfCivToDeclareWarOn) val threatToThem = Automation().threatAssessment(civInfo,civToDeclareWarOn) - if(civInfo.getDiplomacyManager(civToDeclareWarOn).diplomaticStatus== DiplomaticStatus.War){ + if(civInfo.isAtWarWith(civToDeclareWarOn)){ when (threatToThem) { ThreatLevel.VeryLow -> return 0 ThreatLevel.Low -> return 0 @@ -180,7 +179,7 @@ class TradeEvaluation{ return sumOfStats.toInt() * 100 } TradeType.Agreement -> { - if(offer.name=="Open Borders") return 100 + if(offer.name == "Open Borders") return 100 throw Exception("Invalid agreement type!") } } diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt index 50514282..fda6042c 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt @@ -6,6 +6,7 @@ import com.unciv.logic.automation.UnitAutomation import com.unciv.logic.automation.WorkerAutomation import com.unciv.logic.map.MapUnit import com.unciv.logic.map.RoadStatus +import com.unciv.logic.map.TileInfo import com.unciv.models.gamebasics.Building import com.unciv.models.gamebasics.GameBasics import com.unciv.models.gamebasics.tr @@ -105,7 +106,7 @@ class UnitActions { } if(!unit.type.isCivilian() && tile.improvement !=null){ - actionList += UnitAction("Pillage", unit.currentMovement>0) + actionList += UnitAction("Pillage", unit.currentMovement>0 && canPillage(unit,tile)) { // http://well-of-souls.com/civ/civ5_improvements.html says that naval improvements are destroyed upon pilllage // and I can't find any other sources so I'll go with that @@ -253,4 +254,10 @@ class UnitActions { return actionList } + fun canPillage(unit: MapUnit, tile: TileInfo): Boolean { + 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) + } + } \ No newline at end of file