From 2cac1622c9d47fe91f315b92c9157fe433377e8b Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Thu, 28 Jan 2021 10:23:32 +0200 Subject: [PATCH] Deprecation of old uniques --- core/src/com/unciv/logic/city/CityStats.kt | 20 ------------------- .../unciv/logic/civilization/CivInfoStats.kt | 5 ----- .../unciv/logic/map/UnitMovementAlgorithms.kt | 6 +++--- .../com/unciv/models/ruleset/unit/BaseUnit.kt | 16 +++++---------- 4 files changed, 8 insertions(+), 39 deletions(-) diff --git a/core/src/com/unciv/logic/city/CityStats.kt b/core/src/com/unciv/logic/city/CityStats.kt index 7af4bc0c8c..939726f607 100644 --- a/core/src/com/unciv/logic/city/CityStats.kt +++ b/core/src/com/unciv/logic/city/CityStats.kt @@ -170,13 +170,6 @@ class CityStats { fun getGrowthBonusFromPoliciesAndWonders(): Float { var bonus = 0f - - // This is to be deprecated and converted to "+[]% growth in all cities" and "+[]% growth in capital" - keeping it here to that mods with this can still work for now - if (cityInfo.civInfo.hasUnique("+10% food growth in capital") && cityInfo.isCapital()) - bonus += 10f - if (cityInfo.civInfo.hasUnique("+15% growth in all cities")) - bonus += 15f - for (unique in cityInfo.civInfo.getMatchingUniques("+[]% growth in all cities")) bonus += unique.params[0].toFloat() if (cityInfo.isCapital()) for (unique in cityInfo.civInfo.getMatchingUniques("+[]% growth in capital")) @@ -296,19 +289,6 @@ class CityStats { private fun getStatPercentBonusesFromBuildings(currentConstruction: IConstruction): Stats { val stats = cityInfo.cityConstructions.getStatPercentBonuses() - // 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")) - stats.production += 15 - if (currentConstruction.unitType.isLandUnit() - && cityInfo.containsBuildingUnique("+15% production of land units")) - stats.production += 15 - if (currentConstruction.unitType.isWaterUnit() - && cityInfo.containsBuildingUnique("+15% production of naval units")) - stats.production += 15 - } - for (unique in cityInfo.cityConstructions.builtBuildingUniqueMap.getUniques("+[]% production when building [] in this city")) { if (constructionMatchesFilter(currentConstruction, unique.params[1])) stats.production += unique.params[0].toInt() diff --git a/core/src/com/unciv/logic/civilization/CivInfoStats.kt b/core/src/com/unciv/logic/civilization/CivInfoStats.kt index 6291ba38d0..259e7c46ae 100644 --- a/core/src/com/unciv/logic/civilization/CivInfoStats.kt +++ b/core/src/com/unciv/logic/civilization/CivInfoStats.kt @@ -27,11 +27,6 @@ class CivInfoStats(val civInfo: CivilizationInfo){ var numberOfUnitsToPayFor = max(0f, unitsToPayFor.count().toFloat() - freeUnits) - // Deprecated and generalized as of 3.11.20 - here for mod transition period - if (civInfo.hasUnique("-25% land units maintenance")) { - val numberOfUnitsWithDiscount = min(numberOfUnitsToPayFor, unitsToPayFor.count { it.type.isLandUnit() }.toFloat()) - numberOfUnitsToPayFor -= 0.25f * numberOfUnitsWithDiscount - } for (unique in civInfo.getMatchingUniques("-[]% [] unit maintenance costs")) { val numberOfUnitsWithDiscount = min(numberOfUnitsToPayFor, unitsToPayFor.count { it.matchesFilter(unique.params[1]) }.toFloat()) diff --git a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt index 94f14c98bb..64408cff83 100644 --- a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt +++ b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt @@ -58,11 +58,11 @@ class UnitMovementAlgorithms(val unit:MapUnit) { class ParentTileAndTotalDistance(val parentTile: TileInfo, val totalDistance: Float) - val MOVEMENT_TESTING = UncivGame.Current.settings.unitMovementIncludesImpassibles - fun isUnknownTileWeShouldAssumeToBePassable(tileInfo: TileInfo) = MOVEMENT_TESTING && !unit.civInfo.exploredTiles.contains(tileInfo.position) + fun isUnknownTileWeShouldAssumeToBePassable(tileInfo: TileInfo) = UncivGame.Current.settings.unitMovementIncludesImpassibles + && !unit.civInfo.exploredTiles.contains(tileInfo.position) fun getDistanceToTilesWithinTurn(origin: Vector2, unitMovement: Float): PathsToTilesWithinTurn { - if(MOVEMENT_TESTING) return getDistanceToTilesWithinTurnIncludingUnknownImpassibles(origin, unitMovement) + if (UncivGame.Current.settings.unitMovementIncludesImpassibles) return getDistanceToTilesWithinTurnIncludingUnknownImpassibles(origin, unitMovement) val distanceToTiles = PathsToTilesWithinTurn() if (unitMovement == 0f) return distanceToTiles diff --git a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt index 16172b8508..6001328f5e 100644 --- a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt +++ b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt @@ -170,25 +170,24 @@ class BaseUnit : INamed, IConstruction { if (unit == null) return false // couldn't place the unit, so there's actually no unit =( //movement penalty - if (wasBought && !unit.hasUnique("Can move immediately once bought") && !civInfo.gameInfo.gameParameters.godMode) + if (wasBought && !civInfo.gameInfo.gameParameters.godMode && !unit.hasUnique("Can move immediately once bought")) unit.currentMovement = 0f if (this.unitType.isCivilian()) return true // tiny optimization makes save files a few bytes smaller var XP = construction.getBuiltBuildings().sumBy { it.xpForNewUnits } - // As of 3.11.2 This is to be deprecated and converted to "New [] units start with [] Experience" - keeping it here to that mods with this can still work for now - for (unique in civInfo.getMatchingUniques("New military units start with [] Experience")) - XP += unique.params[0].toInt() - for (unique in construction.cityInfo.cityConstructions.builtBuildingUniqueMap.getUniques("New [] units start with [] Experience in this city") + for (unique in construction.cityInfo.cityConstructions.builtBuildingUniqueMap + .getUniques("New [] units start with [] Experience in this city") + civInfo.getMatchingUniques("New [] units start with [] Experience")) { if (unit.matchesFilter(unique.params[0])) XP += unique.params[1].toInt() } unit.promotions.XP = XP - for (unique in construction.cityInfo.cityConstructions.builtBuildingUniqueMap.getUniques("All newly-trained [] units in this city receive the [] promotion")) { + 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] @@ -196,11 +195,6 @@ class BaseUnit : INamed, IConstruction { 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) - return true }