int maxumumHeatFront = 0; int maxumumHeatRear = 0;
double maxumumHeatFront = 0; double maxumumHeatRear = 0;
    public int calculateBattleValue() {        double dbv = 0; // defensive battle value        double obv = 0; // offensive bv                // total armor points        dbv += getTotalArmor() * 2.0;                // total internal structure        double internalMultiplier;        if (hasXL()) {            internalMultiplier = isClan() ? 1.125 : 0.75;        } else {            internalMultiplier = 1.5;        }                dbv += getTotalInternal() * internalMultiplier;                // add weight        dbv += getWeight();                // subtract for explosive ammo        for (Enumeration i = equipmentList.elements(); i.hasMoreElements();) {            Mounted mounted = (Mounted)i.nextElement();            int loc = mounted.getLocation();            EquipmentType etype = mounted.getType();                        // only count explosive ammo            if (!etype.isExplosive()) {                continue;            }                        if (isClan()) {                // clan mechs only count ammo in ct, legs or head                if (loc != LOC_CT && loc != LOC_RLEG && loc != LOC_LLEG                && loc != LOC_HEAD) {                    continue;                }            } else {                // inner sphere with XL counts everywhere                if (!hasXL()) {                    // without XL, only count torsos if not CASEed, and arms                    // if arm & torso not CASEed                    if ((loc == LOC_RT || loc == LOC_LT) && locationHasCase(loc)) {                        continue;                    }                    if (loc == LOC_LARM && (locationHasCase(loc) || locationHasCase(LOC_LT))) {                        continue;                    }                    if (loc == LOC_RARM && (locationHasCase(loc) || locationHasCase(LOC_RT))) {                        continue;                    }                }            }                        float tonnage = etype.getTonnage(this);                        // gauss rifles only count as one ton for this            if (etype instanceof WeaponType && etype.getName().indexOf("Gauss") != -1) {                tonnage = 1.0f;            }                        dbv -= (int)(20.0 * tonnage);        }                        // total up maximum heat generated        int maxumumHeatFront = 0;        int maxumumHeatRear = 0;        for (Enumeration i = weaponList.elements(); i.hasMoreElements();) {            Mounted mounted = (Mounted)i.nextElement();            WeaponType wtype = (WeaponType)mounted.getType();            float weaponHeat = wtype.getHeat();                        // double heat for ultras            if (wtype.getAmmoType() == AmmoType.T_AC_ULTRA) {                weaponHeat *= 2;            }            // half heat for streaks            if (wtype.getAmmoType() == AmmoType.T_SRM_STREAK) {                weaponHeat *= 0.5;            }                        if (mounted.isRearMounted()) {                maxumumHeatRear += weaponHeat;            } else {                maxumumHeatFront += weaponHeat;            }        }        int maximumHeat = Math.max(maxumumHeatFront, maxumumHeatRear);        if (getJumpMP() > 0) {            maximumHeat += Math.max(3, getJumpMP());        } else {            maximumHeat += 2;        }        // adjust for heat efficiency        if (maximumHeat > getHeatCapacity()) {            dbv -= ((maximumHeat - getHeatCapacity()) * 5);        }                // adjust for target movement modifier        int tmmRan = Compute.getTargetMovementModifier(getRunMP(), false).getValue();        int tmmJumped = Compute.getTargetMovementModifier(getJumpMP(), true).getValue();        int targetMovementModidifer = Math.max(tmmRan, tmmJumped);        if (targetMovementModidifer > 5) {            targetMovementModidifer = 5;        }        double[] tmmFactors = { 1.0, 1.1, 1.2, 1.3, 1.4, 1.5 };        dbv *= tmmFactors[targetMovementModidifer];                double weaponBV = 0;                // figure out base weapon bv        double weaponsBVFront = 0;        double weaponsBVRear = 0;        for (Enumeration i = weaponList.elements(); i.hasMoreElements();) {            Mounted mounted = (Mounted)i.nextElement();            WeaponType wtype = (WeaponType)mounted.getType();            double dBV = wtype.getBV(this);                        // artemis bumps up the value            if (mounted.getLinkedBy() != null) {                Mounted mLinker = mounted.getLinkedBy();                if (mLinker.getType() instanceof MiscType &&                         mLinker.getType().hasFlag(MiscType.F_ARTEMIS)) {                    dBV *= 1.2;                }            }                         if (mounted.isRearMounted()) {                weaponsBVRear += dBV;            } else {                weaponsBVFront += dBV;            }        }        if (weaponsBVFront > weaponsBVRear) {            weaponBV += weaponsBVFront;            weaponBV += (weaponsBVRear * 0.5);        } else {            weaponBV += weaponsBVRear;            weaponBV += (weaponsBVFront * 0.5);        }                // add ammo bv        double ammoBV = 0;        for (Enumeration i = ammoList.elements(); i.hasMoreElements();) {            Mounted mounted = (Mounted)i.nextElement();            AmmoType atype = (AmmoType)mounted.getType();            ammoBV += atype.getBV(this);        }        weaponBV += ammoBV;                // adjust for heat efficiency        if (maximumHeat > getHeatCapacity()) {            double x = (getHeatCapacity()  * weaponBV) / maximumHeat;            double y = (weaponBV - x) / 2;            weaponBV = x + y;        }                // adjust further for speed factor        double speedFactor = getRunMP() + getJumpMP() - 5;        speedFactor /= 10;        speedFactor++;        speedFactor = Math.pow(speedFactor, 1.2);        speedFactor = Math.round(speedFactor * 100) / 100.0;                obv = weaponBV * speedFactor;                // we get extra bv from c3 networks. a valid network requires at least 2 members        // some hackery and magic numbers here.  could be better        // also, each 'has' loops through all equipment.  inefficient to do it 3 times        double xbv = 0.0;        if ((hasC3M() && calculateFreeC3Nodes() < 3) ||            (hasC3S() && C3Master > NONE) ||            (hasC3i() && calculateFreeC3Nodes() < 5)) {                xbv = (double)(Math.round(0.35 * weaponsBVFront + (0.5 * weaponsBVRear)));        }                // and then factor in pilot        double pilotFactor = crew.getBVSkillMultiplier();                return (int)Math.round((dbv + obv + xbv) * pilotFactor);    }