Small fixes (#4548)

* Raze city button should be disabled for original capitals

* Halicarnassus trigger checks Great Person

* New water improvements should recalculate resource stuff

* Should't be able to create water improvements outside borders
This commit is contained in:
SomeTroglodyte 2021-07-19 20:53:15 +02:00 committed by GitHub
parent 46da6bd56e
commit 973a8fb0ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 15 deletions

View File

@ -599,7 +599,7 @@ class CityInfo {
} }
fun canBeDestroyed(): Boolean { fun canBeDestroyed(): Boolean {
return !isCapital() && !isHolyCity() return !isOriginalCapital && !isCapital() && !isHolyCity()
} }
//endregion //endregion

View File

@ -114,17 +114,20 @@ object UnitActions {
val tile = unit.currentTile val tile = unit.currentTile
if (!tile.isWater || !unit.hasUnique("May create improvements on water resources") || tile.resource == null) return null if (!tile.isWater || !unit.hasUnique("May create improvements on water resources") || tile.resource == null) return null
val improvement = tile.getTileResource().improvement val improvementName = tile.getTileResource().improvement ?: return null
val improvement = tile.ruleset.tileImprovements[improvementName] ?: return null
if (!tile.canBuildImprovement(improvement, unit.civInfo)) return null
if (tile.improvement == null && tile.ruleset.tileImprovements.containsKey(improvement) return UnitAction(UnitActionType.Create, "Create [$improvementName]",
&& tile.ruleset.tileImprovements[improvement]!!.techRequired.let { it == null || unit.civInfo.tech.isResearched(it) }) action = {
return UnitAction(UnitActionType.Create, "Create [$improvement]", tile.improvement = improvementName
action = { val city = tile.getCity()
tile.improvement = improvement if (city != null) {
unit.destroy() city.cityStats.update()
}.takeIf { unit.currentMovement > 0 }) city.civInfo.updateDetailedCivResources()
}
return null unit.destroy()
}.takeIf { unit.currentMovement > 0 })
} }
// This entire function is deprecated since 3.15.4, as the 'can construct roads' unique is deprecated // This entire function is deprecated since 3.15.4, as the 'can construct roads' unique is deprecated
@ -491,10 +494,8 @@ object UnitActions {
city.cityStats.update() city.cityStats.update()
city.civInfo.updateDetailedCivResources() city.civInfo.updateDetailedCivResources()
} }
// Why is this here? How do we now the unit is actually a great person? if (unit.hasUnique("Great Person - []"))
// What if in some mod some unit can construct a certain type of improvement using the "Can construct []" unique? addGoldPerGreatPersonUsage(unit.civInfo)
// That unit does not need to be a great person at all, and yet it would trigger mausoleum of halicarnassus (?) here.
addGoldPerGreatPersonUsage(unit.civInfo)
unit.destroy() unit.destroy()
}.takeIf { }.takeIf {
unit.currentMovement > 0f && tile.canBuildImprovement(improvement, unit.civInfo) unit.currentMovement > 0f && tile.canBuildImprovement(improvement, unit.civInfo)