From e2c6ae450d8fac3e0d29f7c1fee998ff156af86f Mon Sep 17 00:00:00 2001 From: SomeTroglodyte <63000004+SomeTroglodyte@users.noreply.github.com> Date: Mon, 19 Apr 2021 19:18:20 +0200 Subject: [PATCH] Make city center unpillagable using a unique (#3818) --- .../assets/jsons/Civ V - Vanilla/TileImprovements.json | 8 ++++---- core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/android/assets/jsons/Civ V - Vanilla/TileImprovements.json b/android/assets/jsons/Civ V - Vanilla/TileImprovements.json index 251fd12352..f275cb1858 100644 --- a/android/assets/jsons/Civ V - Vanilla/TileImprovements.json +++ b/android/assets/jsons/Civ V - Vanilla/TileImprovements.json @@ -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"] } ] diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt index f9df82074a..2878c4229a 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt @@ -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)