This commit is contained in:
YueR 2019-10-04 22:54:01 +08:00
commit c7ac39c54e
3 changed files with 6 additions and 5 deletions

View File

@ -1557,7 +1557,7 @@
French:"Entretien des transports" French:"Entretien des transports"
Romanian:"Întreținere trasporturi" Romanian:"Întreținere trasporturi"
Spanish:"Mantenimiento de transporte" Spanish:"Mantenimiento de transporte"
Simplified_Chinese:"道(铁)路维护" Simplified_Chinese:"道(铁)路维护"
Portuguese:"Manutenção de transporte" Portuguese:"Manutenção de transporte"
German:"Unterhalt für Transport" German:"Unterhalt für Transport"
} }

View File

@ -200,7 +200,8 @@ class BattleDamage{
} }
private fun getHealthDependantDamageRatio(combatant: ICombatant): Float { private fun getHealthDependantDamageRatio(combatant: ICombatant): Float {
return if(combatant.getCivInfo().nation.unique == "Units fight as though they were at full strength even when damaged" && !combatant.getUnitType().isAirUnit()) return if(combatant.getUnitType() == UnitType.City
|| combatant.getCivInfo().nation.unique == "Units fight as though they were at full strength even when damaged" && !combatant.getUnitType().isAirUnit())
1f 1f
else 1 - (100 - combatant.getHealth()) / 300f// Each 3 points of health reduces damage dealt by 1% like original game else 1 - (100 - combatant.getHealth()) / 300f// Each 3 points of health reduces damage dealt by 1% like original game
} }
@ -228,12 +229,12 @@ class BattleDamage{
if(attacker.isRanged()) return 0 if(attacker.isRanged()) return 0
if(defender.getUnitType().isCivilian()) return 0 if(defender.getUnitType().isCivilian()) return 0
val ratio = getAttackingStrength(attacker,defender) / getDefendingStrength(attacker,defender) val ratio = getAttackingStrength(attacker,defender) / getDefendingStrength(attacker,defender)
return (damageModifier(ratio, true) * (if(defender.getUnitType() == UnitType.City) 1.00f else getHealthDependantDamageRatio(defender))).roundToInt() return (damageModifier(ratio, true) * getHealthDependantDamageRatio(defender)).roundToInt()
} }
fun calculateDamageToDefender(attacker: ICombatant, defender: ICombatant): Int { fun calculateDamageToDefender(attacker: ICombatant, defender: ICombatant): Int {
val ratio = getAttackingStrength(attacker,defender) / getDefendingStrength(attacker,defender) val ratio = getAttackingStrength(attacker,defender) / getDefendingStrength(attacker,defender)
return (damageModifier(ratio,false) * (if(attacker.getUnitType() == UnitType.City) 0.75f else getHealthDependantDamageRatio(attacker))).roundToInt() return (damageModifier(ratio,false) * getHealthDependantDamageRatio(attacker)).roundToInt()
} }
fun damageModifier(attackerToDefenderRatio:Float, damageToAttacker:Boolean): Float { fun damageModifier(attackerToDefenderRatio:Float, damageToAttacker:Boolean): Float {

View File

@ -27,7 +27,7 @@ class CityCombatant(val city: CityInfo) : ICombatant {
} }
override fun getUnitType(): UnitType = UnitType.City override fun getUnitType(): UnitType = UnitType.City
override fun getAttackingStrength(): Int = getCityStrength() //If we don't need to multiply by a modifier number (0.75) in Damage Calculations, getCityStrength() should multiply by 1/(x^i+0.5) (x = CityStrength / DefendUnitStrength, i = if(x>1) 1 else -1). override fun getAttackingStrength(): Int = (getCityStrength() * 0.75).roundToInt()
override fun getDefendingStrength(): Int{ override fun getDefendingStrength(): Int{
if(isDefeated()) return 1 if(isDefeated()) return 1
return getCityStrength() return getCityStrength()