mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-16 18:59:15 +07:00
Deprecation of old unique formats in favor of newer, more generalized ones
This commit is contained in:
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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<String> {
|
||||
val modifiers = Counter<String>()
|
||||
|
||||
// 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)) {
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -17,9 +17,6 @@ class PopulationManager {
|
||||
var population = 1
|
||||
var foodStored = 0
|
||||
|
||||
@Deprecated("As of 3.10.14, changed to Counter<String> to accommodate dynamic specialist types. Use specialistAllocations instead.")
|
||||
val specialists = Stats()
|
||||
|
||||
// In favor of this bad boy
|
||||
val specialistAllocations = Counter<String>()
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -25,8 +25,6 @@ class Difficulty: INamed {
|
||||
var aiBuildingMaintenanceModifier:Float = 1f
|
||||
var aiUnitMaintenanceModifier = 1f
|
||||
var aiFreeTechs = ArrayList<String>()
|
||||
@Deprecated("Deprecated as of 3.10.4. Use aiMajorCivStartingUnits instead")
|
||||
var aiFreeUnits = ArrayList<String>()
|
||||
var aiMajorCivStartingUnits = ArrayList<String>()
|
||||
var aiCityStateStartingUnits = ArrayList<String>()
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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}) {
|
||||
|
@ -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<String>()
|
||||
val uniqueObjects:List<Unique> 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<String> = arrayListOf()
|
||||
|
@ -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"))
|
||||
|
@ -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 {
|
||||
|
Reference in New Issue
Block a user