Fix Citadel not quite buildable where it should be (#3788)

This commit is contained in:
SomeTroglodyte
2021-04-14 10:28:13 +02:00
committed by GitHub
parent 3efbbc716e
commit 83427fec85
3 changed files with 9 additions and 8 deletions

View File

@ -183,7 +183,7 @@
}, },
{ {
"name": "Citadel", "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 //Civilization unique improvements

View File

@ -323,7 +323,11 @@ open class TileInfo {
return when { return when {
improvement.uniqueTo != null && improvement.uniqueTo != civInfo.civName -> false improvement.uniqueTo != null && improvement.uniqueTo != civInfo.civName -> false
improvement.techRequired != null && !civInfo.tech.isResearched(improvement.techRequired!!) -> 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 { improvement.uniqueObjects.any {
it.placeholderText == "Obsolete with []" && civInfo.tech.isResearched(it.params[0]) it.placeholderText == "Obsolete with []" && civInfo.tech.isResearched(it.params[0])
} -> return false } -> return false
@ -651,4 +655,4 @@ open class TileInfo {
} }
//endregion //endregion
} }

View File

@ -352,10 +352,7 @@ object UnitActions {
unit.destroy() unit.destroy()
}.takeIf { }.takeIf {
unit.currentMovement > 0f && tile.canBuildImprovement(improvement, unit.civInfo) unit.currentMovement > 0f && tile.canBuildImprovement(improvement, unit.civInfo)
&& !tile.isImpassible() && // Not 100% sure that this check is necessary... && !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 })
}) })
} }
return finalActions 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 // 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)
} }
} }