mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-12 16:59:11 +07:00
Strength bonus from capital is now part of the Palace bonuses to make it moddable
This commit is contained in:
@ -7,6 +7,7 @@
|
||||
"science": 3,
|
||||
"gold": 3,
|
||||
"culture": 1,
|
||||
"cityStrength": 2,
|
||||
"cost": 1,
|
||||
"uniques": ["Indicates the capital city"]
|
||||
},
|
||||
|
@ -17,32 +17,31 @@ class CityCombatant(val city: CityInfo) : ICombatant {
|
||||
override fun getCivInfo(): CivilizationInfo = city.civInfo
|
||||
override fun getTile(): TileInfo = city.getCenterTile()
|
||||
override fun getName(): String = city.name
|
||||
override fun isDefeated(): Boolean = city.health==1
|
||||
override fun isDefeated(): Boolean = city.health == 1
|
||||
override fun isInvisible(): Boolean = false
|
||||
override fun canAttack(): Boolean = (!city.attackedThisTurn)
|
||||
override fun matchesCategory(category:String) = category == "City"
|
||||
override fun matchesCategory(category: String) = category == "City"
|
||||
|
||||
override fun takeDamage(damage: Int) {
|
||||
city.health -= damage
|
||||
if(city.health<1) city.health=1 // min health is 1
|
||||
if (city.health < 1) city.health = 1 // min health is 1
|
||||
}
|
||||
|
||||
override fun getUnitType(): UnitType = UnitType.City
|
||||
override fun getAttackingStrength(): Int = (getCityStrength() * 0.75).roundToInt()
|
||||
override fun getDefendingStrength(): Int{
|
||||
if(isDefeated()) return 1
|
||||
override fun getDefendingStrength(): Int {
|
||||
if (isDefeated()) return 1
|
||||
return getCityStrength()
|
||||
}
|
||||
|
||||
fun getCityStrength(): Int { // Civ fanatics forum, from a modder who went through the original code
|
||||
var strength = 8f
|
||||
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()
|
||||
if (cityTile.isHill()) strength += 5
|
||||
// as tech progresses so does city strength
|
||||
val techCount = getCivInfo().gameInfo.ruleSet.technologies.count()
|
||||
val techsPercentKnown: Float = if(techCount>0) city.civInfo.tech.techsResearched.count().toFloat() / techCount else 0.5f // for mods with no tech
|
||||
val techsPercentKnown: Float = if (techCount > 0) city.civInfo.tech.techsResearched.count().toFloat() / techCount else 0.5f // for mods with no tech
|
||||
strength += (techsPercentKnown * 5.5).pow(2.8).toFloat()
|
||||
|
||||
|
||||
@ -52,16 +51,16 @@ class CityCombatant(val city: CityInfo) : ICombatant {
|
||||
// 100% of the way through the game provides an extra 50.00
|
||||
|
||||
// Garrisoned unit gives up to 20% of strength to city, health-dependant
|
||||
if(cityTile.militaryUnit!=null)
|
||||
if (cityTile.militaryUnit != null)
|
||||
strength += cityTile.militaryUnit!!.baseUnit().strength * (cityTile.militaryUnit!!.health / 100f) * 0.2f
|
||||
|
||||
var buildingsStrength = city.cityConstructions.getBuiltBuildings().sumBy{ it.cityStrength }.toFloat()
|
||||
if(getCivInfo().hasUnique("Defensive buildings in all cities are 25% more effective"))
|
||||
buildingsStrength*=1.25f
|
||||
var buildingsStrength = city.cityConstructions.getBuiltBuildings().sumBy { it.cityStrength }.toFloat()
|
||||
if (getCivInfo().hasUnique("Defensive buildings in all cities are 25% more effective"))
|
||||
buildingsStrength *= 1.25f
|
||||
strength += buildingsStrength
|
||||
|
||||
return strength.roundToInt()
|
||||
}
|
||||
|
||||
override fun toString(): String {return city.name} // for debug
|
||||
override fun toString() = city.name // for debug
|
||||
}
|
||||
|
Reference in New Issue
Block a user