Move units out of cities when liberating

This commit is contained in:
Yair Morgenstern 2020-06-07 21:27:27 +03:00
parent 05ae6fc81f
commit bc458c72ff
2 changed files with 13 additions and 9 deletions

View File

@ -114,7 +114,7 @@ object BattleDamage {
val modifiers = getGeneralModifiers(attacker, defender)
val policies = attacker.getCivInfo().policies
if(attacker is MapUnitCombatant) {
if (attacker is MapUnitCombatant) {
modifiers.putAll(getTileSpecificModifiers(attacker, defender.getTile()))
for (ability in attacker.unit.getUniques()) {
@ -122,11 +122,11 @@ object BattleDamage {
if (regexResult == null) continue
val bonus = regexResult.groups[1]!!.value.toFloat() / 100
if (modifiers.containsKey("Attacker Bonus"))
modifiers["Attacker Bonus"] =modifiers["Attacker Bonus"]!! + bonus
modifiers["Attacker Bonus"] = modifiers["Attacker Bonus"]!! + bonus
else modifiers["Attacker Bonus"] = bonus
}
if(attacker.unit.isEmbarked() && !attacker.unit.hasUnique("Amphibious"))
if (attacker.unit.isEmbarked() && !attacker.unit.hasUnique("Amphibious"))
modifiers["Landing"] = -0.5f
if (attacker.isMelee()) {
@ -136,12 +136,12 @@ object BattleDamage {
&& MapUnitCombatant(it.militaryUnit!!).isMelee()
}
if (numberOfAttackersSurroundingDefender > 1)
modifiers["Flanking"] = 0.1f * (numberOfAttackersSurroundingDefender-1) //https://www.carlsguides.com/strategy/civilization5/war/combatbonuses.php
modifiers["Flanking"] = 0.1f * (numberOfAttackersSurroundingDefender - 1) //https://www.carlsguides.com/strategy/civilization5/war/combatbonuses.php
if (tileToAttackFrom!=null && tileToAttackFrom.isConnectedByRiver(defender.getTile())){
if (tileToAttackFrom != null && tileToAttackFrom.isConnectedByRiver(defender.getTile())) {
if (!tileToAttackFrom.hasConnection(attacker.getCivInfo()) // meaning, the tiles are not road-connected for this civ
|| !defender.getTile().hasConnection(attacker.getCivInfo())
|| !attacker.getCivInfo().tech.roadsConnectAcrossRivers){
|| !attacker.getCivInfo().tech.roadsConnectAcrossRivers) {
modifiers["Across river"] = -0.2f
}
}
@ -153,9 +153,7 @@ object BattleDamage {
if (defender is CityCombatant &&
attacker.getCivInfo().containsBuildingUnique("+15% Combat Strength for all units when attacking Cities"))
modifiers["Statue of Zeus"] = 0.15f
}
else if (attacker is CityCombatant) {
} else if (attacker is CityCombatant) {
if (policies.hasEffect("Units in cities cost no Maintenance, garrisoned city +50% attacking strength")
&& attacker.city.getCenterTile().militaryUnit != null)
modifiers["Oligarchy"] = 0.5f

View File

@ -450,6 +450,12 @@ class CityInfo {
if(foundingCiv.cities.size == 1) cityConstructions.addBuilding("Palace") // Resurrection!
isPuppet = false
cityStats.update()
// Move units out of the city when liberated
for(unit in getTiles().flatMap { it.getUnits() }.toList())
if(!unit.movement.canPassThrough(unit.currentTile))
unit.movement.teleportToClosestMoveableTile()
UncivGame.Current.worldScreen.shouldUpdate=true
}