Resolved #753 - can no longer pillage tiles of allied civs (that's an act of war)

This commit is contained in:
Yair Morgenstern 2019-05-14 20:47:21 +03:00
parent 157e6e81a8
commit 59e30529c4
3 changed files with 11 additions and 5 deletions

View file

@ -106,7 +106,7 @@ class UnitAutomation{
fun pillageImprovement(unit: MapUnit, unitDistanceToTiles: HashMap<TileInfo, Float>) : 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() }!!

View file

@ -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!")
}
}

View file

@ -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)
}
}