Search in sources :

Example 1 with TestMech

use of megamek.common.verifier.TestMech in project megameklab by MegaMek.

the class StatusBar method refresh.

public void refresh() {
    int heat = getMech().getHeatCapacity();
    double tonnage = getMech().getWeight();
    double currentTonnage;
    int bv = getMech().calculateBattleValue();
    int maxCrits;
    if (getMech() instanceof TripodMech) {
        maxCrits = 84;
    } else if (getMech() instanceof QuadMech) {
        maxCrits = 66;
    } else {
        maxCrits = 78;
    }
    int currentCrits = UnitUtil.countUsedCriticals(getMech());
    long currentCost = (long) Math.round(getMech().getCost(false));
    testEntity = new TestMech(getMech(), entityVerifier.mechOption, null);
    currentTonnage = testEntity.calculateWeight();
    currentTonnage += UnitUtil.getUnallocatedAmmoTonnage(getMech());
    double totalHeat = calculateTotalHeat();
    heatSink.setText("Heat: " + totalHeat + "/" + heat);
    heatSink.setToolTipText("Total Heat Generated/Total Heat Dissipated");
    if (totalHeat > heat) {
        heatSink.setForeground(Color.red);
    } else {
        heatSink.setForeground(Color.black);
    }
    tons.setText("Tonnage: " + currentTonnage + "/" + tonnage);
    tons.setToolTipText("Current Tonnage/Max Tonnage");
    if (currentTonnage > tonnage) {
        tons.setForeground(Color.red);
    } else {
        tons.setForeground(Color.black);
    }
    bvLabel.setText("BV: " + bv);
    bvLabel.setToolTipText("BV 2.0");
    cost.setText("Cost: " + formatter.format(currentCost) + " C-bills");
    crits.setText("Criticals: " + currentCrits + "/" + maxCrits);
    if (currentCrits > maxCrits) {
        crits.setForeground(Color.red);
    } else {
        crits.setForeground(Color.BLACK);
    }
}
Also used : TripodMech(megamek.common.TripodMech) QuadMech(megamek.common.QuadMech) TestMech(megamek.common.verifier.TestMech)

Example 2 with TestMech

use of megamek.common.verifier.TestMech in project megameklab by MegaMek.

the class SummaryView method refresh.

public void refresh() {
    TestMech testMech = new TestMech(getMech(), entityVerifier.mechOption, null);
    txtGyroTon.setText(Double.toString(testMech.getWeightGyro()));
    txtEngineTon.setText(Double.toString(testMech.getWeightEngine()));
    txtCockpitTon.setText(Double.toString(testMech.getWeightCockpit()));
    txtHeatTon.setText(Double.toString(testMech.getWeightHeatSinks()));
    txtStructTon.setText(Double.toString(testMech.getWeightStructure()));
    if (getMech().hasPatchworkArmor()) {
        txtArmorTon.setText(Double.toString(testMech.getWeightAllocatedArmor()));
    } else {
        txtArmorTon.setText(Double.toString(testMech.getWeightArmor()));
    }
    txtOtherTon.setText(Double.toString(testMech.getWeightPowerAmp() + testMech.getWeightCarryingSpace() + testMech.getWeightMisc()));
    txtGyroCrit.setText(Integer.toString(getGyroCrits()));
    txtEngineCrit.setText(Integer.toString(getEngineCrits()));
    txtCockpitCrit.setText(Integer.toString(getCockpitCrits()));
    if ((getMech().getStructureType() >= 0) && (getMech().getStructureType() < EquipmentType.structureNames.length)) {
        String structName = EquipmentType.getStructureTypeName(getMech().getStructureType(), TechConstants.isClan(getMech().getStructureTechLevel()));
        txtStructCrit.setText(Integer.toString(EquipmentType.get(structName).getCriticals(getMech())));
    } else {
        txtStructCrit.setText("?");
    }
    // FIXME: This doesn't account for patchwork armor crits.
    if ((getMech().getArmorType(0) >= 0) && (getMech().getArmorType(0) < EquipmentType.armorNames.length)) {
        String armorName = EquipmentType.getArmorTypeName(getMech().getArmorType(0), TechConstants.isClan(getMech().getArmorTechLevel(0)));
        txtArmorCrit.setText(Integer.toString(EquipmentType.get(armorName).getCriticals(getMech())));
    } else {
        txtArmorCrit.setText("?");
    }
    runThroughEquipment(testMech);
    int numberSinks = UnitUtil.countActualHeatSinks(getMech());
    numberSinks = Math.max(0, numberSinks - UnitUtil.getCriticalFreeHeatSinks(getMech(), getMech().hasCompactHeatSinks()));
    int critSinks = numberSinks;
    if (UnitUtil.hasClanDoubleHeatSinks(getMech())) {
        critSinks = numberSinks * 2;
    } else if (getMech().hasDoubleHeatSinks()) {
        critSinks = numberSinks * 3;
    } else if (getMech().hasCompactHeatSinks()) {
        critSinks = (critSinks / 2) + (critSinks % 2);
    }
    txtHeatCrit.setText(Integer.toString(critSinks));
}
Also used : TestMech(megamek.common.verifier.TestMech)

