mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-04 07:17:50 +07:00
Removed final vestiges of old Bonus/Penalty effects.
Friendship ended with Regex, now Unique is my best friend.
This commit is contained in:
@ -282,7 +282,7 @@
|
|||||||
"requiredResource": "Horses",
|
"requiredResource": "Horses",
|
||||||
"upgradesTo": "Knight",
|
"upgradesTo": "Knight",
|
||||||
"obsoleteTech": "Metallurgy",
|
"obsoleteTech": "Metallurgy",
|
||||||
"uniques": ["Can move after attacking","No defensive terrain bonus","Penalty vs City 33%" ],
|
"uniques": ["Can move after attacking","No defensive terrain bonus","-[33]% Strength vs [City]" ],
|
||||||
"hurryCostModifier": 20,
|
"hurryCostModifier": 20,
|
||||||
"attackSound": "horse"
|
"attackSound": "horse"
|
||||||
},
|
},
|
||||||
@ -299,7 +299,7 @@
|
|||||||
"obsoleteTech": "Metallurgy",
|
"obsoleteTech": "Metallurgy",
|
||||||
"promotions": ["Great Generals I"],
|
"promotions": ["Great Generals I"],
|
||||||
"requiredResource": "Horses",
|
"requiredResource": "Horses",
|
||||||
"uniques": ["Can move after attacking", "No defensive terrain bonus", "Penalty vs City 33%"],
|
"uniques": ["Can move after attacking", "No defensive terrain bonus", "-[33]% Strength vs [City]"],
|
||||||
"hurryCostModifier": 20,
|
"hurryCostModifier": 20,
|
||||||
"attackSound": "horse"
|
"attackSound": "horse"
|
||||||
},
|
},
|
||||||
@ -461,7 +461,7 @@
|
|||||||
"obsoleteTech": "Military Science",
|
"obsoleteTech": "Military Science",
|
||||||
"upgradesTo": "Cavalry",
|
"upgradesTo": "Cavalry",
|
||||||
"requiredResource": "Horses",
|
"requiredResource": "Horses",
|
||||||
"uniques": ["Can move after attacking","No defensive terrain bonus","Penalty vs City 33%" ],
|
"uniques": ["Can move after attacking","No defensive terrain bonus","-[33]% Strength vs [City]" ],
|
||||||
"attackSound": "horse"
|
"attackSound": "horse"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -509,7 +509,7 @@
|
|||||||
"requiredTech": "Chivalry",
|
"requiredTech": "Chivalry",
|
||||||
"obsoleteTech": "Military Science",
|
"obsoleteTech": "Military Science",
|
||||||
"upgradesTo": "Cavalry",
|
"upgradesTo": "Cavalry",
|
||||||
"uniques": ["Can move after attacking","No defensive terrain bonus","+[50]% Strength vs [Mounted]","Penalty vs City 33%"],
|
"uniques": ["Can move after attacking","No defensive terrain bonus","+[50]% Strength vs [Mounted]","-[33]% Strength vs [City]"],
|
||||||
"attackSound": "shot"
|
"attackSound": "shot"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -795,7 +795,7 @@
|
|||||||
"cost": 185,
|
"cost": 185,
|
||||||
"requiredTech": "Metallurgy",
|
"requiredTech": "Metallurgy",
|
||||||
"requiredResource": "Horses",
|
"requiredResource": "Horses",
|
||||||
"uniques": ["Can move after attacking","No defensive terrain bonus","Penalty vs City 33%"],
|
"uniques": ["Can move after attacking","No defensive terrain bonus","-[33]% Strength vs [City]"],
|
||||||
"promotions": ["Formation I"],
|
"promotions": ["Formation I"],
|
||||||
"upgradesTo": "Anti-Tank Gun",
|
"upgradesTo": "Anti-Tank Gun",
|
||||||
"obsoleteTech": "Combined Arms",
|
"obsoleteTech": "Combined Arms",
|
||||||
@ -811,7 +811,7 @@
|
|||||||
"cost": 185,
|
"cost": 185,
|
||||||
"requiredTech": "Metallurgy",
|
"requiredTech": "Metallurgy",
|
||||||
"requiredResource": "Horses",
|
"requiredResource": "Horses",
|
||||||
"uniques": ["Can move after attacking","No defensive terrain bonus","Penalty vs City 33%",
|
"uniques": ["Can move after attacking","No defensive terrain bonus","-[33]% Strength vs [City]",
|
||||||
"[+1] Visibility Range", "No movement cost to pillage"],
|
"[+1] Visibility Range", "No movement cost to pillage"],
|
||||||
"promotions": ["Formation I"],
|
"promotions": ["Formation I"],
|
||||||
"upgradesTo": "Anti-Tank Gun",
|
"upgradesTo": "Anti-Tank Gun",
|
||||||
@ -881,7 +881,7 @@
|
|||||||
"obsoleteTech": "Combustion",
|
"obsoleteTech": "Combustion",
|
||||||
"requiredResource": "Horses",
|
"requiredResource": "Horses",
|
||||||
"upgradesTo": "Landship",
|
"upgradesTo": "Landship",
|
||||||
"uniques": ["Can move after attacking","No defensive terrain bonus","Penalty vs City 33%" ],
|
"uniques": ["Can move after attacking","No defensive terrain bonus","-[33]% Strength vs [City]" ],
|
||||||
"attackSound": "horse"
|
"attackSound": "horse"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -897,7 +897,7 @@
|
|||||||
"requiredResource": "Horses",
|
"requiredResource": "Horses",
|
||||||
"upgradesTo": "Landship",
|
"upgradesTo": "Landship",
|
||||||
"uniques": ["Can move after attacking","No defensive terrain bonus",
|
"uniques": ["Can move after attacking","No defensive terrain bonus",
|
||||||
"Penalty vs City 33%", "+[50]% Strength vs [wounded units]"],
|
"-[33]% Strength vs [City]", "+[50]% Strength vs [wounded units]"],
|
||||||
"attackSound": "horse"
|
"attackSound": "horse"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,9 @@ object BattleDamage {
|
|||||||
if (enemy.matchesCategory(unique.params[1]))
|
if (enemy.matchesCategory(unique.params[1]))
|
||||||
modifiers.add("vs [${unique.params[1]}]", unique.params[0].toInt())
|
modifiers.add("vs [${unique.params[1]}]", unique.params[0].toInt())
|
||||||
}
|
}
|
||||||
for (unique in combatant.unit.getMatchingUniques("-[]% Strength vs []")) {
|
for (unique in combatant.unit.getMatchingUniques("-[]% Strength vs []")+
|
||||||
|
civInfo.getMatchingUniques("-[]% Strength vs []")
|
||||||
|
) {
|
||||||
if (enemy.matchesCategory(unique.params[1]))
|
if (enemy.matchesCategory(unique.params[1]))
|
||||||
modifiers.add("vs [${unique.params[1]}]", -unique.params[0].toInt())
|
modifiers.add("vs [${unique.params[1]}]", -unique.params[0].toInt())
|
||||||
}
|
}
|
||||||
|
@ -165,11 +165,11 @@ class Nation : INamed {
|
|||||||
if (!unit.getResourceRequirements().containsKey(resource))
|
if (!unit.getResourceRequirements().containsKey(resource))
|
||||||
textList += " " + "[$resource] not required".tr()
|
textList += " " + "[$resource] not required".tr()
|
||||||
for (unique in unit.uniques.filterNot { it in originalUnit.uniques })
|
for (unique in unit.uniques.filterNot { it in originalUnit.uniques })
|
||||||
textList += " " + Translations.translateBonusOrPenalty(unique)
|
textList += " " + unique.tr()
|
||||||
for (unique in originalUnit.uniques.filterNot { it in unit.uniques })
|
for (unique in originalUnit.uniques.filterNot { it in unit.uniques })
|
||||||
textList += " " + "Lost ability".tr() + "(" + "vs [${originalUnit.name}]".tr() + "): " + Translations.translateBonusOrPenalty(unique)
|
textList += " " + "Lost ability".tr() + "(" + "vs [${originalUnit.name}]".tr() + "): " + unique.tr()
|
||||||
for (promotion in unit.promotions.filter { it !in originalUnit.promotions })
|
for (promotion in unit.promotions.filter { it !in originalUnit.promotions })
|
||||||
textList += " " + promotion.tr() + " (" + Translations.translateBonusOrPenalty(ruleset.unitPromotions[promotion]!!.effect) + ")"
|
textList += " " + promotion.tr() + " (" + ruleset.unitPromotions[promotion]!!.effect.tr() + ")"
|
||||||
} else if (unit.replaces != null) {
|
} else if (unit.replaces != null) {
|
||||||
textList += unit.name.tr() + " - " + "Replaces [${unit.replaces}], which is not found in the ruleset!".tr()
|
textList += unit.name.tr() + " - " + "Replaces [${unit.replaces}], which is not found in the ruleset!".tr()
|
||||||
} else {
|
} else {
|
||||||
|
@ -8,8 +8,6 @@ import com.unciv.logic.map.MapUnit
|
|||||||
import com.unciv.models.ruleset.Ruleset
|
import com.unciv.models.ruleset.Ruleset
|
||||||
import com.unciv.models.ruleset.Unique
|
import com.unciv.models.ruleset.Unique
|
||||||
import com.unciv.models.stats.INamed
|
import com.unciv.models.stats.INamed
|
||||||
import com.unciv.models.translations.Translations
|
|
||||||
import com.unciv.models.translations.getPlaceholderText
|
|
||||||
import com.unciv.models.translations.tr
|
import com.unciv.models.translations.tr
|
||||||
import com.unciv.ui.utils.Fonts
|
import com.unciv.ui.utils.Fonts
|
||||||
import kotlin.math.pow
|
import kotlin.math.pow
|
||||||
@ -50,7 +48,7 @@ class BaseUnit : INamed, IConstruction {
|
|||||||
infoList += promotion.tr()
|
infoList += promotion.tr()
|
||||||
if (replacementTextForUniques != "") infoList += replacementTextForUniques
|
if (replacementTextForUniques != "") infoList += replacementTextForUniques
|
||||||
else for (unique in uniques)
|
else for (unique in uniques)
|
||||||
infoList += Translations.translateBonusOrPenalty(unique)
|
infoList += unique.tr()
|
||||||
return infoList.joinToString()
|
return infoList.joinToString()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +74,7 @@ class BaseUnit : INamed, IConstruction {
|
|||||||
|
|
||||||
if (replacementTextForUniques != "") sb.appendLine(replacementTextForUniques)
|
if (replacementTextForUniques != "") sb.appendLine(replacementTextForUniques)
|
||||||
else for (unique in uniques)
|
else for (unique in uniques)
|
||||||
sb.appendLine(Translations.translateBonusOrPenalty(unique))
|
sb.appendLine(unique.tr())
|
||||||
|
|
||||||
if (promotions.isNotEmpty()) {
|
if (promotions.isNotEmpty()) {
|
||||||
sb.append((if (promotions.size == 1) "Free promotion:" else "Free promotions:").tr())
|
sb.append((if (promotions.size == 1) "Free promotion:" else "Free promotions:").tr())
|
||||||
|
@ -3,7 +3,6 @@ package com.unciv.models.ruleset.unit
|
|||||||
import com.unciv.models.ruleset.Ruleset
|
import com.unciv.models.ruleset.Ruleset
|
||||||
import com.unciv.models.ruleset.Unique
|
import com.unciv.models.ruleset.Unique
|
||||||
import com.unciv.models.stats.INamed
|
import com.unciv.models.stats.INamed
|
||||||
import com.unciv.models.translations.Translations
|
|
||||||
import com.unciv.models.translations.tr
|
import com.unciv.models.translations.tr
|
||||||
|
|
||||||
class Promotion : INamed{
|
class Promotion : INamed{
|
||||||
@ -20,7 +19,7 @@ class Promotion : INamed{
|
|||||||
val stringBuilder = StringBuilder()
|
val stringBuilder = StringBuilder()
|
||||||
|
|
||||||
for (unique in uniques + effect) {
|
for (unique in uniques + effect) {
|
||||||
stringBuilder.appendLine(Translations.translateBonusOrPenalty(unique))
|
stringBuilder.appendLine(unique.tr())
|
||||||
}
|
}
|
||||||
|
|
||||||
if(prerequisites.isNotEmpty()) {
|
if(prerequisites.isNotEmpty()) {
|
||||||
|
@ -179,22 +179,6 @@ class Translations : LinkedHashMap<String, TranslationEntry>(){
|
|||||||
val translationFilesTime = System.currentTimeMillis() - startTime
|
val translationFilesTime = System.currentTimeMillis() - startTime
|
||||||
println("Loading percent complete of languages - "+translationFilesTime+"ms")
|
println("Loading percent complete of languages - "+translationFilesTime+"ms")
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
|
||||||
// Regex compilation is expensive, best to save it
|
|
||||||
val bonusOrPenaltyRegex = Regex("""(Bonus|Penalty) vs (.*) (\d*)%""")
|
|
||||||
fun translateBonusOrPenalty(unique: String): String {
|
|
||||||
val regexResult = bonusOrPenaltyRegex.matchEntire(unique)
|
|
||||||
if (regexResult == null) return unique.tr()
|
|
||||||
else {
|
|
||||||
var separatorCharacter = " "
|
|
||||||
if (UncivGame.Current.settings.language == "Simplified_Chinese") separatorCharacter = ""
|
|
||||||
val start = regexResult.groups[1]!!.value + " vs [" + regexResult.groups[2]!!.value + "]"
|
|
||||||
val translatedUnique = start.tr() + separatorCharacter + regexResult.groups[3]!!.value + "%"
|
|
||||||
return translatedUnique
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user