diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index f0c1e621..28ccf51e 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -880,3 +880,4 @@ Invalid ID! = [stats] from every [param] = [stats] from [param] tiles in this city = ++[amount]% vs [unitType] = diff --git a/core/src/com/unciv/logic/battle/BattleDamage.kt b/core/src/com/unciv/logic/battle/BattleDamage.kt index 7ec57da2..0f168c79 100644 --- a/core/src/com/unciv/logic/battle/BattleDamage.kt +++ b/core/src/com/unciv/logic/battle/BattleDamage.kt @@ -4,8 +4,6 @@ import com.unciv.Constants import com.unciv.logic.map.MapUnit import com.unciv.logic.map.TileInfo import com.unciv.models.ruleset.unit.UnitType -import com.unciv.models.translations.equalsPlaceholderText -import com.unciv.models.translations.getPlaceholderParameters import java.util.* import kotlin.collections.HashMap import kotlin.collections.set @@ -40,11 +38,12 @@ object BattleDamage { private fun getGeneralModifiers(combatant: ICombatant, enemy: ICombatant): HashMap { val modifiers = HashMap() - fun addToModifiers(BDM:BattleDamageModifier){ - val text = BDM.getText() - if(!modifiers.containsKey(text)) modifiers[text]=0f - modifiers[text]=modifiers[text]!!+BDM.modificationAmount + fun addToModifiers(text:String, amount:Float) { + if (!modifiers.containsKey(text)) modifiers[text] = 0f + modifiers[text] = modifiers[text]!! + amount } + fun addToModifiers(BDM:BattleDamageModifier) = + addToModifiers(BDM.getText(), BDM.modificationAmount) val civInfo = combatant.getCivInfo() if (combatant is MapUnitCombatant) { @@ -61,6 +60,11 @@ object BattleDamage { addToModifiers(BDM) } + for (unique in combatant.unit.getMatchingUniques("+[]% Strength vs []")) { + if (unique.params[1] == enemy.getName()) + addToModifiers("vs [${unique.params[1]}]", unique.params[0].toFloat() / 100) + } + //https://www.carlsguides.com/strategy/civilization5/war/combatbonuses.php val civHappiness = civInfo.getHappiness() if (civHappiness < 0) diff --git a/core/src/com/unciv/logic/city/CityStats.kt b/core/src/com/unciv/logic/city/CityStats.kt index 6cc89bc7..2d8dd1c6 100644 --- a/core/src/com/unciv/logic/city/CityStats.kt +++ b/core/src/com/unciv/logic/city/CityStats.kt @@ -308,16 +308,7 @@ class CityStats { } for (unique in cityInfo.cityConstructions.builtBuildingUniqueMap.getUniques("+[]% production when building [] in this city")) { - val filter = unique.params[1] - if (currentConstruction.name == filter - || (filter == "land units" && currentConstruction is BaseUnit && currentConstruction.unitType.isLandUnit()) - || (filter == "naval units" && currentConstruction is BaseUnit && currentConstruction.unitType.isWaterUnit()) - || (filter == "mounted units" && currentConstruction is BaseUnit && currentConstruction.unitType == UnitType.Mounted) - || (filter == "military units" && currentConstruction is BaseUnit && currentConstruction.unitType.isMilitary()) - || (filter == "melee units" && currentConstruction is BaseUnit && currentConstruction.unitType.isMelee()) - || (filter == "Buildings" && currentConstruction is Building && !currentConstruction.isWonder) - || (filter == "Wonders" && currentConstruction is Building && currentConstruction.isWonder) - || (currentConstruction is Building && currentConstruction.uniques.contains(filter))) + if (constructionFitsFilter(currentConstruction, unique.params[1])) stats.production += unique.params[0].toInt() } @@ -332,23 +323,20 @@ class CityStats { && uniques.any { it.text == "Training of settlers increased +50% in capital" }) stats.production += 50f - if (currentConstruction is Building && !currentConstruction.isWonder) + if (currentConstruction is Building && !currentConstruction.isWonder && !currentConstruction.isNationalWonder) for (unique in uniques.filter { it.placeholderText == "+[]% Production when constructing [] buildings" }) { val stat = Stat.valueOf(unique.params[1]) if (currentConstruction.isStatRelated(stat)) stats.production += unique.params[0].toInt() } + for (unique in uniques.filter { it.placeholderText == "+[]% Production when constructing []" }) { - val filter = unique.params[1] - if (currentConstruction.name == filter - || (filter == "military units" && currentConstruction is BaseUnit && !currentConstruction.unitType.isCivilian()) - || (filter == "melee units" && currentConstruction is BaseUnit && currentConstruction.unitType.isMelee()) - || (filter == "Buildings" && currentConstruction is Building && !currentConstruction.isWonder) - || (filter == "Wonders" && currentConstruction is Building && currentConstruction.isWonder)) + if (constructionFitsFilter(currentConstruction, unique.params[1])) stats.production += unique.params[0].toInt() } + if (cityInfo.cityConstructions.getBuiltBuildings().any { it.isWonder } && uniques.any { it.text == "+33% culture in all cities with a world wonder" }) stats.culture += 33f @@ -363,6 +351,18 @@ class CityStats { return stats } + fun constructionFitsFilter(construction:IConstruction, filter:String): Boolean { + return construction.name == filter + || (filter == "land units" && construction is BaseUnit && construction.unitType.isLandUnit()) + || (filter == "naval units" && construction is BaseUnit && construction.unitType.isWaterUnit()) + || (filter == "mounted units" && construction is BaseUnit && construction.unitType == UnitType.Mounted) + || (filter == "military units" && construction is BaseUnit && !construction.unitType.isCivilian()) + || (filter == "melee units" && construction is BaseUnit && construction.unitType.isMelee()) + || (filter == "Buildings" && construction is Building && !(construction.isWonder || construction.isNationalWonder)) + || (filter == "Wonders" && construction is Building && (construction.isWonder || construction.isNationalWonder)) + || (construction is Building && construction.uniques.contains(filter)) + } + fun isConnectedToCapital(roadType: RoadStatus): Boolean { if (cityInfo.civInfo.cities .count() < 2) return false// first city!