Minor bugfix

This commit is contained in:
Yair Morgenstern 2018-10-02 00:00:33 +03:00
parent 47a61ccb29
commit 5beac5cd03
2 changed files with 7 additions and 3 deletions

View file

@ -146,6 +146,8 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
}
} else { // If the tile is far away, we need to build a path how to get there, and then take the first step
val path = getShortestPath(destination)
class UnreachableDestinationException:Exception()
if(path.isEmpty()) throw UnreachableDestinationException()
destinationTileThisTurn = path.first()
}

View file

@ -61,9 +61,11 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
if(selectedUnit.currentMovement>0)
moveHereGroup.onClick {
selectedUnit.movementAlgs().headTowards(tileInfo)
if(selectedUnit.currentTile != tileInfo)
selectedUnit.action = "moveTo " + tileInfo.position.x.toInt() + "," + tileInfo.position.y.toInt()
if(selectedUnit.movementAlgs().canReach(tileInfo)) {
selectedUnit.movementAlgs().headTowards(tileInfo)
if (selectedUnit.currentTile != tileInfo)
selectedUnit.action = "moveTo " + tileInfo.position.x.toInt() + "," + tileInfo.position.y.toInt()
}
worldScreen.update()
overlayActor!!.remove()