Resolved #2406 - land units prefer to be generated in land tiles

This commit is contained in:
Yair Morgenstern 2020-04-13 23:01:20 +03:00
parent 85e1476efb
commit dd8acda4c0

View file

@ -144,7 +144,9 @@ class TileMap {
var tryCount = 0
var potentialCandidates = getPassableNeighbours(currentTile)
while (unitToPlaceTile == null && tryCount++ < 10) {
unitToPlaceTile = potentialCandidates.firstOrNull { unit.movement.canMoveTo(it) }
unitToPlaceTile = potentialCandidates
.sortedByDescending { if(unit.type.isLandUnit()) it.isLand else true } // Land units should prefer to go into land tiles
.firstOrNull { unit.movement.canMoveTo(it) }
if (unitToPlaceTile != null) continue
// if it's not found yet, let's check their neighbours
val newPotentialCandidates = mutableSetOf<TileInfo>()