Merge pull request #433 from ninjatao/fix_seige_units_targets

Fix seige units finding targets bug.
This commit is contained in:
Yair Morgenstern 2019-01-23 18:17:28 +02:00 committed by GitHub
commit d7324ab30f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View File

@ -146,6 +146,7 @@ class UnitAutomation{
val tilesWithEnemies = unit.civInfo.viewableTiles
.filter { containsAttackableEnemy(it, MapUnitCombatant(unit)) }
val minMovBeforeSetup = if (unit.hasUnique("Must set up to ranged attack") && unit.action != "Set Up" ) minMovementBeforeAttack+1.0f else minMovementBeforeAttack
val rangeOfAttack = unit.getRange()
val attackableTiles = ArrayList<AttackableTile>()
@ -155,7 +156,7 @@ class UnitAutomation{
// So the poor unit thought it could attack from the tile, but when it comes to do so it has no movement points!
// Silly floats, basically
val tilesToAttackFrom = unitDistanceToTiles.asSequence()
.filter { unit.currentMovement - it.value >= minMovementBeforeAttack }
.filter { unit.currentMovement - it.value >= minMovBeforeSetup }
.map { it.key }
.filter { unit.canMoveTo(it) || it==unit.getTile() }
@ -534,4 +535,4 @@ class SpecificUnitAutomation{
}
}
}

View File

@ -185,7 +185,6 @@ class MapUnit {
if(currentMovement==0f) return false
if(attacksThisTurn>0 && !hasUnique("1 additional attack per turn")) return false
if(attacksThisTurn>1) return false
if(hasUnique("Must set up to ranged attack") && action != "Set Up") return false
return true
}

View File

@ -153,6 +153,10 @@ class BattleTable(val worldScreen: WorldScreen): Table() {
attackButton.onClick {
if (attacker is MapUnitCombatant) {
attacker.unit.moveToTile(attackableEnemy!!.tileToAttackFrom)
if (attacker.unit.hasUnique("Must set up to ranged attack") && attacker.unit.action != "Set Up") {
attacker.unit.action = "Set Up"
attacker.unit.useMovementPoints(1f)
}
}
battle.attack(attacker, defender)
worldScreen.shouldUpdate=true