Hashtable<EquipmentType, Integer> equipmentAtLocation = equipment
.get(weaponLocation);
if (equipmentAtLocation != null) {
for (Enumeration<EquipmentType> e = equipmentAtLocation.keys(); e
.hasMoreElements();) {
EquipmentType equipmentType = e.nextElement();
Integer count = equipmentAtLocation.get(equipmentType);
for (int i = 0; i < count.intValue(); i++) {
// for experimental or unofficial equipment, we need
// to adjust the mech's techlevel, because HMV only
// knows lvl1/2/3
if ((equipmentType.getTechLevel() > tank.getTechLevel())
&& (tank.getTechLevel() >= TechConstants.T_IS_ADVANCED)) {
boolean isClan = tank.isClan();
if ((equipmentType.getTechLevel() == TechConstants.T_IS_EXPERIMENTAL) ||
(equipmentType.getTechLevel() == TechConstants.T_CLAN_EXPERIMENTAL)) {
tank.setTechLevel(isClan?TechConstants.T_CLAN_EXPERIMENTAL:TechConstants.T_IS_EXPERIMENTAL);
} else if ((equipmentType.getTechLevel() == TechConstants.T_IS_UNOFFICIAL) ||
(equipmentType.getTechLevel() == TechConstants.T_CLAN_UNOFFICIAL)) {
tank.setTechLevel(isClan?TechConstants.T_CLAN_UNOFFICIAL:TechConstants.T_IS_UNOFFICIAL);
}
}
Mounted weapon = tank.addEquipment(equipmentType, location);
// Add artemis?
// Note this is done here because SRM without artemis and
// LRM with artemis
// can be in the same location on a tank. (and might be
// mislinked)
if ((artemisType != 0) && (equipmentType instanceof WeaponType)) {
String artemis = null;
int ammoType = ((WeaponType) equipmentType)
.getAmmoType();
if (ammoType == AmmoType.T_LRM) {
if ((artemisType & 2) == 2) {
artemis = "ArtemisIV";
} else if ((artemisType & 8) == 8) {
artemis = "ArtemisV";
}
} else if (ammoType == AmmoType.T_SRM) {
if ((artemisType & 1) == 1) {
artemis = "ArtemisIV";
} else if ((artemisType & 4) == 4) {
artemis = "ArtemisV";
}
}
if (artemis != null) {
EquipmentType artEq;
if ((equipmentType.getTechLevel() == TechConstants.T_CLAN_TW)
|| (equipmentType.getTechLevel() == TechConstants.T_CLAN_ADVANCED)) {
artEq = EquipmentType.get("CL" + artemis);
} else {
artEq = EquipmentType.get("IS" + artemis);