mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-09 15:29:32 +07:00
Ease of deprecation, brought to you by unique types!
*Visible*, locatable deprecated uniques! Stated replacement uniques!
This commit is contained in:
@ -337,7 +337,8 @@
|
||||
"outerColor": [150,150,150],
|
||||
"innerColor": [60,60,60],
|
||||
"uniqueName": "Furor Teutonicus",
|
||||
"uniques": ["67% chance to earn 25 Gold and recruit a Barbarian unit from a conquered encampment", "-[25]% [Land] unit maintenance costs"],
|
||||
"uniques": ["67% chance to earn 25 Gold and recruit a Barbarian unit from a conquered encampment",
|
||||
"[-25]% maintenance costs for [Land] units"],
|
||||
"cities": ["Berlin","Hamburg","Munich","Cologne","Frankfurt","Essen","Dortmund","Stuttgart","Düsseldorf","Bremen",
|
||||
"Hannover","Duisburg","Leipzig","Dresden","Bonn","Bochum","Bielefeld","Karlsruhe","Gelsenkirchen","Wiesbaden",
|
||||
"Münster","Rostock","Chemnitz","Braunschweig","Halle","Mönchengladbach","Kiel","Wuppertal","Freiburg","Hagen",
|
||||
@ -366,7 +367,8 @@
|
||||
"outerColor": [245,248,185],
|
||||
"innerColor": [18,84,30],
|
||||
"uniqueName": "Barbary Corsairs",
|
||||
"uniques": ["-[66]% [Water] unit maintenance costs", "50% chance of capturing defeated Barbarian naval units and earning 25 Gold"],
|
||||
"uniques": ["[-66]% maintenance costs for [Water] units",
|
||||
"50% chance of capturing defeated Barbarian naval units and earning 25 Gold"],
|
||||
"cities": ["Istanbul","Edirne","Ankara","Bursa","Konya","Samsun","Gaziantep","Diyarbakır","Izmir","Kayseri","Malatya",
|
||||
"Mersin","Antalya","Zonguldak","Denizli","Ordu","Muğla","Eskişehir","Inebolu","Sinop","Adana","Artvin",
|
||||
"Bodrum","Eregli","Silifke","Sivas","Amasya","Marmaris","Trabzon","Erzurum","Urfa","Izmit","Afyonkarahisar",
|
||||
|
@ -367,7 +367,7 @@
|
||||
{
|
||||
"name": "Autocracy",
|
||||
"era": "Industrial era",
|
||||
"uniques": ["-[33]% unit upkeep costs", "Upon capturing a city, receive [10] times its [Culture] production as [Culture] immediately",
|
||||
"uniques": ["[-33]% maintenance costs for [All] units", "Upon capturing a city, receive [10] times its [Culture] production as [Culture] immediately",
|
||||
"Incompatible with [Order]", "Incompatible with [Freedom]"],
|
||||
"policies": [
|
||||
{
|
||||
|
@ -37,8 +37,7 @@ class CivInfoStats(val civInfo: CivilizationInfo) {
|
||||
|
||||
var numberOfUnitsToPayFor = max(0f, unitsToPayFor.count().toFloat() - freeUnits)
|
||||
|
||||
|
||||
for (unique in civInfo.getMatchingUniques("-[]% [] unit maintenance costs")) {
|
||||
for (unique in civInfo.getMatchingUniquesByEnum(UniqueType.UnitMaintenanceDiscount)) {
|
||||
val numberOfUnitsWithDiscount = min(
|
||||
numberOfUnitsToPayFor,
|
||||
unitsToPayFor.count { it.matchesFilter(unique.params[1]) }.toFloat()
|
||||
@ -46,6 +45,17 @@ class CivInfoStats(val civInfo: CivilizationInfo) {
|
||||
numberOfUnitsToPayFor -= numberOfUnitsWithDiscount * unique.params[0].toFloat() / 100f
|
||||
}
|
||||
|
||||
for (unique in civInfo.getMatchingUniquesByEnum(UniqueType.DecreasedUnitMaintenanceCostsByFilter)) {
|
||||
val numberOfUnitsWithDiscount = min(
|
||||
numberOfUnitsToPayFor,
|
||||
unitsToPayFor.count { it.matchesFilter(unique.params[1]) }.toFloat()
|
||||
)
|
||||
numberOfUnitsToPayFor -= numberOfUnitsWithDiscount * unique.params[0].toFloat() / 100f
|
||||
}
|
||||
for (unique in civInfo.getMatchingUniquesByEnum(UniqueType.DecreasedUnitMaintenanceCostsGlobally)) {
|
||||
numberOfUnitsToPayFor *= 1f - unique.params[0].toFloat() / 100f
|
||||
}
|
||||
|
||||
val turnLimit =
|
||||
BASE_GAME_DURATION_TURNS * civInfo.gameInfo.gameParameters.gameSpeed.modifier
|
||||
val gameProgress =
|
||||
@ -55,9 +65,6 @@ class CivInfoStats(val civInfo: CivilizationInfo) {
|
||||
if (!civInfo.isPlayerCivilization())
|
||||
cost *= civInfo.gameInfo.getDifficulty().aiUnitMaintenanceModifier
|
||||
|
||||
for (unique in civInfo.getMatchingUniques("-[]% unit upkeep costs")) {
|
||||
cost *= 1f - unique.params[0].toFloat() / 100f
|
||||
}
|
||||
|
||||
return cost.toInt()
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import com.unciv.models.translations.getPlaceholderText
|
||||
// Eventually we'll merge the translation generation to take this as the source of that
|
||||
enum class UniqueParameterType(val parameterName:String) {
|
||||
Number("amount") {
|
||||
override fun getErrorType(parameterText: String, ruleset: Ruleset):
|
||||
override fun getErrorSeverity(parameterText: String, ruleset: Ruleset):
|
||||
UniqueType.UniqueComplianceErrorSeverity? {
|
||||
return if (parameterText.toIntOrNull() == null) UniqueType.UniqueComplianceErrorSeverity.RulesetInvariant
|
||||
else null
|
||||
@ -17,18 +17,18 @@ enum class UniqueParameterType(val parameterName:String) {
|
||||
},
|
||||
MapUnitFilter("mapUnitFilter"){
|
||||
val knownValues = setOf("Wounded", "Barbarians", "City-State", "Embarked", "Non-City")
|
||||
override fun getErrorType(parameterText: String, ruleset: Ruleset):
|
||||
override fun getErrorSeverity(parameterText: String, ruleset: Ruleset):
|
||||
UniqueType.UniqueComplianceErrorSeverity? {
|
||||
if (parameterText in knownValues) return null
|
||||
return BaseUnitFilter.getErrorType(parameterText, ruleset)
|
||||
return BaseUnitFilter.getErrorSeverity(parameterText, ruleset)
|
||||
}
|
||||
},
|
||||
BaseUnitFilter("baseUnitFilter"){
|
||||
// As you can see there is a difference between these and what's in unitTypeStrings (for translation) -
|
||||
// the goal is to unify, but for now this is the "real" list
|
||||
val knownValues = setOf("Melee", "Ranged", "Civilian", "Military", "Land", "Water", "Air",
|
||||
val knownValues = setOf("All", "Melee", "Ranged", "Civilian", "Military", "Land", "Water", "Air",
|
||||
"non-air", "Nuclear Weapon", "Great Person", "Religious")
|
||||
override fun getErrorType(parameterText: String, ruleset: Ruleset):
|
||||
override fun getErrorSeverity(parameterText: String, ruleset: Ruleset):
|
||||
UniqueType.UniqueComplianceErrorSeverity? {
|
||||
if (parameterText in knownValues) return null
|
||||
if (ruleset.unitTypes.containsKey(parameterText)) return null
|
||||
@ -41,13 +41,13 @@ enum class UniqueParameterType(val parameterName:String) {
|
||||
}
|
||||
},
|
||||
Unknown("param") {
|
||||
override fun getErrorType(parameterText: String, ruleset: Ruleset):
|
||||
override fun getErrorSeverity(parameterText: String, ruleset: Ruleset):
|
||||
UniqueType.UniqueComplianceErrorSeverity? {
|
||||
return null
|
||||
}
|
||||
};
|
||||
|
||||
abstract fun getErrorType(parameterText:String, ruleset: Ruleset): UniqueType.UniqueComplianceErrorSeverity?
|
||||
abstract fun getErrorSeverity(parameterText:String, ruleset: Ruleset): UniqueType.UniqueComplianceErrorSeverity?
|
||||
|
||||
companion object {
|
||||
val unitTypeStrings = hashSetOf(
|
||||
@ -76,10 +76,16 @@ class UniqueComplianceError(
|
||||
)
|
||||
|
||||
|
||||
enum class UniqueType(val text:String) {
|
||||
enum class UniqueType(val text:String, val replacedBy: UniqueType? = null) {
|
||||
|
||||
ConsumesResources("Consumes [amount] [resource]"),
|
||||
FreeUnits("[amount] units cost no maintenance");
|
||||
FreeUnits("[amount] units cost no maintenance"),
|
||||
UnitMaintenanceDiscount("[amount]% maintenance costs for [mapUnitFilter] units"),
|
||||
@Deprecated("As of 3.16.16")
|
||||
DecreasedUnitMaintenanceCostsByFilter("-[amount]% [mapUnitFilter] unit maintenance costs", UnitMaintenanceDiscount),
|
||||
@Deprecated("As of 3.16.16")
|
||||
DecreasedUnitMaintenanceCostsGlobally("-[amount]% unit upkeep costs", UnitMaintenanceDiscount),
|
||||
;
|
||||
|
||||
/** For uniques that have "special" parameters that can accept multiple types, we can override them manually
|
||||
* For 95% of cases, auto-matching is fine. */
|
||||
@ -118,7 +124,7 @@ enum class UniqueType(val text:String) {
|
||||
for ((index, param) in unique.params.withIndex()) {
|
||||
val acceptableParamTypes = parameterTypeMap[index]
|
||||
val errorTypesForAcceptableParameters =
|
||||
acceptableParamTypes.map { it.getErrorType(param, ruleset) }
|
||||
acceptableParamTypes.map { it.getErrorSeverity(param, ruleset) }
|
||||
if (errorTypesForAcceptableParameters.any { it == null }) continue // This matches one of the types!
|
||||
val leastSevereWarning =
|
||||
errorTypesForAcceptableParameters.maxByOrNull { it!!.ordinal }!!
|
||||
|
Reference in New Issue
Block a user