private int calcSquadCost() {
return calcSuitCost() * stateMenPerSquad;
}
private BattleArmor getEntity() {
BattleArmor retVal = new BattleArmor();
// Set the name.
retVal.setChassis(m_tfBAName.getText().trim());
retVal.setModel("");
retVal.setWeightClass(stateWeightClass);
retVal.setChassisType(stateChassisType);
// Set the weight (number of troops), and then initialize the armor.
retVal.setWeight(stateMenPerSquad);
retVal.refreshLocations();
retVal.autoSetInternal();
retVal.setArmorType(stateArmorType);
for (int x = 1; x < retVal.locations(); x++) {
retVal.initializeArmor(stateArmorValue, x);
}
// Set the tech base.
if (stateTechBase == TECH_BASE_IS) {
retVal.setTechLevel(TechConstants.T_IS_TW_NON_BOX);
} else {
retVal.setTechLevel(TechConstants.T_CLAN_TW);
}
// Set the ground movement.
retVal.setOriginalWalkMP(stateGroundMP);
// Set the jump movement.
retVal.setOriginalJumpMP(getTotalJumpMP());
// Set the movement mode.
if (stateJumpType == JUMP_TYPE_VTOL) {
retVal.setMovementMode(IEntityMovementMode.VTOL);
} else if (stateJumpType == JUMP_TYPE_UMU) {
retVal.setMovementMode(IEntityMovementMode.INF_UMU);
} else {
retVal.setMovementMode(IEntityMovementMode.INF_LEG);
}
// And set its cost.
retVal.setCost(calcSquadCost());
try {
if (stateArmorType == 7) { // Fire-resistant Armor
retVal.addEquipment(EquipmentType
.get("BA-Fire Resistant Armor"),
BattleArmor.LOC_SQUAD);
}
// If it's capable of anti-'Mech attacks...
if (canDoAntiMech()) {
retVal.addEquipment(EquipmentType.get(Infantry.LEG_ATTACK),
BattleArmor.LOC_SQUAD);
retVal.addEquipment(EquipmentType.get(Infantry.SWARM_MEK),
BattleArmor.LOC_SQUAD);
retVal.addEquipment(EquipmentType.get(Infantry.STOP_SWARM),
BattleArmor.LOC_SQUAD);
// Don't forget magnetic claws that give a bonus, like
// Salamanders!
if (stateManipulatorTypeLeft == BattleArmor.MANIPULATOR_BATTLE_MAGNET) {
// We only check one, because they can only be added in
// pairs...
retVal.addEquipment(EquipmentType
.get(BattleArmor.ASSAULT_CLAW),
BattleArmor.LOC_SQUAD);
}
}
// Lets add vibro-claws!
if (((stateManipulatorTypeLeft == BattleArmor.MANIPULATOR_BATTLE_VIBRO) || (stateManipulatorTypeLeft == BattleArmor.MANIPULATOR_HEAVY_BATTLE_VIBRO))
&& ((stateManipulatorTypeRight == BattleArmor.MANIPULATOR_BATTLE_VIBRO) || (stateManipulatorTypeRight == BattleArmor.MANIPULATOR_HEAVY_BATTLE_VIBRO))) {
// BA-Vibro Claws (2)
retVal.addEquipment(EquipmentType.get("BA-Vibro Claws (2)"),
BattleArmor.LOC_SQUAD);
} else if (((stateManipulatorTypeLeft == BattleArmor.MANIPULATOR_BATTLE_VIBRO) || (stateManipulatorTypeLeft == BattleArmor.MANIPULATOR_HEAVY_BATTLE_VIBRO))
|| ((stateManipulatorTypeRight == BattleArmor.MANIPULATOR_BATTLE_VIBRO) || (stateManipulatorTypeRight == BattleArmor.MANIPULATOR_HEAVY_BATTLE_VIBRO))) {
// BA-Vibro Claws (1)
retVal.addEquipment(EquipmentType.get("BA-Vibro Claws (1)"),
BattleArmor.LOC_SQUAD);
}
if (canMountMech()) {
// Needs to be able to ride 'Mechs.
retVal.addEquipment(EquipmentType
.get(BattleArmor.BOARDING_CLAW), BattleArmor.LOC_SQUAD);
}
// Equipment and stuff needs to be set!
// Now all other equipment.
if (leftArmEquipment != null) {
Iterator<BattleArmorEquipment> tmpE = leftArmEquipment
.iterator();
while (tmpE.hasNext()) {
BattleArmorEquipment tmpBAE = (tmpE.next());
if ((tmpBAE.internalType == EQUIPMENT_TYPE_WEAPON)
|| (tmpBAE.internalType == EQUIPMENT_TYPE_AMMO)) {
retVal.addEquipment(EquipmentType
.get(tmpBAE.weaponTypeName),
BattleArmor.LOC_SQUAD);
} else if (tmpBAE.internalType == EQUIPMENT_TYPE_OTHER) {
// FIXME
}
// EQUIPMENT_TYPE_PREPROCESS, by definition, should already
// have been handled.
}
}
if (rightArmEquipment != null) {
Iterator<BattleArmorEquipment> tmpE = rightArmEquipment
.iterator();
while (tmpE.hasNext()) {
BattleArmorEquipment tmpBAE = (tmpE.next());
if ((tmpBAE.internalType == EQUIPMENT_TYPE_WEAPON)
|| (tmpBAE.internalType == EQUIPMENT_TYPE_AMMO)) {
retVal.addEquipment(EquipmentType
.get(tmpBAE.weaponTypeName),
BattleArmor.LOC_SQUAD);
} else if (tmpBAE.internalType == EQUIPMENT_TYPE_OTHER) {
// FIXME
}
// EQUIPMENT_TYPE_PREPROCESS, by definition, should already
// have been handled.
}
}
if (torsoEquipment != null) {
Iterator<BattleArmorEquipment> tmpE = torsoEquipment.iterator();
while (tmpE.hasNext()) {
BattleArmorEquipment tmpBAE = (tmpE.next());
if ((tmpBAE.internalType == EQUIPMENT_TYPE_WEAPON)
|| (tmpBAE.internalType == EQUIPMENT_TYPE_AMMO)) {
retVal.addEquipment(EquipmentType
.get(tmpBAE.weaponTypeName),
BattleArmor.LOC_SQUAD);
} else if (tmpBAE.internalType == EQUIPMENT_TYPE_OTHER) {
// FIXME
}