From 83427fec854f9e520456757212324983b3fd066e Mon Sep 17 00:00:00 2001 From: SomeTroglodyte <63000004+SomeTroglodyte@users.noreply.github.com> Date: Wed, 14 Apr 2021 10:28:13 +0200 Subject: [PATCH] Fix Citadel not quite buildable where it should be (#3788) --- .../assets/jsons/Civ V - Vanilla/TileImprovements.json | 2 +- core/src/com/unciv/logic/map/TileInfo.kt | 8 ++++++-- core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt | 7 ++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/android/assets/jsons/Civ V - Vanilla/TileImprovements.json b/android/assets/jsons/Civ V - Vanilla/TileImprovements.json index da4ca03c13..251fd12352 100644 --- a/android/assets/jsons/Civ V - Vanilla/TileImprovements.json +++ b/android/assets/jsons/Civ V - Vanilla/TileImprovements.json @@ -183,7 +183,7 @@ }, { "name": "Citadel", - "uniques": ["Gives a defensive bonus of [100]%", "Deal 30 damage to adjacent enemy units", "Great Improvement"] + "uniques": ["Gives a defensive bonus of [100]%", "Deal 30 damage to adjacent enemy units", "Great Improvement", "Can be built just outside your borders"] }, //Civilization unique improvements diff --git a/core/src/com/unciv/logic/map/TileInfo.kt b/core/src/com/unciv/logic/map/TileInfo.kt index de8dbf0eb5..3a1b1fee6f 100644 --- a/core/src/com/unciv/logic/map/TileInfo.kt +++ b/core/src/com/unciv/logic/map/TileInfo.kt @@ -323,7 +323,11 @@ open class TileInfo { return when { improvement.uniqueTo != null && improvement.uniqueTo != civInfo.civName -> false improvement.techRequired != null && !civInfo.tech.isResearched(improvement.techRequired!!) -> false - getOwner() != civInfo && !improvement.hasUnique("Can be built outside your borders") -> false + getOwner() != civInfo && ! ( + improvement.hasUnique("Can be built outside your borders") + // citadel can be built only next to or within own borders + || improvement.hasUnique("Can be built just outside your borders") && neighbors.any { it.getOwner() == civInfo } + ) -> false improvement.uniqueObjects.any { it.placeholderText == "Obsolete with []" && civInfo.tech.isResearched(it.params[0]) } -> return false @@ -651,4 +655,4 @@ open class TileInfo { } //endregion -} \ No newline at end of file +} diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt index b34c93aeba..f9df82074a 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt @@ -352,10 +352,7 @@ object UnitActions { unit.destroy() }.takeIf { unit.currentMovement > 0f && tile.canBuildImprovement(improvement, unit.civInfo) - && !tile.isImpassible() && // Not 100% sure that this check is necessary... - // citadel can be built only next to or within own borders - (improvementName != Constants.citadel || - tile.neighbors.any { it.getOwner() == unit.civInfo }) + && !tile.isImpassible() // Not 100% sure that this check is necessary... }) } return finalActions @@ -449,4 +446,4 @@ object UnitActions { // 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 +}