From 973a8fb0acc79b4889d9e251a98401ba54a683b4 Mon Sep 17 00:00:00 2001 From: SomeTroglodyte <63000004+SomeTroglodyte@users.noreply.github.com> Date: Mon, 19 Jul 2021 20:53:15 +0200 Subject: [PATCH] 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 --- core/src/com/unciv/logic/city/CityInfo.kt | 2 +- .../unciv/ui/worldscreen/unit/UnitActions.kt | 29 ++++++++++--------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/core/src/com/unciv/logic/city/CityInfo.kt b/core/src/com/unciv/logic/city/CityInfo.kt index fc34dd1fb2..4e33631641 100644 --- a/core/src/com/unciv/logic/city/CityInfo.kt +++ b/core/src/com/unciv/logic/city/CityInfo.kt @@ -599,7 +599,7 @@ class CityInfo { } fun canBeDestroyed(): Boolean { - return !isCapital() && !isHolyCity() + return !isOriginalCapital && !isCapital() && !isHolyCity() } //endregion diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt index 8cf16bf368..f8924865ea 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt @@ -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)