Fixed errors caused by siege unit's movement points not being calculated correctly

This commit is contained in:
Yair Morgenstern 2019-01-27 23:38:11 +02:00
parent 5ab6c6c991
commit 653cb556cf
2 changed files with 9 additions and 4 deletions

View File

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

View File

@ -146,7 +146,6 @@ 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,8 +154,14 @@ class UnitAutomation{
// and then later we round it off to a whole.
// 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 unitMustBeSetUp = unit.hasUnique("Must set up to ranged attack")
val tilesToAttackFrom = unitDistanceToTiles.asSequence()
.filter { unit.currentMovement - it.value >= minMovBeforeSetup }
.filter {
val movementPointsToExpendAfterMovement = if(unitMustBeSetUp) 1 else 0
val movementPointsToExpendHere = if(unitMustBeSetUp && unit.action != "Set Up") 1 else 0
val movementPointsToExpendBeforeAttack = if(it.key==unit.currentTile) movementPointsToExpendHere else movementPointsToExpendAfterMovement
unit.currentMovement - it.value - movementPointsToExpendBeforeAttack > 0 } // still got leftover movement points after all that, to attack
.map { it.key }
.filter { unit.canMoveTo(it) || it==unit.getTile() }