use of megamek.common.verifier.TestTank 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.TestTank in project megameklab by MegaMek.
the class StatusBar method refresh.
public void refresh() {
int walk = getTank().getOriginalWalkMP();
int run = getTank().getRunMP(true, true, false);
int jump = getTank().getOriginalJumpMP();
double tonnage = getTank().getWeight();
double currentTonnage;
int bv = getTank().calculateBattleValue();
if (getTank().isSupportVehicle()) {
testEntity = new TestSupportVehicle(getTank(), entityVerifier.tankOption, null);
} else {
testEntity = new TestTank((Tank) getTank(), entityVerifier.tankOption, null);
}
currentTonnage = testEntity.calculateWeight();
currentTonnage += UnitUtil.getUnallocatedAmmoTonnage(getTank());
long currentCost = (long) Math.round(getTank().getCost(false));
tons.setText("Tonnage: " + currentTonnage + "/" + tonnage);
tons.setToolTipText("Current Tonnage/Max Tonnage");
if (currentTonnage > tonnage) {
tons.setForeground(Color.red);
} else {
tons.setForeground(Color.black);
}
Tank tank = getTank();
int currentSlots = tank.getTotalSlots() - tank.getFreeSlots();
slots.setText("Slots: " + currentSlots + "/" + tank.getTotalSlots());
if (currentSlots > tank.getTotalSlots()) {
slots.setForeground(Color.red);
} else {
slots.setForeground(Color.black);
}
bvLabel.setText("BV: " + bv);
bvLabel.setToolTipText("BV 2.0");
cost.setText("Cost: " + formatter.format(currentCost) + " C-bills");
move.setText("Movement: " + walk + "/" + run + "/" + jump);
move.setToolTipText("Walk/Run/Jump MP");
}
use of megamek.common.verifier.TestTank in project megameklab by MegaMek.
the class SummaryView method refresh.
public void refresh() {
TestTank testTank = new TestTank(getTank(), entityVerifier.mechOption, null);
txtStructTon.setText(Double.toString(testTank.getWeightStructure()));
txtEngineTon.setText(Double.toString(testTank.getWeightEngine()));
txtLiftTon.setText(Double.toString(testTank.getTankWeightLifting()));
txtControlsTon.setText(Double.toString(testTank.getWeightControls()));
txtHeatTon.setText(Double.toString(testTank.getWeightHeatSinks()));
txtArmorTon.setText(Double.toString(testTank.getWeightArmor()));
txtTurretTon.setText(Double.toString(testTank.getTankWeightTurret()));
txtRearTurretTon.setText(Double.toString(testTank.getTankWeightDualTurret()));
// Sponsons?
txtPowerAmpTon.setText(Double.toString(testTank.getWeightPowerAmp()));
txtEngineCrit.setText(Integer.toString(getEngineCrits()));
txtArmorCrit.setText(Integer.toString(getArmorCrits()));
txtJumpCrit.setText(Integer.toString(0));
runThroughEquipment(testTank);
}
Aggregations