Throw exception when attempting to move a unit to a tile that already contains one

This commit is contained in:
Yair Morgenstern 2018-04-09 11:08:20 +03:00
parent af47880f48
commit 90baebc63d

View file

@ -179,6 +179,7 @@ class MapUnit {
fun moveToTile(otherTile: TileInfo) {
val distanceToTiles = getDistanceToTiles()
if (!distanceToTiles.containsKey(otherTile)) throw Exception("You can't get there from here!")
if (otherTile.unit != null ) throw Exception("Tile already contains a unit!")
currentMovement -= distanceToTiles[otherTile]!!
if (currentMovement < 0.1) currentMovement = 0f // silly floats which are "almost zero"