boolean targetUnderWater = targetHex.contains(Terrain.WATER) && targetHex.depth() > 0 && targEl < targetHex.surface(); boolean targetInWater = targetHex.contains(Terrain.WATER) && targetHex.depth() > 0 && targEl == targetHex.surface(); boolean targetOnLand = !(targetUnderWater || targetInWater);
boolean targetOffBoard = !game.board.contains(target.getPosition()); boolean targetUnderWater; boolean targetInWater; boolean targetOnLand; if (targetOffBoard) { targetUnderWater = true; targetInWater = false; targetOnLand = true; } else { targetUnderWater = targetHex.contains(Terrain.WATER) && targetHex.depth() > 0 && targEl < targetHex.surface(); targetInWater = targetHex.contains(Terrain.WATER) && targetHex.depth() > 0 && targEl == targetHex.surface(); targetOnLand = !(targetUnderWater || targetInWater); }
    public static LosEffects calculateLos(Game game, int attackerId, Targetable target) {        final Entity ae = game.getEntity(attackerId);                        // LOS fails if one of the entities is not deployed.        if (null == ae.getPosition() || null == target.getPosition()) {            LosEffects los = new LosEffects();            los.blocked = true; // TODO: come up with a better "impossible"            return los;        }                final AttackInfo ai = new AttackInfo();        ai.attackPos = ae.getPosition();        ai.targetPos = target.getPosition();        ai.targetEntity = target.getTargetType() == Targetable.TYPE_ENTITY;        ai.targetInfantry = target instanceof Infantry;        ai.attackHeight = ae.getHeight();        ai.targetHeight = target.getHeight();            Hex attHex = game.board.getHex(ae.getPosition());        Hex targetHex = game.board.getHex(target.getPosition());                int attEl = ae.absHeight();        int targEl;        if ( target.getTargetType() == Targetable.TYPE_ENTITY ||             target.getTargetType() == Targetable.TYPE_BUILDING ||             target.getTargetType() == Targetable.TYPE_BLDG_IGNITE ) {            targEl = target.absHeight();        } else {            targEl = game.board.getHex(target.getPosition()).floor();        }    	        ai.attackAbsHeight = attEl;        ai.targetAbsHeight = targEl;        boolean attOffBoard = ae.isOffBoard();        boolean attUnderWater;        boolean attInWater;        boolean attOnLand;        if (attOffBoard) {            attUnderWater = true;            attInWater = false;            attOnLand = true;        } else {            attUnderWater = attHex.contains(Terrain.WATER) &&                 attHex.depth() > 0 &&                 attEl < attHex.surface();            attInWater = attHex.contains(Terrain.WATER) &&                attHex.depth() > 0 &&                 attEl == attHex.surface();            attOnLand = !(attUnderWater || attInWater);        }                boolean targetUnderWater = targetHex.contains(Terrain.WATER) &&             targetHex.depth() > 0 &&             targEl < targetHex.surface();        boolean targetInWater = targetHex.contains(Terrain.WATER) &&            targetHex.depth() > 0 &&             targEl == targetHex.surface();        boolean targetOnLand = !(targetUnderWater || targetInWater);		        boolean underWaterCombat = targetUnderWater || attUnderWater;                ai.attUnderWater = attUnderWater;        ai.attInWater = attInWater;        ai.attOnLand = attOnLand;        ai.targetUnderWater = targetUnderWater;        ai.targetInWater = targetInWater;        ai.targetOnLand = targetOnLand;        ai.underWaterCombat = underWaterCombat;        ai.attOffBoard = attOffBoard;                return calculateLos(game, ai);    }