This commit is contained in:
parent
c9397572f9
commit
e68c32a1e3
3 changed files with 9 additions and 7 deletions
|
@ -21,7 +21,7 @@ buildscript {
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
|
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'
|
classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.1'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import kotlin.collections.HashMap
|
||||||
import kotlin.collections.set
|
import kotlin.collections.set
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
import kotlin.math.pow
|
import kotlin.math.pow
|
||||||
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
class BattleDamageModifier(val vs:String,val modificationAmount:Float){
|
class BattleDamageModifier(val vs:String,val modificationAmount:Float){
|
||||||
fun getText(): String = "vs $vs"
|
fun getText(): String = "vs $vs"
|
||||||
|
@ -227,12 +228,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))).toInt()
|
return (damageModifier(ratio, true) * (if(defender.getUnitType() == UnitType.City) 1.00f else 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))).toInt()
|
return (damageModifier(ratio,false) * (if(attacker.getUnitType() == UnitType.City) 0.75f else getHealthDependantDamageRatio(attacker))).roundToInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun damageModifier(attackerToDefenderRatio:Float, damageToAttacker:Boolean): Float {
|
fun damageModifier(attackerToDefenderRatio:Float, damageToAttacker:Boolean): Float {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.unciv.logic.civilization.CivilizationInfo
|
||||||
import com.unciv.logic.map.TileInfo
|
import com.unciv.logic.map.TileInfo
|
||||||
import com.unciv.models.gamebasics.GameBasics
|
import com.unciv.models.gamebasics.GameBasics
|
||||||
import com.unciv.models.gamebasics.unit.UnitType
|
import com.unciv.models.gamebasics.unit.UnitType
|
||||||
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
class CityCombatant(val city: CityInfo) : ICombatant {
|
class CityCombatant(val city: CityInfo) : ICombatant {
|
||||||
override fun getMaxHealth(): Int {
|
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
|
fun getCityStrength(): Int { // Civ fanatics forum, from a modder who went through the original code
|
||||||
var strength = 8f
|
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
|
strength += (city.population.population/5) * 2 // Each 5 pop gives 2 defence
|
||||||
val cityTile = city.getCenterTile()
|
val cityTile = city.getCenterTile()
|
||||||
if(cityTile.baseTerrain== Constants.hill) strength+=5
|
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
|
// Industrial - 32.4, Modern - 51, Atomic - 72.5, All - 118.3
|
||||||
// 100% of the way through the game provides an extra 50.00
|
// 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)
|
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()
|
var buildingsStrength = city.cityConstructions.getBuiltBuildings().sumBy{ it.cityStrength }.toFloat()
|
||||||
if(getCivInfo().containsBuildingUnique("Defensive buildings in all cities are 25% more effective"))
|
if(getCivInfo().containsBuildingUnique("Defensive buildings in all cities are 25% more effective"))
|
||||||
buildingsStrength*=1.25f
|
buildingsStrength*=1.25f
|
||||||
strength += buildingsStrength
|
strength += buildingsStrength
|
||||||
|
|
||||||
return strength.toInt()
|
return strength.roundToInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toString(): String {return city.name} // for debug
|
override fun toString(): String {return city.name} // for debug
|
||||||
|
|
Loading…
Reference in a new issue