targEl = game.getBoard().getHex(target.getPosition()).floor();
targEl = game.getBoard().getHex(target.getPosition()).surface();
    public static LosEffects calculateLos(IGame 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() || ae.isOffBoard()) {            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();            IHex attHex = game.getBoard().getHex(ae.getPosition());        IHex targetHex = game.getBoard().getHex(target.getPosition());        int attEl = ae.absHeight() + attHex.getElevation();        int targEl;        if ( target.getTargetType() == Targetable.TYPE_ENTITY ||             target.getTargetType() == Targetable.TYPE_BUILDING ||             target.getTargetType() == Targetable.TYPE_BLDG_IGNITE ) {            targEl = target.absHeight() + targetHex.getElevation();        } else {            targEl = game.getBoard().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.containsTerrain(Terrains.WATER) &&                 attHex.depth() > 0 &&                 attEl < attHex.surface();            attInWater = attHex.containsTerrain(Terrains.WATER) &&                attHex.depth() > 0 &&                 attEl == attHex.surface();            attOnLand = !(attUnderWater || attInWater);        }                boolean targetOffBoard = !game.getBoard().contains(target.getPosition());        boolean targetUnderWater;        boolean targetInWater;        boolean targetOnLand;        if (targetOffBoard) {            targetUnderWater = true;            targetInWater = false;            targetOnLand = true;        } else {            targetUnderWater = targetHex.containsTerrain(Terrains.WATER) &&                 targetHex.depth() > 0 &&                 targEl < targetHex.surface();            targetInWater = targetHex.containsTerrain(Terrains.WATER) &&                targetHex.depth() > 0 &&                 targEl == targetHex.surface();            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;        // Handle minimum water depth.        // Applies to Torpedos.        if(ai.attOnLand || ai.targetOnLand)            ai.minimumWaterDepth = 0;        else if (ai.attInWater || ai.targetInWater)            ai.minimumWaterDepth = 1;        else if (ai.attUnderWater || ai.targetUnderWater)            ai.minimumWaterDepth = Math.min(attHex.terrainLevel(Terrains.WATER),                    targetHex.terrainLevel(Terrains.WATER));        LosEffects finalLoS = calculateLos(game, ai);        finalLoS.hasLoS = !finalLoS.blocked && (finalLoS.lightWoods + finalLoS.lightSmoke) + ((finalLoS.heavyWoods + finalLoS.heavySmoke) * 2) + (finalLoS.ultraWoods * 3) < 3;                /*         * Torren (MekWars)         * If LOS is blocked         * And the Attacker has BAP that is working         * i.e. not effect by ECM or destoyed/damaged/breached/Shutdown         * And the target is a Non-Infantry Unit         * And the target is not under water         * And the target is in range of the Attackers BAP         * Then remove the Block.         *          *  Note code was done with 2 version of BMR and maxtech rules from various user sources          *  anything that is wrong please let me know for feature refence.         *           *  This will not detect hidden units(not coded yet anyways)         *  This was designed for double blind.         *           *           */        final int probeRange = ae.getBAPRange();        if ( !finalLoS.canSee()&& ae.hasBAP()                 &&  ai.targetEntity                && !(ai.targetInfantry && !(target instanceof BattleArmor) && probeRange!=8)                && !ai.underWaterCombat                 && ae.getPosition().distance(ai.targetPos) <= probeRange                && !Compute.isAffectedByECM(ae, ae.getPosition(), ai.targetPos)                && !Compute.isAffectedByAngelECM(ae, ae.getPosition(), ai.targetPos)) {            Entity te = (Entity)target;            if(probeRange==8 || !(te.isStealthActive()))                finalLoS.hasLoS = true;        }                    return finalLoS;    }