Fixed #457 - AI naval units would fortify

This commit is contained in:
Yair Morgenstern 2019-02-18 20:46:50 +02:00
parent add84c4807
commit df237d8686
3 changed files with 13 additions and 4 deletions

View file

@ -21,8 +21,8 @@ android {
applicationId "com.unciv.app"
minSdkVersion 14
targetSdkVersion 28
versionCode 204
versionName "2.13.4"
versionCode 205
versionName "2.13.5"
}
// Had to add this crap for Travis to build, it wanted to sign the app

View file

@ -4,8 +4,8 @@ import com.unciv.UnCivGame
import com.unciv.logic.battle.*
import com.unciv.logic.city.CityInfo
import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.logic.civilization.diplomacy.DiplomaticStatus
import com.unciv.logic.civilization.GreatPersonManager
import com.unciv.logic.civilization.diplomacy.DiplomaticStatus
import com.unciv.logic.map.MapUnit
import com.unciv.logic.map.TileInfo
import com.unciv.models.gamebasics.GameBasics
@ -107,7 +107,7 @@ class UnitAutomation{
val bestTileForHealing = bestTilesForHealing.maxBy { it.getDefensiveBonus() }!!
if(unitTile!=bestTileForHealing && rankTileForHealing(bestTileForHealing,unit)>rankTileForHealing(unitTile,unit))
unit.moveToTile(bestTileForHealing)
if(unit.currentMovement>0 && !unit.hasUnique("No defensive terrain bonus") && !unit.isFortified() ){
if(unit.currentMovement>0 && !unit.isFortified() && unit.canFortify()){
unit.action="Fortify 0"
}
}

View file

@ -245,6 +245,14 @@ class MapUnit {
return goldCostOfUpgrade
}
fun canFortify(): Boolean {
if(type.isWaterUnit()) return false
if(isEmbarked()) return false
if(hasUnique("No defensive terrain bonus")) return false
return true
}
//endregion
//region state-changing functions
@ -446,5 +454,6 @@ class MapUnit {
this.civInfo=civInfo
civInfo.addUnit(this)
}
//endregion
}