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);
}
}
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));
}
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>");
}
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;
}
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));
}
Aggregations