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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

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

View File

@ -439,9 +439,9 @@ object UnitActions {
}
fun canPillage(unit: MapUnit, tile: TileInfo): Boolean {
if (tile.improvement == null || tile.improvement == Constants.barbarianEncampment
|| tile.improvement == Constants.ancientRuins
|| tile.improvement == "City ruins") return false
val tileImprovement = tile.getTileImprovement()
// City ruins, Ancient Ruins, Barbarian Camp, City Center marked in json
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)