From b264876b6b763a504d4c9039c008b5ef21743451 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Sun, 13 Dec 2020 12:21:38 +0200 Subject: [PATCH] Deprecation of old unique formats in favor of newer, more generalized ones --- core/src/com/unciv/logic/GameInfo.kt | 6 ---- core/src/com/unciv/logic/battle/Battle.kt | 22 ++---------- .../com/unciv/logic/battle/BattleDamage.kt | 35 ------------------- .../com/unciv/logic/city/CityConstructions.kt | 2 -- core/src/com/unciv/logic/city/CityStats.kt | 12 +------ .../com/unciv/logic/city/PopulationManager.kt | 3 -- core/src/com/unciv/logic/map/TileInfo.kt | 4 --- core/src/com/unciv/models/ruleset/Building.kt | 4 --- .../com/unciv/models/ruleset/Difficulty.kt | 4 +-- .../unciv/models/ruleset/tech/Technology.kt | 8 ----- .../models/ruleset/tile/TileImprovement.kt | 8 ----- .../com/unciv/ui/pickerscreens/TechButton.kt | 1 - .../unciv/ui/worldscreen/unit/UnitActions.kt | 11 ------ 13 files changed, 4 insertions(+), 116 deletions(-) diff --git a/core/src/com/unciv/logic/GameInfo.kt b/core/src/com/unciv/logic/GameInfo.kt index 99ae9a22ae..383954778f 100644 --- a/core/src/com/unciv/logic/GameInfo.kt +++ b/core/src/com/unciv/logic/GameInfo.kt @@ -327,12 +327,6 @@ class GameInfo { for (cityInfo in civInfo.cities) cityInfo.cityStats.updateCityHappiness() for (cityInfo in civInfo.cities) { - // As of 3.10.14, specialists are saved by name not by stat - for ((key, value) in cityInfo.population.specialists.toHashMap().filter { it.value > 0 }) - cityInfo.population.specialistAllocations.add( - Specialist.specialistNameByStat(key), value.toInt()) - cityInfo.population.specialists.clear() - /** We remove constructions from the queue that aren't defined in the ruleset. * This can lead to situations where the city is puppeted and had its construction removed, and there's no way to user-set it * So for cities like those, we'll auto-set the construction diff --git a/core/src/com/unciv/logic/battle/Battle.kt b/core/src/com/unciv/logic/battle/Battle.kt index 04a7aa9cf5..f94a7aaff0 100644 --- a/core/src/com/unciv/logic/battle/Battle.kt +++ b/core/src/com/unciv/logic/battle/Battle.kt @@ -106,20 +106,6 @@ object Battle { bonusUniques.addAll(civUnit.unit.getMatchingUniques(bonusUniquePlaceholderText)) } - // As of 3.11.5 This is to be deprecated and converted to "Earn [100]% of [Barbarian] opponent's [Strength] as [Culture] for kills" - keeping it here so that mods with this can still work for now - if (defeatedUnit.unit.civInfo.isBarbarian() && civUnit.getCivInfo().hasUnique("Gain Culture when you kill a barbarian unit")) { - cultureReward += unitStr - } - - // As of 3.11.5 This is to be deprecated and converted to "Earn [100]% of [military] opponent's [Strength] as [Culture] for kills" - keeping it here so that mods with this can still work for now - if (civUnit.getCivInfo().hasUnique("Gains culture from each enemy unit killed")) { - cultureReward += unitStr - } - - // As of 3.11.5 This is to be deprecated and converted to "Earn [10]% of [military] opponent's [Cost] as [Gold] for kills" - keeping it here so that mods with this can still work for now - if (civUnit.getCivInfo().hasUnique("Gain gold for each unit killed")) { - goldReward += (unitCost.toFloat() * 0.10).toInt() - } for (unique in bonusUniques) { if (!defeatedUnit.matchesCategory(unique.params[1])) continue @@ -267,13 +253,12 @@ object Battle { // XP! private fun addXp(thisCombatant:ICombatant, amount:Int, otherCombatant:ICombatant){ if(thisCombatant !is MapUnitCombatant) return - if(thisCombatant.unit.promotions.totalXpProduced() >= thisCombatant.unit.civInfo.gameInfo.ruleSet.modOptions.maxXPfromBarbarians && otherCombatant.getCivInfo().isBarbarian()) + if(thisCombatant.unit.promotions.totalXpProduced() >= thisCombatant.unit.civInfo.gameInfo.ruleSet.modOptions.maxXPfromBarbarians + && otherCombatant.getCivInfo().isBarbarian()) return var XPModifier = 1f if (thisCombatant.getCivInfo().hasUnique("Military units gain 50% more Experience from combat")) XPModifier += 0.5f - if (thisCombatant.unit.hasUnique("50% Bonus XP gain")) XPModifier += 0.5f // As of 3.10.10 This is to be deprecated and converted to "[50]% Bonus XP gain" - keeping it here to that mods with this can still work for now - for (unique in thisCombatant.unit.getMatchingUniques("[]% Bonus XP gain")) XPModifier += unique.params[0].toFloat() / 100 @@ -289,9 +274,6 @@ object Battle { if (unique.params[0] == Constants.greatGeneral) greatGeneralPointsModifier += unique.params[1].toFloat() / 100 - if (thisCombatant.unit.hasUnique("Combat very likely to create Great Generals")) // As of 3.10.10 This is to be deprecated and converted to "[Great General] is earned []% faster" - keeping it here to that mods with this can still work for now - greatGeneralPointsModifier += 1f - val greatGeneralPointsGained = (XPGained * greatGeneralPointsModifier).toInt() thisCombatant.getCivInfo().greatPeople.greatGeneralPoints += greatGeneralPointsGained } diff --git a/core/src/com/unciv/logic/battle/BattleDamage.kt b/core/src/com/unciv/logic/battle/BattleDamage.kt index 457d1b9947..8a96533968 100644 --- a/core/src/com/unciv/logic/battle/BattleDamage.kt +++ b/core/src/com/unciv/logic/battle/BattleDamage.kt @@ -68,10 +68,6 @@ object BattleDamage { if (civHappiness < 0) modifiers["Unhappiness"] = max(2 * civHappiness, -90) // otherwise it could exceed -100% and start healing enemy units... - // As of 3.11.0 This is to be deprecated and converted to "[Wounded] units deal +[25]% damage" - keeping it here so that mods with this can still work for now - if (civInfo.hasUnique("Wounded military units deal +25% damage") && combatant.getHealth() < 100) { - modifiers["Wounded unit"] = 25 - } for (unique in civInfo.getMatchingUniques("[] units deal +[]% damage")) { if (combatant.matchesCategory(unique.params[0])) { modifiers.add(unique.params[0], unique.params[1].toInt()) @@ -121,12 +117,6 @@ object BattleDamage { if (attacker is MapUnitCombatant) { modifiers.add(getTileSpecificModifiers(attacker, defender.getTile())) - // As of 3.11.3 This is to be deprecated and converted to "+[]% Strength when attacking" - keeping it here to that mods with this can still work for now - for (ability in attacker.unit.getUniques()) { - if (ability.placeholderText == "Bonus as Attacker []%") - modifiers.add("Attacker Bonus", ability.params[0].toInt()) - } - for(unique in attacker.unit.getMatchingUniques("+[]% Strength when attacking")) { modifiers.add("Attacker Bonus", unique.params[0].toInt()) } @@ -192,10 +182,6 @@ object BattleDamage { if (defenceVsRanged > 0) modifiers["defence vs ranged"] = defenceVsRanged } - // As of 3.11.2 This is to be deprecated and converted to "+[25]% Strength when defending" - keeping it here to that mods with this can still work for now - val carrierDefenceBonus = 25 * defender.unit.getUniques().count { it.text == "+25% Combat Bonus when defending" } - if (carrierDefenceBonus > 0) modifiers["Defender Bonus"] = carrierDefenceBonus - for(unique in defender.unit.getMatchingUniques("+[]% Strength when defending")) { modifiers.add("Defender Bonus", unique.params[0].toInt()) } @@ -215,14 +201,6 @@ object BattleDamage { private fun getTileSpecificModifiers(unit: MapUnitCombatant, tile: TileInfo): Counter { val modifiers = Counter() - // As of 3.11.0 This is to be deprecated and converted to "+[15]% combat bonus for units fighting in [Friendly Land]" - keeping it here to that mods with this can still work for now - // Civ 5 does not use "Himeji Castle" - if (tile.isFriendlyTerritory(unit.getCivInfo()) && unit.getCivInfo().hasUnique("+15% combat strength for units fighting in friendly territory")) - modifiers.add("Friendly Land", 15) - - // As of 3.11.0 This is to be deprecated and converted to "+[20]% combat bonus in [Foreign Land]" - keeping it here to that mods with this can still work for now - if (!tile.isFriendlyTerritory(unit.getCivInfo()) && unit.unit.hasUnique("+20% bonus outside friendly territory")) - modifiers.add("Foreign Land", 20) for (unique in unit.unit.getMatchingUniques("+[]% combat bonus in []") + unit.getCivInfo().getMatchingUniques("+[]% combat bonus for units fighting in []")) { @@ -233,15 +211,6 @@ object BattleDamage { modifiers.add(filter, unique.params[0].toInt()) } - // As of 3.10.6 This is to be deprecated and converted to "+[]% combat bonus in []" - keeping it here to that mods with this can still work for now - if (unit.unit.hasUnique("+25% bonus in Snow, Tundra and Hills") && - (tile.baseTerrain == Constants.snow - || tile.baseTerrain == Constants.tundra - || tile.isHill()) && - // except when there is a vegetation - (tile.terrainFeature != Constants.forest - || tile.terrainFeature != Constants.jungle)) - modifiers[tile.baseTerrain] = 25 for (unique in unit.getCivInfo().getMatchingUniques("+[]% Strength if within [] tiles of a []")) { if (tile.getTilesInDistance(unique.params[1].toInt()).any { it.matchesUniqueFilter(unique.params[2]) }) @@ -252,10 +221,6 @@ object BattleDamage { .any { it.hasUnique("-10% combat strength for adjacent enemy units") && it.civInfo.isAtWarWith(unit.getCivInfo()) }) modifiers["Haka War Dance"] = -10 - // As of 3.10.6 This is to be deprecated and converted to "+[]% combat bonus in []" - keeping it here to that mods with this can still work for now - if (unit.unit.hasUnique("+33% combat bonus in Forest/Jungle") - && (tile.terrainFeature == Constants.forest || tile.terrainFeature == Constants.jungle)) - modifiers[tile.terrainFeature!!] = 33 val isRoughTerrain = tile.isRoughTerrain() for (BDM in getBattleDamageModifiersOfUnit(unit.unit)) { diff --git a/core/src/com/unciv/logic/city/CityConstructions.kt b/core/src/com/unciv/logic/city/CityConstructions.kt index a71fbbe5ea..253fbda8d8 100644 --- a/core/src/com/unciv/logic/city/CityConstructions.kt +++ b/core/src/com/unciv/logic/city/CityConstructions.kt @@ -74,8 +74,6 @@ class CityConstructions { "[] once [] is discovered" -> if (cityInfo.civInfo.tech.isResearched(unique.params[1])) stats.add(unique.stats) } - // This is to be deprecated and converted to "[stats] Per [N] Population in this city" - keeping it here to that mods with this can still work for now - stats.science += (builtBuildingUniqueMap.getAllUniques().count { it.text == "+1 Science Per 2 Population" } * cityInfo.population.population / 2).toFloat() return stats } diff --git a/core/src/com/unciv/logic/city/CityStats.kt b/core/src/com/unciv/logic/city/CityStats.kt index 95680aa08e..869d80840c 100644 --- a/core/src/com/unciv/logic/city/CityStats.kt +++ b/core/src/com/unciv/logic/city/CityStats.kt @@ -306,16 +306,6 @@ 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 - if (cityInfo.civInfo.hasUnique("Increases production of spaceship parts by 25%")) - stats.production += 25 - if (cityInfo.containsBuildingUnique("Increases production of spaceship parts by 50%")) - 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 @@ -380,7 +370,7 @@ class CityStats { fun constructionMatchesFilter(construction:IConstruction, filter:String): Boolean { return construction.name == filter - // All of these are deprecated as of 3.11.20 + // All of these are deprecated as of 3.11.20 in favor of "+[]% Production when constructing [] units" || filter == "land units" && construction is BaseUnit && construction.unitType.isLandUnit() || filter == "naval units" && construction is BaseUnit && construction.unitType.isWaterUnit() || filter == "ranged units" && construction is BaseUnit && construction.unitType == UnitType.Ranged diff --git a/core/src/com/unciv/logic/city/PopulationManager.kt b/core/src/com/unciv/logic/city/PopulationManager.kt index fcd83ea0f7..a5a497f839 100644 --- a/core/src/com/unciv/logic/city/PopulationManager.kt +++ b/core/src/com/unciv/logic/city/PopulationManager.kt @@ -17,9 +17,6 @@ class PopulationManager { var population = 1 var foodStored = 0 - @Deprecated("As of 3.10.14, changed to Counter to accommodate dynamic specialist types. Use specialistAllocations instead.") - val specialists = Stats() - // In favor of this bad boy val specialistAllocations = Counter() diff --git a/core/src/com/unciv/logic/map/TileInfo.kt b/core/src/com/unciv/logic/map/TileInfo.kt index 83cf7eaee9..da56295920 100644 --- a/core/src/com/unciv/logic/map/TileInfo.kt +++ b/core/src/com/unciv/logic/map/TileInfo.kt @@ -246,10 +246,6 @@ open class TileInfo { if (hasViewableResource(observingCiv) && getTileResource().improvement == improvement.name) stats.add(getTileResource().improvementStats!!.clone()) // resource-specific improvement - // As of 3.10.5 This is to be deprecated and converted to "[stats] once [tech] is discovered" - keeping it here to that mods with this can still work for now - if (improvement.improvingTech != null && observingCiv.tech.isResearched(improvement.improvingTech!!)) - stats.add(improvement.improvingTechStats!!) // eg Chemistry for mines - for (unique in improvement.uniqueObjects) if (unique.placeholderText == "[] once [] is discovered" && observingCiv.tech.isResearched(unique.params[1])) stats.add(unique.stats) diff --git a/core/src/com/unciv/models/ruleset/Building.kt b/core/src/com/unciv/models/ruleset/Building.kt index cfa4bbf092..6f50330f7a 100644 --- a/core/src/com/unciv/models/ruleset/Building.kt +++ b/core/src/com/unciv/models/ruleset/Building.kt @@ -277,10 +277,6 @@ class Building : NamedStats(), IConstruction { return unique.text "Must be next to river" -> // Deprecated as of 3.10.8 . Use "Must be on [River]" instead if (!cityCenter.isAdjacentToRiver()) return unique.text - "Must not be on plains" -> // Deprecated as of 3.10.8 . Use "Must not be on [Plains]" instead - if (cityCenter.baseTerrain == Constants.plains) return unique.text - "Must not be on hill" -> // Deprecated as of 3.10.8 . Use "Must not be on [Hill]" instead - if (cityCenter.baseTerrain == Constants.hill) return unique.text "Can only be built in coastal cities" -> // Deprecated as of 3.10.8 . Use "Must be next to [Coast]" instead if (!cityCenter.isCoastalTile()) return unique.text "Must border a source of fresh water" -> // Deprecated as of 3.10.8 . Use "Must be next to [Fresh water]" instead diff --git a/core/src/com/unciv/models/ruleset/Difficulty.kt b/core/src/com/unciv/models/ruleset/Difficulty.kt index adbf24f7b8..451c5906e6 100644 --- a/core/src/com/unciv/models/ruleset/Difficulty.kt +++ b/core/src/com/unciv/models/ruleset/Difficulty.kt @@ -25,8 +25,6 @@ class Difficulty: INamed { var aiBuildingMaintenanceModifier:Float = 1f var aiUnitMaintenanceModifier = 1f var aiFreeTechs = ArrayList() - @Deprecated("Deprecated as of 3.10.4. Use aiMajorCivStartingUnits instead") - var aiFreeUnits = ArrayList() var aiMajorCivStartingUnits = ArrayList() var aiCityStateStartingUnits = ArrayList() var aiUnhappinessModifier = 1f @@ -39,7 +37,7 @@ class Difficulty: INamed { startingUnits.add(Constants.settler) startingUnits.add("Warrior") aiCityStateStartingUnits.addAll(startingUnits) - aiMajorCivStartingUnits.addAll(startingUnits + aiFreeUnits) + aiMajorCivStartingUnits.addAll(startingUnits) } } diff --git a/core/src/com/unciv/models/ruleset/tech/Technology.kt b/core/src/com/unciv/models/ruleset/tech/Technology.kt index 609aa87079..201da7bb92 100644 --- a/core/src/com/unciv/models/ruleset/tech/Technology.kt +++ b/core/src/com/unciv/models/ruleset/tech/Technology.kt @@ -37,14 +37,6 @@ class Technology { lineList += impimpString } - val improvedImprovements = ruleset.tileImprovements.values - .filter { it.improvingTech == name }.groupBy { it.improvingTechStats.toString() } - for (improvement in improvedImprovements) { - val impimpString = improvement.value.joinToString { it.name.tr() } + - " {provide" + (if (improvement.value.size == 1) "s" else "") + "} " + improvement.key - lineList += impimpString.tr() - } - val viewingCiv = UncivGame.Current.worldScreen.viewingCiv val enabledUnits = getEnabledUnits(viewingCiv) if (enabledUnits.any { "Will not be displayed in Civilopedia" !in it.uniques}) { diff --git a/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt b/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt index 7d3952f49a..f7735169bb 100644 --- a/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt +++ b/core/src/com/unciv/models/ruleset/tile/TileImprovement.kt @@ -19,10 +19,6 @@ class TileImprovement : NamedStats() { var techRequired: String? = null - @Deprecated("Deprecated as of 3.10.5. Use [stats] once [tech] is discovered unique instead") - var improvingTech: String? = null - @Deprecated("Deprecated as of 3.10.5. Use [stats] once [tech] is discovered unique instead") - var improvingTechStats: Stats? = null var uniqueTo:String? = null var uniques = ArrayList() val uniqueObjects:List by lazy { uniques.map { Unique(it) } } @@ -44,10 +40,6 @@ class TileImprovement : NamedStats() { val stringBuilder = StringBuilder() val statsDesc = this.clone().toString() if (statsDesc.isNotEmpty()) stringBuilder.appendln(statsDesc) - if (improvingTech != null && improvingTechStats != null) { - val improveStatsDesc = improvingTechStats.toString() - if (improveStatsDesc.isNotEmpty()) stringBuilder.appendln("[$improveStatsDesc] with [${improvingTech!!}]".tr()) - } if (uniqueTo!=null && !forPickerScreen) stringBuilder.appendln("Unique to [$uniqueTo]".tr()) if (!terrainsCanBeBuiltOn.isEmpty()) { val terrainsCanBeBuiltOnString: ArrayList = arrayListOf() diff --git a/core/src/com/unciv/ui/pickerscreens/TechButton.kt b/core/src/com/unciv/ui/pickerscreens/TechButton.kt index 9d684bfc3b..ef14242050 100644 --- a/core/src/com/unciv/ui/pickerscreens/TechButton.kt +++ b/core/src/com/unciv/ui/pickerscreens/TechButton.kt @@ -64,7 +64,6 @@ class TechButton(techName:String, private val techManager: TechManager, isWorldS for (improvement in ruleset.tileImprovements.values .filter { it.techRequired == techName || it.uniqueObjects.any { u -> u.params.contains(techName) } - || it.improvingTech == techName || it.uniqueObjects.any { it.placeholderText=="[] once [] is discovered" && it.params[1]==techName } } .filter { it.uniqueTo==null || it.uniqueTo==civName }) if (improvement.name.startsWith("Remove")) diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt index 1f5ab8e982..8ad3c03a99 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt @@ -312,17 +312,6 @@ object UnitActions { unit.destroy() }.takeIf { unit.currentTile.getOwner() != null && unit.currentTile.getOwner() == unit.civInfo }) } - // As of 3.10.7 This is to be deprecated and converted to "Can start an []-turn golden age" - keeping it here to that mods with this can still work for now - "Can start an 8-turn golden age" -> { - actionList += UnitAction( - type = UnitActionType.StartGoldenAge, - uncivSound = UncivSound.Chimes, - action = { - unit.civInfo.goldenAges.enterGoldenAge(8) - addGoldPerGreatPersonUsage(unit.civInfo) - unit.destroy() - }.takeIf { unit.currentTile.getOwner() != null && unit.currentTile.getOwner() == unit.civInfo }) - } "Can speed up construction of a wonder" -> { val canHurryWonder = if (!tile.isCityCenter()) false else {