Added Great War Bomber

Air units now require Oil
This commit is contained in:
Yair Morgenstern 2019-07-15 22:45:32 +03:00
parent cf8d9f9ff1
commit b9a7f7e1d0
4 changed files with 50 additions and 3 deletions

View File

@ -838,7 +838,6 @@
hurryCostModifier:20,
attackSound:"shot"
},
{
name:"Triplane",
unitType:"Fighter",
@ -848,11 +847,25 @@
range:5,
cost: 325,
requiredTech:"Flight",
requiredResource:"Oil",
hurryCostModifier:20,
uniques:["[50]% chance to intercept air attacks","Bonus vs Bomber 150%",
"6 tiles in every direction always visible"]
attackSound:"shot"
},
{
name:"Great War Bomber",
unitType:"Bomber",
movement:1,
strength:50,
rangedStrength:50,
range:6,
cost: 325,
requiredTech:"Flight",
requiredResource:"Oil",
hurryCostModifier:20,
attackSound:"shot"
},
/*
{

View File

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

View File

@ -208,4 +208,32 @@ class SpecificUnitAutomation{
}
fun automateBomber(unit: MapUnit) {
if(UnitAutomation().tryAttackNearbyEnemy(unit)) return
val tilesInRange = unit.currentTile.getTilesInDistance(unit.getRange())
val immediatelyReachableCities = tilesInRange
.filter { it.isCityCenter() && it.getOwner()==unit.civInfo && unit.movement.canMoveTo(it)}
for(city in immediatelyReachableCities){
if(city.getTilesInDistance(unit.getRange())
.any { UnitAutomation().containsAttackableEnemy(it,MapUnitCombatant(unit)) }) {
unit.movement.moveToTile(city)
return
}
}
val pathsToCities = unit.movement.getArialPathsToCities()
if(pathsToCities.size==1) return // can't actually move anywhere else
val citiesThatCanAttackFrom = pathsToCities.keys
.filter { it.getTilesInDistance(unit.getRange())
.any { UnitAutomation().containsAttackableEnemy(it,MapUnitCombatant(unit)) } }
if(citiesThatCanAttackFrom.isEmpty()) return
val closestCityThatCanAttackFrom = citiesThatCanAttackFrom.minBy { pathsToCities[it]!!.size }!!
val firstStepInPath = pathsToCities[closestCityThatCanAttackFrom]!!.first()
unit.movement.moveToTile(firstStepInPath)
}
}

View File

@ -36,6 +36,9 @@ class UnitAutomation{
if(unit.type==UnitType.Fighter)
return SpecificUnitAutomation().automateFighter(unit)
if(unit.type==UnitType.Bomber)
return SpecificUnitAutomation().automateBomber(unit)
if(unit.name.startsWith("Great")
&& unit.name in GreatPersonManager().statToGreatPersonMapping.values){ // So "Great War Infantry" isn't caught here
return SpecificUnitAutomation().automateGreatPerson(unit)
@ -384,6 +387,8 @@ class UnitAutomation{
val cityTilesToAttack = attackableEnemies.filter { it.tileToAttack.isCityCenter() }
val nonCityTilesToAttack = attackableEnemies.filter { !it.tileToAttack.isCityCenter() }
// todo add filter undefended tile if is air unit
var enemyTileToAttack: AttackableTile? = null
val capturableCity = cityTilesToAttack.firstOrNull{it.tileToAttack.getCity()!!.health == 1}
val cityWithHealthLeft = cityTilesToAttack.filter { it.tileToAttack.getCity()!!.health != 1 } // don't want ranged units to attack defeated cities
@ -394,6 +399,7 @@ class UnitAutomation{
else if (nonCityTilesToAttack.isNotEmpty()) // second priority, units
enemyTileToAttack = nonCityTilesToAttack.minBy { Battle(unit.civInfo.gameInfo).getMapCombatantOfTile(it.tileToAttack)!!.getHealth() }
else if (cityWithHealthLeft!=null) enemyTileToAttack = cityWithHealthLeft// third priority, city
return enemyTileToAttack