Coords src, Coords dest) { final Entity entity = game.getEntity(entityId); final IHex srcHex = game.getBoard().getHex(src); final IHex destHex = game.getBoard().getHex(dest); final Coords[] intervening = Coords.intervening(src, dest); final int direction = src.direction(dest);   if (entity == null) { throw new IllegalArgumentException("Entity invalid."); }   if (!game.getBoard().contains(dest)) { if (game.getOptions().booleanOption("push_off_board")) { return true; } else { return false; } }    if (entity.isHexProhibited(destHex) && !(entity instanceof Tank && destHex.containsTerrain(Terrains.WATER) && (entity.movementMode == IEntityMovementMode.TRACKED || entity.movementMode == IEntityMovementMode.WHEELED))) { return false; }   for (int i = 0; i < intervening.length; i++) { final IHex hex = game.getBoard().getHex(intervening[i]); int change = entity.elevationOccupied(hex) - entity.elevationOccupied(srcHex); if (change > entity.getMaxElevationChange()) { return false; } }    Entity inTheWay = stackingViolation(game, entityId, dest); if (inTheWay != null) { return isValidDisplacement(game, inTheWay.getId(), inTheWay .getPosition(), direction); }   return true;
Coords src, int direction) { return isValidDisplacement(game, entityId, src, src .translated(direction));
    public static boolean isValidDisplacement(IGame game, int entityId,            Coords src, Coords dest) {        final Entity entity = game.getEntity(entityId);        final IHex srcHex = game.getBoard().getHex(src);        final IHex destHex = game.getBoard().getHex(dest);        final Coords[] intervening = Coords.intervening(src, dest);        final int direction = src.direction(dest);        // arguments valid?        if (entity == null) {            throw new IllegalArgumentException("Entity invalid.");        }        // an easy check        if (!game.getBoard().contains(dest)) {            if (game.getOptions().booleanOption("push_off_board")) {                return true;            } else {                return false;            }        }        // can't be displaced into prohibited terrain        // unless we're displacing a tracked or wheeled vee into water        if (entity.isHexProhibited(destHex)                && !(entity instanceof Tank                        && destHex.containsTerrain(Terrains.WATER) && (entity.movementMode == IEntityMovementMode.TRACKED || entity.movementMode == IEntityMovementMode.WHEELED))) {            return false;        }        // can't go up more levels than normally possible        for (int i = 0; i < intervening.length; i++) {            final IHex hex = game.getBoard().getHex(intervening[i]);            int change = entity.elevationOccupied(hex)                    - entity.elevationOccupied(srcHex);            if (change > entity.getMaxElevationChange()) {                return false;            }        }        // if there's an entity in the way, can they be displaced in that        // direction?        Entity inTheWay = stackingViolation(game, entityId, dest);        if (inTheWay != null) {            return isValidDisplacement(game, inTheWay.getId(), inTheWay                    .getPosition(), direction);        }        // okay, that's about all the checks        return true;    }