/** * Shortcut to type.getName() */ public String getName() { return type.getName(); }
public static int getStructureType(EquipmentType et) { if (et == null) { return T_STRUCTURE_UNKNOWN; } for (int x = 0; x < structureNames.length; x++) { if (structureNames[x].equals(et.getName())) { return x; } } return T_STRUCTURE_UNKNOWN; }
public String getShortName() { if (shortName.trim().length() < 1) { return getName(); } return shortName; }
public static int getArmorType(EquipmentType et) { if (null == et) { return T_ARMOR_UNKNOWN; } for (int x = 0; x < armorNames.length; x++) { // Some armor names (Industrial), have a space in the name, so trim if (armorNames[x].trim().equals(et.getName().trim())) { return x; } } return T_ARMOR_UNKNOWN; }
/** * Restores the equipment from the name */ public void restore() { if (typeName == null) { typeName = type.getName(); } else { type = EquipmentType.get(typeName); } if (type == null) { System.err .println("Mounted.restore: could not restore equipment type \"" + typeName + "\""); } }
public MissingEquipmentPart(int tonnage, EquipmentType et, int equipNum, Campaign c, double eTonnage, boolean omniPodded) { // TODO Memorize all entity attributes needed to calculate cost // As it is a part bought with one entity can be used on another entity // on which it would have a different price (only tonnage is taken into // account for compatibility) super(tonnage, c); this.type =et; if(null != type) { this.name = type.getName(); this.typeName = type.getInternalName(); } this.equipmentNum = equipNum; this.equipTonnage = eTonnage; this.omniPodded = omniPodded; }
/** * Restores the equipment from the name */ public void restore() { if (typeName == null) { typeName = type.getName(); } else { type = EquipmentType.get(typeName); } if (type == null) { System.err .println("Mounted.restore: could not restore equipment type \"" + name + "\""); } }
/** * Restores the equipment from the name */ public void restore() { if (typeName == null) { typeName = type.getName(); } else { type = EquipmentType.get(typeName); } if (type == null) { System.err .println("Mounted.restore: could not restore equipment type \"" + typeName + "\""); return; } }
/** * Adds ammo data used by large craft */ protected void addAmmo() { final Map<String, List<Mounted>> ammoByType = aero.getAmmo().stream() .collect(Collectors.groupingBy(m -> m.getType().getName())); final List<Map<String, Object>> ammo = new ArrayList<>(); for (final List<Mounted> aList : ammoByType.values()) { final Map<String, Object> ammoEntry = new HashMap<>(); ammoEntry.put("name", aList.get(0).getType().getName().replaceAll("\\s+Ammo", "")); ammoEntry.put("shots", aList.stream().mapToInt(Mounted::getUsableShotsLeft).sum()); ammoEntry.put("tonnage", aList.stream().mapToDouble(m -> m.getType().getTonnage(aero)).sum()); ammo.add(ammoEntry); } setModelData("ammo", ammo); }
public void changeMunition(EquipmentType type) { if (type instanceof AmmoType) { munition = ((AmmoType) type).getMunitionType(); this.type = type; this.name = type.getName(); this.typeName = type.getInternalName(); updateConditionFromEntity(false); } }
if (fieldGuns.size() > 1) { notes.add(String.format(Messages.getString("TROView.InfantryNote.FieldGuns"), fieldGuns.size(), fieldGuns.get(0).getName(), shots / fieldGuns.size(), (int) fieldGuns.get(0).getTonnage(inf))); } else if (fieldGuns.size() > 0) { notes.add(String.format(Messages.getString("TROView.InfantryNote.SingleFieldGun"), fieldGuns.get(0).getName(), shots, (int) fieldGuns.get(0).getTonnage(inf)));
typeName = type.getName(); } else { type = EquipmentType.get(typeName);
public EquipmentPart(int tonnage, EquipmentType et, int equipNum, boolean omniPodded, Campaign c) { super(tonnage, omniPodded, c); this.type =et; if(null != type) { this.name = type.getName(); this.typeName = type.getInternalName(); } if (equipNum != -1) { this.equipmentNum = equipNum; } else { equipmentNum = -1; } if(null != type) { try { equipTonnage = type.getTonnage(null); } catch(NullPointerException ex) { MekHQ.getLogger().error(EquipmentPart.class, "EquipmentPart", ex); } } }
podSpace += m.getType().getTonnage(entity, m.getLocation()); } else if (m.getType() instanceof WeaponType) { weaponCount.merge(m.getType().getName(), 1, Integer::sum);
public Object getValueAt(int row, int col) { if (row >= equipment.size()) { return null; } EquipmentType eq = equipment.elementAt(row); switch (col) { case COL_QTY: return qty[row] + ""; case COL_NAME: return eq.getName(); case COL_IS_CLAN: return TechConstants.getTechName(eq.getTechLevel(gameYear)); case COL_COST: return eq.getRawCost(); case COL_LEVEL: return TechConstants.getSimpleLevelName(TechConstants .convertFromNormalToSimple(eq .getTechLevel(gameYear))); case COL_INTERNAL_NAME: return eq.getInternalName(); default: return "?"; } }
&& !m.getType().getName().equals(MIMETIC_ARMOR)) { specialAbilities.put(BattleForceSPA.LMAS, null); } else if (m.getType().hasFlag(MiscType.F_VEHICLE_MINE_DISPENSER)) {
EquipmentType etype = i.nextElement(); if(etype instanceof WeaponType) { optionComp.addValue(etype.getName());
public void loadBin() { int shots = Math.min(getAmountAvailable(), getShotsNeeded()); if (null != unit) { Mounted mounted = unit.getEntity().getEquipment(equipmentNum); if (null != mounted) { EquipmentType mType = mounted.getType(); if (mType instanceof AmmoType) { if (!ammoTypeChanged()) { //just a simple reload mounted.setShotsLeft(mounted.getBaseShotsLeft() + shots); } else { //loading a new type of ammo unload(); mounted.changeAmmoType((AmmoType)type); mounted.setShotsLeft(shots); } changeAmountAvailable(-1 * shots, (AmmoType)type); shotsNeeded -= shots; } else { MekHQ.getLogger().log(AmmoBin.class, "loadBin", LogLevel.WARNING, mType.getName() + " is not valid equipment for " + getName() + " to restock ammo on unit " + unit.getName()); } } } }
if (type.getName().equals("Beagle Active Probe")) {