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 {
return !isCapital() && !isHolyCity()
return !isOriginalCapital && !isCapital() && !isHolyCity()
}
//endregion

View File

@ -114,17 +114,20 @@ object UnitActions {
val tile = unit.currentTile
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)
&& tile.ruleset.tileImprovements[improvement]!!.techRequired.let { it == null || unit.civInfo.tech.isResearched(it) })
return UnitAction(UnitActionType.Create, "Create [$improvement]",
action = {
tile.improvement = improvement
unit.destroy()
}.takeIf { unit.currentMovement > 0 })
return null
return UnitAction(UnitActionType.Create, "Create [$improvementName]",
action = {
tile.improvement = improvementName
val city = tile.getCity()
if (city != null) {
city.cityStats.update()
city.civInfo.updateDetailedCivResources()
}
unit.destroy()
}.takeIf { unit.currentMovement > 0 })
}
// 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.civInfo.updateDetailedCivResources()
}
// Why is this here? How do we now the unit is actually a great person?
// What if in some mod some unit can construct a certain type of improvement using the "Can construct []" unique?
// That unit does not need to be a great person at all, and yet it would trigger mausoleum of halicarnassus (?) here.
addGoldPerGreatPersonUsage(unit.civInfo)
if (unit.hasUnique("Great Person - []"))
addGoldPerGreatPersonUsage(unit.civInfo)
unit.destroy()
}.takeIf {
unit.currentMovement > 0f && tile.canBuildImprovement(improvement, unit.civInfo)