Example 3 with TestMech

use of megamek.common.verifier.TestMech in project megameklab by MegaMek.

the class BMStatusBar method refresh.

public void refresh() {
    int heat = getMech().getHeatCapacity();
    double tonnage = getMech().getWeight();
    double currentTonnage;
    int bv = getMech().calculateBattleValue();
    int maxCrits;
    if (getMech() instanceof TripodMech) {
        maxCrits = 84;
    } else if (getMech() instanceof QuadMech) {
        maxCrits = 66;
    } else {
        maxCrits = 78;
    }
    int currentCrits = UnitUtil.countUsedCriticals(getMech());
    long currentCost = Math.round(getMech().getCost(false));
    testEntity = new TestMech(getMech(), entityVerifier.mechOption, null);
    currentTonnage = testEntity.calculateWeight();
    currentTonnage += UnitUtil.getUnallocatedAmmoTonnage(getMech());
    double totalHeat = calculateTotalHeat();
    heatSink.setText("Heat: " + totalHeat + " / " + heat);
    heatSink.setToolTipText("Total Heat Generated / Total Heat Dissipated");
    tons.setText(String.format("Tonnage: %.1f / %.0f (%.1f Remaining)", currentTonnage, tonnage, tonnage - currentTonnage));
    tons.setToolTipText("Current Tonnage/Max Tonnage");
    tons.setForeground(currentTonnage > tonnage ? GUIPreferences.getInstance().getWarningColor() : null);
    bvLabel.setText("BV: " + bv);
    bvLabel.setToolTipText("BV 2.0");
    cost.setText("Cost: " + formatter.format(currentCost) + " C-bills");
    crits.setText("Criticals: " + currentCrits + " / " + maxCrits);
    crits.setForeground(currentCrits > maxCrits ? GUIPreferences.getInstance().getWarningColor() : null);
    StringBuffer sb = new StringBuffer();
    invalid.setVisible(!testEntity.correctEntity(sb));
    invalid.setToolTipText("<html>" + sb.toString().replaceAll("\n", "<br/>") + "</html>");
}
Also used : TestMech(megamek.common.verifier.TestMech)

Example 4 with TestMech

use of megamek.common.verifier.TestMech in project megameklab by MegaMek.

the class UnitUtil method getEntityVerifier.

/**
 * Returns a TestEntity instance for the supplied Entity.
 *
 * @param unit
 * @return
 */
public static TestEntity getEntityVerifier(Entity unit) {
    EntityVerifier entityVerifier = EntityVerifier.getInstance(new File("data/mechfiles/UnitVerifierOptions.xml"));
    TestEntity testEntity = null;
    if (unit.hasETypeFlag(Entity.ETYPE_MECH)) {
        testEntity = new TestMech((Mech) unit, entityVerifier.mechOption, null);
    } else if (unit.hasETypeFlag(Entity.ETYPE_SUPPORT_TANK)) {
        testEntity = new TestSupportVehicle((Tank) unit, entityVerifier.tankOption, null);
    } else if (unit.hasETypeFlag(Entity.ETYPE_TANK)) {
        testEntity = new TestTank((Tank) unit, entityVerifier.tankOption, null);
    } else if (unit.hasETypeFlag(Entity.ETYPE_SMALL_CRAFT)) {
        testEntity = new TestSmallCraft((SmallCraft) unit, entityVerifier.aeroOption, null);
    } else if (unit.hasETypeFlag(Entity.ETYPE_AERO)) {
        testEntity = new TestAero((Aero) unit, entityVerifier.aeroOption, null);
    } else if (unit.hasETypeFlag(Entity.ETYPE_BATTLEARMOR)) {
        testEntity = new TestBattleArmor((BattleArmor) unit, entityVerifier.baOption, null);
    } else if (unit.hasETypeFlag(Entity.ETYPE_INFANTRY)) {
        testEntity = new TestInfantry((Infantry) unit, entityVerifier.infOption, null);
    }
    return testEntity;
}
Also used : TestEntity(megamek.common.verifier.TestEntity) EntityVerifier(megamek.common.verifier.EntityVerifier) TestTank(megamek.common.verifier.TestTank) TestAero(megamek.common.verifier.TestAero) TestBattleArmor(megamek.common.verifier.TestBattleArmor) TestTank(megamek.common.verifier.TestTank) Tank(megamek.common.Tank) Infantry(megamek.common.Infantry) TestInfantry(megamek.common.verifier.TestInfantry) TestMech(megamek.common.verifier.TestMech) TestSupportVehicle(megamek.common.verifier.TestSupportVehicle) TestSmallCraft(megamek.common.verifier.TestSmallCraft) Mech(megamek.common.Mech) TestMech(megamek.common.verifier.TestMech) TripodMech(megamek.common.TripodMech) BipedMech(megamek.common.BipedMech) LandAirMech(megamek.common.LandAirMech) QuadMech(megamek.common.QuadMech) File(java.io.File) Aero(megamek.common.Aero) TestAero(megamek.common.verifier.TestAero) TestInfantry(megamek.common.verifier.TestInfantry)

