Pre-solved potential bugs, unique typing for deprecated uniques

This commit is contained in:
yairm210 2021-11-14 00:16:01 +02:00
parent 297c3d8ba6
commit f3115d9f03
6 changed files with 15 additions and 10 deletions

View File

@ -70,11 +70,7 @@ object BackwardCompatibility {
if (!ruleSet.technologies.containsKey(tech)) if (!ruleSet.technologies.containsKey(tech))
civInfo.tech.techsResearched.remove(tech) civInfo.tech.techsResearched.remove(tech)
for (policy in civInfo.policies.adoptedPolicies.toList()) for (policy in civInfo.policies.adoptedPolicies.toList())
if (!ruleSet.policies.containsKey(policy) if (!ruleSet.policies.containsKey(policy))
// Conversion code for deprecated policies since 3.16.15
&& !(policy == "Patronage " || policy == "Patronage Complete")
//
)
civInfo.policies.adoptedPolicies.remove(policy) civInfo.policies.adoptedPolicies.remove(policy)
} }
} }

View File

@ -37,7 +37,7 @@ object Battle {
/** Alternatively, maybe we DID reach that tile, but it turned out to be a hill or something, /** Alternatively, maybe we DID reach that tile, but it turned out to be a hill or something,
* so we expended all of our movement points! * so we expended all of our movement points!
*/ */
if (attacker.unit.currentMovement != attackableTile.movementLeftAfterMovingToAttackTile) if (attacker.unit.currentMovement == 0f)
return return
if (attacker.unit.hasUnique(UniqueType.MustSetUp) && !attacker.unit.isSetUpForSiege()) { if (attacker.unit.hasUnique(UniqueType.MustSetUp) && !attacker.unit.isSetUpForSiege()) {
attacker.unit.action = UnitActionType.SetUp.value attacker.unit.action = UnitActionType.SetUp.value

View File

@ -614,11 +614,11 @@ class CityStats(val cityInfo: CityInfo) {
var foodEatenBySpecialists = 2f * cityInfo.population.getNumberOfSpecialists() var foodEatenBySpecialists = 2f * cityInfo.population.getNumberOfSpecialists()
// Deprecated since 3.16.11 // Deprecated since 3.16.11
for (unique in cityInfo.civInfo.getMatchingUniques("-[]% food consumption by specialists")) for (unique in cityInfo.civInfo.getMatchingUniques(UniqueType.FoodConsumptionBySpecialistsDeprecated))
foodEatenBySpecialists *= 1f - unique.params[0].toFloat() / 100f foodEatenBySpecialists *= 1f - unique.params[0].toFloat() / 100f
// //
for (unique in cityInfo.getMatchingUniques("[]% food consumption by specialists []")) for (unique in cityInfo.getMatchingUniques(UniqueType.FoodConsumptionBySpecialists))
if (cityInfo.matchesFilter(unique.params[1])) if (cityInfo.matchesFilter(unique.params[1]))
foodEatenBySpecialists *= unique.params[0].toPercent() foodEatenBySpecialists *= unique.params[0].toPercent()

View File

@ -182,7 +182,7 @@ class CivInfoStats(val civInfo: CivilizationInfo) {
} }
// Deprecated since 3.16.15 // Deprecated since 3.16.15
if (civInfo.hasUnique("50% of excess happiness added to culture towards policies")) { if (civInfo.hasUnique(UniqueType.ExcessHappinessToCultureDeprecated)) {
val happiness = civInfo.getHappiness() val happiness = civInfo.getHappiness()
if (happiness > 0) statMap.add("Policies", Stats(culture = happiness / 2f)) if (happiness > 0) statMap.add("Policies", Stats(culture = happiness / 2f))
} }

View File

@ -155,6 +155,15 @@ enum class UniqueType(val text:String, vararg targets: UniqueTarget, val flags:
FreeExtraBeliefs("May choose [amount] additional [beliefType] beliefs when [foundingOrEnhancing] a religion", UniqueTarget.Global), FreeExtraBeliefs("May choose [amount] additional [beliefType] beliefs when [foundingOrEnhancing] a religion", UniqueTarget.Global),
FreeExtraAnyBeliefs("May choose [amount] additional belief(s) of any type when [foundingOrEnhancing] a religion", UniqueTarget.Global), FreeExtraAnyBeliefs("May choose [amount] additional belief(s) of any type when [foundingOrEnhancing] a religion", UniqueTarget.Global),
FoodConsumptionBySpecialists("[amount]% food consumption by specialists [cityFilter]", UniqueTarget.Global),
@Deprecated("As of 3.18.2", ReplaceWith("[-amount]% food consumption by specialists [cityFilter]"), DeprecationLevel.WARNING)
FoodConsumptionBySpecialistsDeprecated("-[amount]% food consumption by specialists [cityFilter]", UniqueTarget.Global),
ExcessHappinessToGlobalStat("[amount]% of excess happiness converted to [stat]", UniqueTarget.Global),
@Deprecated("As of 3.18.2", ReplaceWith("[50]% of excess happiness converted to [Culture]"), DeprecationLevel.WARNING)
ExcessHappinessToCultureDeprecated("50% of excess happiness added to culture towards policies", UniqueTarget.Global),
// There is potential to merge these // There is potential to merge these
BuyUnitsIncreasingCost("May buy [baseUnitFilter] units for [amount] [stat] [cityFilter] at an increasing price ([amount])", UniqueTarget.Global), BuyUnitsIncreasingCost("May buy [baseUnitFilter] units for [amount] [stat] [cityFilter] at an increasing price ([amount])", UniqueTarget.Global),
BuyBuildingsIncreasingCost("May buy [buildingFilter] buildings for [amount] [stat] [cityFilter] at an increasing price ([amount])", UniqueTarget.Global), BuyBuildingsIncreasingCost("May buy [buildingFilter] buildings for [amount] [stat] [cityFilter] at an increasing price ([amount])", UniqueTarget.Global),

View File

@ -22,8 +22,8 @@ object TileSetCache : HashMap<String, TileSetConfig>() {
val mods = mutableListOf("") val mods = mutableListOf("")
if (UncivGame.isCurrentInitialized()) { if (UncivGame.isCurrentInitialized()) {
mods.addAll(UncivGame.Current.settings.visualMods) mods.addAll(UncivGame.Current.settings.visualMods)
mods.addAll(ruleSetMods)
} }
mods.addAll(ruleSetMods)
clear() clear()
for (mod in mods.distinct()) { for (mod in mods.distinct()) {
val entry = allConfigs.entries.firstOrNull { it.key.mod == mod } ?: continue val entry = allConfigs.entries.firstOrNull { it.key.mod == mod } ?: continue