Make city center unpillagable using a unique (#3818)

This commit is contained in:
SomeTroglodyte
2021-04-19 19:18:20 +02:00
committed by GitHub
parent 1eb3629c09
commit e2c6ae450d
2 changed files with 7 additions and 7 deletions

View File

@ -209,8 +209,8 @@
"shortcutKey": "F" "shortcutKey": "F"
}, },
{ "name": "Ancient ruins" }, { "name": "Ancient ruins", "uniques": ["Unpillagable"] },
{ "name": "City ruins" }, { "name": "City ruins", "uniques": ["Unpillagable"] },
{ "name": "City center" }, { "name": "City center", "uniques": ["Unpillagable"] },
{ "name": "Barbarian encampment" } { "name": "Barbarian encampment", "uniques": ["Unpillagable"] }
] ]

View File

@ -439,9 +439,9 @@ object UnitActions {
} }
fun canPillage(unit: MapUnit, tile: TileInfo): Boolean { fun canPillage(unit: MapUnit, tile: TileInfo): Boolean {
if (tile.improvement == null || tile.improvement == Constants.barbarianEncampment val tileImprovement = tile.getTileImprovement()
|| tile.improvement == Constants.ancientRuins // City ruins, Ancient Ruins, Barbarian Camp, City Center marked in json
|| tile.improvement == "City ruins") return false if (tileImprovement == null || tileImprovement.hasUnique("Unpillagable")) return false
val tileOwner = tile.getOwner() val tileOwner = tile.getOwner()
// Can't pillage friendly tiles, just like you can't attack them - it's an 'act of war' thing // 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 || tileOwner == unit.civInfo || unit.civInfo.isAtWarWith(tileOwner)