Example 5 with TestMech

use of megamek.common.verifier.TestMech in project megameklab by MegaMek.

the class BMSummaryView method refresh.

public void refresh() {
    TestMech testMech = new TestMech(getMech(), entityVerifier.mechOption, null);
    txtGyroTon.setText(Double.toString(testMech.getWeightGyro()));
    txtEngineTon.setText(Double.toString(testMech.getWeightEngine()));
    txtCockpitTon.setText(Double.toString(testMech.getWeightCockpit()));
    txtHeatTon.setText(Double.toString(testMech.getWeightHeatSinks()));
    txtStructTon.setText(Double.toString(testMech.getWeightStructure()));
    if (getMech().hasPatchworkArmor()) {
        txtArmorTon.setText(Double.toString(testMech.getWeightAllocatedArmor()));
    } else {
        txtArmorTon.setText(Double.toString(testMech.getWeightArmor()));
    }
    txtOtherTon.setText(Double.toString(testMech.getWeightPowerAmp() + testMech.getWeightCarryingSpace() + testMech.getWeightMisc()));
    txtGyroCrit.setText(Integer.toString(getGyroCrits()));
    txtEngineCrit.setText(Integer.toString(getEngineCrits()));
    txtCockpitCrit.setText(Integer.toString(getCockpitCrits()));
    if ((getMech().getStructureType() >= 0) && (getMech().getStructureType() < EquipmentType.structureNames.length)) {
        String structName = EquipmentType.getStructureTypeName(getMech().getStructureType(), TechConstants.isClan(getMech().getStructureTechLevel()));
        txtStructCrit.setText(Integer.toString(EquipmentType.get(structName).getCriticals(getMech())));
    } else {
        txtStructCrit.setText("?");
    }
    // FIXME: This doesn't account for patchwork armor crits.
    if ((getMech().getArmorType(0) >= 0) && (getMech().getArmorType(0) < EquipmentType.armorNames.length)) {
        String armorName = EquipmentType.getArmorTypeName(getMech().getArmorType(0), TechConstants.isClan(getMech().getArmorTechLevel(0)));
        txtArmorCrit.setText(Integer.toString(EquipmentType.get(armorName).getCriticals(getMech())));
    } else {
        txtArmorCrit.setText("?");
    }
    runThroughEquipment(testMech);
    int numberSinks = UnitUtil.countActualHeatSinks(getMech());
    numberSinks = Math.max(0, numberSinks - UnitUtil.getCriticalFreeHeatSinks(getMech(), getMech().hasCompactHeatSinks()));
    int critSinks = numberSinks;
    if (UnitUtil.hasClanDoubleHeatSinks(getMech())) {
        critSinks = numberSinks * 2;
    } else if (getMech().hasDoubleHeatSinks()) {
        critSinks = numberSinks * 3;
    } else if (getMech().hasCompactHeatSinks()) {
        critSinks = (critSinks / 2) + (critSinks % 2);
    }
    txtHeatCrit.setText(Integer.toString(critSinks));
}
Also used : TestMech(megamek.common.verifier.TestMech)

Aggregations

TestMech (megamek.common.verifier.TestMech)5 QuadMech (megamek.common.QuadMech)2 TripodMech (megamek.common.TripodMech)2 File (java.io.File)1 Aero (megamek.common.Aero)1 BipedMech (megamek.common.BipedMech)1 Infantry (megamek.common.Infantry)1 LandAirMech (megamek.common.LandAirMech)1 Mech (megamek.common.Mech)1 Tank (megamek.common.Tank)1 EntityVerifier (megamek.common.verifier.EntityVerifier)1 TestAero (megamek.common.verifier.TestAero)1 TestBattleArmor (megamek.common.verifier.TestBattleArmor)1 TestEntity (megamek.common.verifier.TestEntity)1 TestInfantry (megamek.common.verifier.TestInfantry)1 TestSmallCraft (megamek.common.verifier.TestSmallCraft)1 TestSupportVehicle (megamek.common.verifier.TestSupportVehicle)1 TestTank (megamek.common.verifier.TestTank)1