From 764a1c3913a5d7fe8a9beb5a5b7fe6bd7ae36cac Mon Sep 17 00:00:00 2001 From: HadeanLake <69697985+HadeanLake@users.noreply.github.com> Date: Tue, 18 Aug 2020 19:20:59 +0300 Subject: [PATCH] scenario editing mode improvements and new unique (#2999) * scenario editing mode improvements and new uniques * Fixed Russian nation unique - it is civ-wide bonus * genericized "+[]% Production when building [] in this city" * genericized "All newly-trained [] units in this city receive the [] promotion" * changed some uniques to be able to have list of filters separated by comma as unique param * scenario editing mode improvements: Resource requirements when buying buildings and units are ignored Limit for selling buildings is ignored Workers improve tiles instantly Units will not be disbanded if civilization has negative gold * fix crash in scenario editing mode due to PerpetualConstruction not having a GoldCost * undo comma separation * implement All newly-trained [relevant] units in this city receive the [] promotion relevant as in 'units that can receive' * upadte template.properties * unnecessary parentheses * Not being annoyed by this vs less chance of forgetting to set gold before releasing scenario * update template.properties * add missing spaces --- .../jsons/Civ V - Vanilla/Buildings.json | 20 +++++++++---------- .../assets/jsons/Civ V - Vanilla/Nations.json | 2 +- .../jsons/translations/template.properties | 4 ++++ core/src/com/unciv/logic/city/CityStats.kt | 16 +++++++++++++++ core/src/com/unciv/logic/map/MapUnit.kt | 2 +- core/src/com/unciv/models/ruleset/Building.kt | 2 +- .../com/unciv/models/ruleset/unit/BaseUnit.kt | 13 +++++++++++- .../com/unciv/ui/cityscreen/CityInfoTable.kt | 2 +- .../unciv/ui/cityscreen/ConstructionsTable.kt | 2 +- 9 files changed, 47 insertions(+), 16 deletions(-) diff --git a/android/assets/jsons/Civ V - Vanilla/Buildings.json b/android/assets/jsons/Civ V - Vanilla/Buildings.json index 845a9b24bb..6b80136593 100644 --- a/android/assets/jsons/Civ V - Vanilla/Buildings.json +++ b/android/assets/jsons/Civ V - Vanilla/Buildings.json @@ -158,7 +158,7 @@ "culture": 1, "isWonder": true, "uniques": ["+15% Combat Strength for all units when attacking Cities"], - "requiredTech": "Bronze Working" + "requiredTech": "Bronze Working", "quote": "'He spoke, the son of Kronos, and nodded his head with the dark brows, and the immortally anointed hair of the great god swept from his divine head, and all Olympos was shaken' - The Iliad" }, { @@ -167,8 +167,8 @@ "greatPersonPoints": {"gold": 1}, "isWonder": true, "uniques": ["Provides a sum of gold each time you spend a Great Person", - "[+2 Gold] from [Marble] tiles in this city", "[+2 Gold] from [Stone] tiles in this city"] - "requiredTech": "Masonry" + "[+2 Gold] from [Marble] tiles in this city", "[+2 Gold] from [Stone] tiles in this city"], + "requiredTech": "Masonry", "quote": "'The whole earth is the tomb of heroic men and their story is not given only on stone over their clay but abides everywhere without visible symbol woven into the stuff of other men's lives.' - Pericles" }, @@ -179,7 +179,7 @@ "hurryCostModifier": 25, "maintenance": 1, "resourceBonusStats": {"food": 1}, - "uniques": ["Can only be built in coastal cities", "[+1 Food] from [Ocean] tiles in this city", "[+1 Food] from [Coast] tiles in this city"] + "uniques": ["Can only be built in coastal cities", "[+1 Food] from [Ocean] tiles in this city", "[+1 Food] from [Coast] tiles in this city"], "requiredTech": "Optics" }, { @@ -198,7 +198,7 @@ "requiredNearbyImprovedResources": ["Horses","Sheep","Cattle"], "resourceBonusStats": {"production": 1}, "hurryCostModifier": 25, - "uniques": ["+15% Production when building Mounted Units in this city"], + "uniques": ["+[15]% production when building [mounted units] in this city"], "requiredTech": "Horseback Riding" }, { @@ -421,7 +421,7 @@ "requiredNearbyImprovedResources": ["Iron"], "resourceBonusStats": {"production": 1}, "requiredTech": "Metal Casting", - "uniques": ["+15% production of land units", "Increases production of spaceship parts by 15%"] + "uniques": ["+[15]% production when building [land units] in this city", "+[15]% production when building [Spaceship part] in this city"] }, { "name": "Harbor", @@ -499,7 +499,7 @@ "isWonder": true, "providesFreeBuilding": "Castle", "percentStatBonus": {"culture": 20}, - "uniques": ["All newly-trained melee, mounted, and armored units in this city receive the Drill I promotion"], + "uniques": ["All newly-trained [relevant] units in this city receive the [Drill I] promotion"], "requiredTech": "Chivalry", "quote": "'Justice is an unassailable fortress, built on the brow of a mountain which cannot be overthrown by the violence of torrents, nor demolished by the force of armies.' - Joseph Addison" }, @@ -659,7 +659,7 @@ "maintenance": 2, "requiredBuilding": "Harbor", "uniques": ["+1 production and gold from all sea resources worked by the city", - "Can only be built in coastal cities", "+15% production of naval units"], + "Can only be built in coastal cities", "+[15]% production when building [naval units] in this city"], "requiredTech": "Navigation" }, { @@ -900,7 +900,7 @@ "production": 3, "requiredResource": "Aluminum", "cost": 360, - "uniques": ["Increases production of spaceship parts by 50%"], + "uniques": ["+[50]% production when building [Spaceship part] in this city"], "requiredBuilding": "Factory", "requiredTech": "Robotics" }, @@ -927,7 +927,7 @@ "greatPersonPoints": {"science": 1}, "providesFreeBuilding": "Spaceship Factory", "uniques": ["2 free great scientists appear", - "Increases production of spaceship parts by 25%"], + "+[25]% production when building [Spaceship part] in this city"], "requiredTech": "Satellites", "quote": "'The wonder is, not that the field of stars is so vast, but that man has measured it.' - Anatole France" }, diff --git a/android/assets/jsons/Civ V - Vanilla/Nations.json b/android/assets/jsons/Civ V - Vanilla/Nations.json index 1fdae14c9c..4c1de8e242 100644 --- a/android/assets/jsons/Civ V - Vanilla/Nations.json +++ b/android/assets/jsons/Civ V - Vanilla/Nations.json @@ -195,7 +195,7 @@ "innerColor": [0,0,0], "unique": "SIBERIAN_RICHES", "uniqueName": "Siberian Riches", - "uniques": ["[+1 Production] from [Strategic resource] tiles in this city","Double quantity of [Horses] produced", + "uniques": ["[+1 Production] from every [Strategic resource]","Double quantity of [Horses] produced", "Double quantity of [Iron] produced","Double quantity of [Uranium] produced"] "cities": ["Moscow","St. Petersburg","Novgorod","Rostov","Yaroslavl","Yekaterinburg","Yakutsk","Vladivostok","Smolensk","Orenburg", "Krasnoyarsk","Khabarovsk","Bryansk","Tver","Novosibirsk","Magadan","Murmansk","Irkutsk","Chita","Samara", diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index 8109341833..278b6fdbce 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -685,6 +685,10 @@ Buildings = # For the "when constructing [military units]" translation military units = melee units = +mounted units = +naval units = +# For the All "newly-trained [relevant] units in this city receive the [] promotion" translation. Relevant as in 'units that can receive' +relevant = Wonders = Base values = Bonuses = diff --git a/core/src/com/unciv/logic/city/CityStats.kt b/core/src/com/unciv/logic/city/CityStats.kt index 592dd9115e..b1310217b2 100644 --- a/core/src/com/unciv/logic/city/CityStats.kt +++ b/core/src/com/unciv/logic/city/CityStats.kt @@ -288,6 +288,7 @@ class CityStats { val stats = cityInfo.cityConstructions.getStatPercentBonuses() val currentConstruction = cityInfo.cityConstructions.getCurrentConstruction() + // This is to be deprecated and converted to "+[]% production when building [] in this city" - keeping it here to that mods with this can still work for now if (currentConstruction is Building && currentConstruction.uniques.contains("Spaceship part")) { if (cityInfo.containsBuildingUnique("Increases production of spaceship parts by 15%")) stats.production += 15 @@ -297,6 +298,7 @@ class CityStats { stats.production += 50 } + // This is to be deprecated and converted to "+[]% production when building [] in this city" - keeping it here to that mods with this can still work for now if (currentConstruction is BaseUnit) { if (currentConstruction.unitType == UnitType.Mounted && cityInfo.containsBuildingUnique("+15% Production when building Mounted Units in this city")) @@ -309,6 +311,20 @@ class CityStats { stats.production += 15 } + for (unique in cityInfo.cityConstructions.builtBuildingUniqueMap.getUniques("+[]% production when building [] in this city")) { + val filter = unique.params[1] + if (currentConstruction.name == filter + || (filter == "land units" && currentConstruction is BaseUnit && currentConstruction.unitType.isLandUnit()) + || (filter == "naval units" && currentConstruction is BaseUnit && currentConstruction.unitType.isWaterUnit()) + || (filter == "mounted units" && currentConstruction is BaseUnit && currentConstruction.unitType == UnitType.Mounted) + || (filter == "military units" && currentConstruction is BaseUnit && currentConstruction.unitType.isMilitary()) + || (filter == "melee units" && currentConstruction is BaseUnit && currentConstruction.unitType.isMelee()) + || (filter == "Buildings" && currentConstruction is Building && !currentConstruction.isWonder) + || (filter == "Wonders" && currentConstruction is Building && currentConstruction.isWonder) + || (currentConstruction is Building && currentConstruction.uniques.contains(filter))) + stats.production += unique.params[0].toInt() + } + return stats } diff --git a/core/src/com/unciv/logic/map/MapUnit.kt b/core/src/com/unciv/logic/map/MapUnit.kt index 5aa9bafd3b..0d96d512ec 100644 --- a/core/src/com/unciv/logic/map/MapUnit.kt +++ b/core/src/com/unciv/logic/map/MapUnit.kt @@ -367,7 +367,7 @@ class MapUnit { private fun workOnImprovement() { val tile = getTile() tile.turnsToImprovement -= 1 - if (tile.turnsToImprovement != 0) return + if (tile.turnsToImprovement != 0 && !civInfo.gameInfo.gameParameters.godMode) return if (civInfo.isCurrentPlayer()) UncivGame.Current.settings.addCompletedTutorialTask("Construct an improvement") diff --git a/core/src/com/unciv/models/ruleset/Building.kt b/core/src/com/unciv/models/ruleset/Building.kt index 5d90074003..c3d8543e6f 100644 --- a/core/src/com/unciv/models/ruleset/Building.kt +++ b/core/src/com/unciv/models/ruleset/Building.kt @@ -307,7 +307,7 @@ class Building : NamedStats(), IConstruction { if (cannotBeBuiltWith != null && construction.isBuilt(cannotBeBuiltWith!!)) return "Cannot be built with $cannotBeBuiltWith" - if (requiredResource != null && !civInfo.hasResource(requiredResource!!)) + if (requiredResource != null && !civInfo.hasResource(requiredResource!!) && !civInfo.gameInfo.gameParameters.godMode) return "Consumes 1 [$requiredResource]" if (requiredNearbyImprovedResources != null) { diff --git a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt index 1d0d915d87..68de0e0766 100644 --- a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt +++ b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt @@ -136,7 +136,7 @@ class BaseUnit : INamed, IConstruction { && uniques.contains("Requires Manhattan Project")) return "Disabled by setting" if (uniques.contains("Requires Manhattan Project") && !civInfo.hasUnique("Enables nuclear weapon")) return "Requires Manhattan Project" - if (requiredResource!=null && !civInfo.hasResource(requiredResource!!)) return "Consumes 1 [$requiredResource]" + if (requiredResource!=null && !civInfo.hasResource(requiredResource!!) && !civInfo.gameInfo.gameParameters.godMode) return "Consumes 1 [$requiredResource]" if (name == Constants.settler && civInfo.isCityState()) return "No settler for city-states" if (name == Constants.settler && civInfo.isOneCityChallenger()) return "No settler for players in One City Challenge" return "" @@ -164,6 +164,17 @@ class BaseUnit : INamed, IConstruction { XP += unique.params[0].toInt() unit.promotions.XP = XP + for (unique in construction.cityInfo.cityConstructions.builtBuildingUniqueMap.getUniques("All newly-trained [] units in this city receive the [] promotion")) { + val filter = unique.params[0] + val promotion = unique.params[1] + if (unit.name == filter + || (filter == "relevant" && civInfo.gameInfo.ruleSet.unitPromotions.values.any { unit.type.toString() in it.unitTypes && it.name == promotion }) + || unit.type.name == filter + || uniques.contains(filter)) + unit.promotions.addPromotion(promotion, isFree = true) + } + + // This is to be deprecated and converted to "All newly-trained [] in this city receive the [] promotion" - keeping it here to that mods with this can still work for now if (unit.type in listOf(UnitType.Melee,UnitType.Mounted,UnitType.Armor) && construction.cityInfo.containsBuildingUnique("All newly-trained melee, mounted, and armored units in this city receive the Drill I promotion")) unit.promotions.addPromotion("Drill I", isFree = true) diff --git a/core/src/com/unciv/ui/cityscreen/CityInfoTable.kt b/core/src/com/unciv/ui/cityscreen/CityInfoTable.kt index 0e7c236128..34d59a92f7 100644 --- a/core/src/com/unciv/ui/cityscreen/CityInfoTable.kt +++ b/core/src/com/unciv/ui/cityscreen/CityInfoTable.kt @@ -114,7 +114,7 @@ class CityInfoTable(private val cityScreen: CityScreen) : Table(CameraStageBaseS cityScreen.update() }).open() } - if (cityScreen.city.hasSoldBuildingThisTurn || cityScreen.city.isPuppet + if ((cityScreen.city.hasSoldBuildingThisTurn && !cityScreen.city.civInfo.gameInfo.gameParameters.godMode) || cityScreen.city.isPuppet || !UncivGame.Current.worldScreen.isPlayersTurn) sellBuildingButton.disable() } diff --git a/core/src/com/unciv/ui/cityscreen/ConstructionsTable.kt b/core/src/com/unciv/ui/cityscreen/ConstructionsTable.kt index 743fd823b7..b3fee7737e 100644 --- a/core/src/com/unciv/ui/cityscreen/ConstructionsTable.kt +++ b/core/src/com/unciv/ui/cityscreen/ConstructionsTable.kt @@ -327,7 +327,7 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre val button = "".toTextButton() - if (construction == null || (!construction.canBePurchased() && !city.civInfo.gameInfo.gameParameters.godMode) + if (construction == null || construction is PerpetualConstruction || (!construction.canBePurchased() && !city.civInfo.gameInfo.gameParameters.godMode) ) { // fully disable a "buy" button only for "priceless" buildings such as wonders // for all other cases, the price should be displayed