public static int getBombTypeForWeapon(EquipmentType weapon) { for (int i = 0; i < B_NUM; i++) { if (bombWeaponNames[i] != null && bombWeaponNames[i].equals(weapon.getInternalName())) { return i; } } return -1; }
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; }
/** * Given the list of equipment mounted on this unit, parse it into a unique * list of names and the number of times that name appears. * * @param mountedList A collection of <code>Mounted</code> equipment */ public void setEquipment(List<Mounted> mountedList) { equipmentNames = new Vector<String>(mountedList.size()); equipmentQuantities = new Vector<Integer>(mountedList.size()); for (Mounted mnt : mountedList) { String eqName = mnt.getType().getInternalName(); int index = equipmentNames.indexOf(eqName); if (index == -1){ //We haven't seen this piece of equipment before equipmentNames.add(eqName); equipmentQuantities.add(1); }else{ //We've seen this before, update count equipmentQuantities.set(index, equipmentQuantities.get(index)+1); } } }
@Override public boolean canDeploy(Unit unit, Campaign campaign) { for (Part p : unit.getParts()) { if (p instanceof EquipmentPart) { for (String weapon : antiRiotWeapons) { if (((EquipmentPart)p).getType().getInternalName().equals(weapon)) { return true; } } } } return false; }
/** * Mounts the specified equipment in the specified location. */ @Override public void addEquipment(Mounted mounted, int loc, boolean rearMounted) throws LocationFullException { // Implement parent's behavior. super.addEquipment(mounted, loc, rearMounted); // Is the item a camo system equipment? String name = mounted.getType().getInternalName(); if (BattleArmor.CAMO_SYSTEM.equals(name)) { hasCamoSystem = true; camoName = name; } }
/** * Returns the <code>EquipmentType</code> internal name for the manipulator * mounted in the right arm of this <code>BattleArmor</code> squad. * * @return */ public String getRightManipulatorName(){ Mounted m = getRightManipulator(); if (m == null){ return MANIPULATOR_TYPE_STRINGS[MANIPULATOR_NONE]; } else { return m.getType().getInternalName(); } }
/** * Returns the <code>EquipmentType</code> internal name for the manipulator * mounted in the left arm of this <code>BattleArmor</code> squad. * * @return */ public String getLeftManipulatorName(){ Mounted m = getLeftManipulator(); if (m == null){ return MANIPULATOR_TYPE_STRINGS[MANIPULATOR_NONE]; } else { return m.getType().getInternalName(); } }
/** * return if the BA has any kind of active probe * * @return */ public boolean hasActiveProbe() { for (Mounted equip : getMisc()) { if (equip.getType().hasFlag(MiscType.F_BAP) && !(equip.getType().getInternalName() .equals(Sensor.ISIMPROVED) || equip.getType() .getInternalName().equals(Sensor.CLIMPROVED))) { return true; } } return false; }
/** * return if this BA has improved sensors * * @return */ public boolean hasImprovedSensors() { for (Mounted equip : getMisc()) { if (equip.getType().hasFlag(MiscType.F_BAP)) { if (equip.getType().getInternalName().equals(Sensor.ISIMPROVED) || equip.getType().getInternalName() .equals(Sensor.CLIMPROVED)) { return true; } } } return false; }
public void restoreMunitionType() { for (AmmoType atype : Utilities.getMunitionsFor(unit.getEntity(),(AmmoType)type, CampaignOptions.TECH_EXPERIMENTAL)) { if (atype.getMunitionType() == munition && atype.getInternalName().equals(type.getInternalName())) { type = atype; break; } } }
/** * Provide weapon groups for capital fighters. For capital fighter purposes * we use Aero locations. */ @Override public Map<String, Integer> groupWeaponsByLocation() { Map<String, Integer> groups = new HashMap<>(); for (Mounted mounted : getTotalWeaponList()) { int loc = LOC_CAPITAL_WINGS; if ((loc == Mech.LOC_CT) || (loc == Mech.LOC_HEAD)) { loc = LOC_CAPITAL_NOSE; } if (mounted.isRearMounted() || (loc == Mech.LOC_LLEG) || (loc == Mech.LOC_RLEG)) { loc = LOC_CAPITAL_AFT; } String key = mounted.getType().getInternalName() + ":" + loc; if (null == groups.get(key)) { groups.put(key, mounted.getNWeapons()); } else { groups.put(key, groups.get(key) + mounted.getNWeapons()); } } return groups; }
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); } }
/** * Prepare the entity for a new round of action. */ @Override public void newRound(int roundNumber) { // Perform all base-class behavior. super.newRound(roundNumber); // If we're equipped with a Magnetic Mine // launcher, turn it to single shot mode. for (Mounted m : getMisc()) { EquipmentType equip = m.getType(); if (BattleArmor.MINE_LAUNCHER.equals(equip.getInternalName())) { m.setMode("Single"); } } }
@Override public void writeToXml(PrintWriter pw1, int indent) { writeToXmlBegin(pw1, indent); pw1.println(MekHqXmlUtil.indentStr(indent+1) +"<equipmentNum>" +equipmentNum +"</equipmentNum>"); pw1.println(MekHqXmlUtil.indentStr(indent+1) +"<typeName>" +MekHqXmlUtil.escape(type.getInternalName()) +"</typeName>"); pw1.println(MekHqXmlUtil.indentStr(indent+1) +"<equipTonnage>" +equipTonnage +"</equipTonnage>"); writeToXmlEnd(pw1, indent); }
/** * Returns true if this Mounted is an APDS. * @return */ public boolean isAPDS() { if ((getEntity() instanceof BattleArmor) && getType().getInternalName().equals("ISBAAPDS")) { return true; } else if (getType() instanceof WeaponType) { return ((WeaponType)getType()).getAmmoType() == AmmoType.T_APDS; } else { return false; } }
@Override public void writeToXml(PrintWriter pw1, int indent) { writeToXmlBegin(pw1, indent); pw1.println(MekHqXmlUtil.indentStr(indent+1) +"<equipmentNum>" +equipmentNum +"</equipmentNum>"); pw1.println(MekHqXmlUtil.indentStr(indent+1) +"<typeName>" +MekHqXmlUtil.escape(type.getInternalName()) +"</typeName>"); pw1.println(MekHqXmlUtil.indentStr(indent+1) +"<equipTonnage>" +equipTonnage +"</equipTonnage>"); pw1.println(MekHqXmlUtil.indentStr(indent+1) +"<trooper>" +trooper +"</trooper>"); writeToXmlEnd(pw1, indent); }
@Override public void writeToXml(PrintWriter pw1, int indent) { final String METHOD_NAME = "writeToXml(PrintWriter,int)"; //$NON-NLS-1$ writeToXmlBegin(pw1, indent); pw1.print(MekHqXmlUtil.indentStr(indent + 1) + "<partType tonnage='" + partType.getUnitTonnage() + "' type='"); if (partType instanceof AeroHeatSink) { pw1.print("AeroHeatSink' hsType='" + ((AeroHeatSink)partType).getType()); } else if (partType instanceof EquipmentPart) { pw1.print(((EquipmentPart)partType).getType().getInternalName()); if (partType instanceof MASC) { pw1.print("' rating='" + ((MASC)partType).getEngineRating()); } } else { MekHQ.getLogger().log(getClass(), METHOD_NAME, LogLevel.INFO, "OmniPod partType is not EquipmentType"); //$NON-NLS-1$ } pw1.println("'/>"); writeToXmlEnd(pw1, indent); }
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); } } }
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 "?"; } }
private void initGUI() { //Using bombCatalog to store the part ID's of the bombs so don't have to keep full spare list in memory //and for ease of access later List<Part> spareParts = campaign.getSpareParts(); for(Part spare : spareParts) { if(spare instanceof AmmoStorage && ((EquipmentPart)spare).getType() instanceof BombType && spare.isPresent()) { int bombType = (BombType.getBombTypeFromInternalName(((AmmoStorage)spare).getType().getInternalName())); bombCatalog[bombType] = spare.getId(); availBombs[bombType] = ((AmmoStorage)spare).getShots(); } } for (int type = 0; type < BombType.B_NUM; type++) { typeMax[type] = availBombs[type] + bombChoices[type]; } bombPanel = new BombChoicePanel(bomber, campaign.getGameOptions().booleanOption("at2_nukes"), campaign.getGameOptions().booleanOption("allow_advanced_ammo"), typeMax); //Set up the display of this dialog. JScrollPane scroller = new JScrollPane(bombPanel); scroller.setPreferredSize(new Dimension(300, 200)); setLayout(new BorderLayout()); add(scroller, BorderLayout.CENTER); add(buildButtonPanel(), BorderLayout.SOUTH); }