checkPathAvailability

final Boolean checkPathAvailability(Paths2D.PathStrategy path, Cell startCell, Integer depth, Function1<GameUnit, Boolean> unitIsOk, Function1<GameUnit, Boolean> unitIsTarget)

Checks if all cells on path are available.

This method will iterate through all cells of the path in normal order and then run unitIsOk predicate for each unit found on that cell. If any of these runs fail, the path is considered not available.

Additionally, unitIsTarget is run for each unit on the path. If this predicate is satisfied, the iteration stops and the path is considered available.

If the iteration goes on for depth steps and all unitIsOk are satisfied to that point, the iteration stops and the path is considered available.

Return

true if path is considered available, false otherwise.

Parameters

path

The path to test.

startCell

The cell to start iterating path from.

depth

The maximum number of steps to be taken along the path.

unitIsOk

The predicate that decides whether a unit can appear on an available path.

unitIsTarget

The predicate that decides whether iteration can be stopped upon encountering a unit.