diff --git a/build.gradle b/build.gradle index dd586de743..34b8d99833 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,7 @@ buildscript { } dependencies { classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6' - classpath 'com.android.tools.build:gradle:3.5.0' + classpath 'com.android.tools.build:gradle:3.5.1' classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.1' } } diff --git a/core/src/com/unciv/logic/battle/BattleDamage.kt b/core/src/com/unciv/logic/battle/BattleDamage.kt index a7ef5e6cf1..2821d8bf60 100644 --- a/core/src/com/unciv/logic/battle/BattleDamage.kt +++ b/core/src/com/unciv/logic/battle/BattleDamage.kt @@ -9,6 +9,7 @@ import kotlin.collections.HashMap import kotlin.collections.set import kotlin.math.max import kotlin.math.pow +import kotlin.math.roundToInt class BattleDamageModifier(val vs:String,val modificationAmount:Float){ fun getText(): String = "vs $vs" @@ -227,12 +228,12 @@ class BattleDamage{ if(attacker.isRanged()) return 0 if(defender.getUnitType().isCivilian()) return 0 val ratio = getAttackingStrength(attacker,defender) / getDefendingStrength(attacker,defender) - return (damageModifier(ratio, true) * (if(defender.getUnitType() == UnitType.City) 1.00f else getHealthDependantDamageRatio(defender))).toInt() + return (damageModifier(ratio, true) * (if(defender.getUnitType() == UnitType.City) 1.00f else getHealthDependantDamageRatio(defender))).roundToInt() } fun calculateDamageToDefender(attacker: ICombatant, defender: ICombatant): Int { val ratio = getAttackingStrength(attacker,defender) / getDefendingStrength(attacker,defender) - return (damageModifier(ratio,false) * (if(attacker.getUnitType() == UnitType.City) 0.75f else getHealthDependantDamageRatio(attacker))).toInt() + return (damageModifier(ratio,false) * (if(attacker.getUnitType() == UnitType.City) 0.75f else getHealthDependantDamageRatio(attacker))).roundToInt() } fun damageModifier(attackerToDefenderRatio:Float, damageToAttacker:Boolean): Float { diff --git a/core/src/com/unciv/logic/battle/CityCombatant.kt b/core/src/com/unciv/logic/battle/CityCombatant.kt index 14b63e5d2f..c254e8f427 100644 --- a/core/src/com/unciv/logic/battle/CityCombatant.kt +++ b/core/src/com/unciv/logic/battle/CityCombatant.kt @@ -6,6 +6,7 @@ import com.unciv.logic.civilization.CivilizationInfo import com.unciv.logic.map.TileInfo import com.unciv.models.gamebasics.GameBasics import com.unciv.models.gamebasics.unit.UnitType +import kotlin.math.roundToInt class CityCombatant(val city: CityInfo) : ICombatant { override fun getMaxHealth(): Int { @@ -34,7 +35,7 @@ class CityCombatant(val city: CityInfo) : ICombatant { fun getCityStrength(): Int { // Civ fanatics forum, from a modder who went through the original code var strength = 8f - if(city.isCapital()) strength+=2.5f + if(city.isCapital()) strength+=2f strength += (city.population.population/5) * 2 // Each 5 pop gives 2 defence val cityTile = city.getCenterTile() if(cityTile.baseTerrain== Constants.hill) strength+=5 @@ -48,16 +49,16 @@ class CityCombatant(val city: CityInfo) : ICombatant { // Industrial - 32.4, Modern - 51, Atomic - 72.5, All - 118.3 // 100% of the way through the game provides an extra 50.00 - // Garrisoned unit gives up to 20% of strength to city, health-dependant + // Garrisoned unit gives up to 20% of strength to city, in original game strengh of unit has nothing to do with health, health only is related to damage. if(cityTile.militaryUnit!=null) - strength += cityTile.militaryUnit!!.baseUnit().strength * cityTile.militaryUnit!!.health/100f + strength += cityTile.militaryUnit!!.baseUnit().strength / 5f var buildingsStrength = city.cityConstructions.getBuiltBuildings().sumBy{ it.cityStrength }.toFloat() if(getCivInfo().containsBuildingUnique("Defensive buildings in all cities are 25% more effective")) buildingsStrength*=1.25f strength += buildingsStrength - return strength.toInt() + return strength.roundToInt() } override fun toString(): String {return city.name} // for debug