public void removeWeapon(String toRemove) { for (Mounted mounted : getMisc()) { if (mounted.getName().equals(toRemove)) { weaponList.remove(mounted); equipmentList.remove(mounted); break; } } }
/** * Removes the first misc eq. whose name equals the specified string. Used * for removing broken tree clubs. */ public void removeMisc(String toRemove) { for (Mounted mounted : getMisc()) { if (mounted.getName().equals(toRemove)) { miscList.remove(mounted); equipmentList.remove(mounted); break; } } }
private static String formatAmmo(Entity e) { StringBuffer sb = new StringBuffer(1024); for (Mounted ammo : e.getAmmo()) { sb.append(ammo.getName()); sb.append(": ").append(ammo.getBaseShotsLeft()) .append(CommonConstants.NL); } return sb.toString(); }
String getWeaponNames() { StringBuilder out = new StringBuilder(""); for (WeaponFireInfo wfi : this) { if (!StringUtil.isNullOrEmpty(out)) { out.append(","); } if (wfi.getWeapon() == null) { out.append("null"); continue; } out.append(wfi.getWeapon().getName()); } return out.toString(); }
private JMenu createClubMenu() { JMenu menu = new JMenu("Weapon"); for (int pos = 0; pos < myEntity.getClubs().size(); pos++) { Mounted club = myEntity.getClubs().get(pos); if (!club.isDestroyed()) { menu.add(createClubJMenuItem(club.getName(), pos)); } } return menu; }
private Map<String, Object> formatManipulatorRow(int mountLoc, Mounted manipulator) { final Map<String, Object> retVal = new HashMap<>(); retVal.put("locName", BattleArmor.getBaMountLocAbbr(mountLoc)); if (null == manipulator) { retVal.put("eqName", Messages.getString("TROView.None")); retVal.put("eqMass", 0); } else { String name = manipulator.getName(); if (name.contains("[")) { name = name.replaceAll(".*\\[", "").replaceAll("\\].*", ""); } retVal.put("eqName", name); retVal.put("eqMass", manipulator.getType().getTonnage(null) * 1000); } return retVal; }
private String getAmmo() { StringBuffer sAmmo = new StringBuffer(); if (entity.getAmmo().size() < 1) { return ""; } sAmmo.append(String.format("%1$-30s %2$3s %3$5s\n", "Ammo", "Loc", "Shots")); sAmmo.append("----------------------------------------\n"); for (Mounted mounted : entity.getAmmo()) { sAmmo.append(String.format("%1$-30s %2$3s %3$5d\n", mounted.getName(), entity.getLocationAbbr(mounted.getLocation()), mounted.getBaseShotsLeft())); } sAmmo.append("\n"); return sAmmo.toString(); }
String getDebugDescription() { return getWeapon().getName() + " P. Hit: " + LOG_PER.format(getProbabilityToHit()) + ", Max Dam: " + LOG_DEC.format(getMaxDamage()) + ", Exp. Dam: " + LOG_DEC.format(getExpectedDamageOnHit()) + ", Num Crits: " + LOG_DEC.format(getExpectedCriticals()) + ", Kill Prob: " + LOG_PER.format(getKillProbability()); } }
public void addWeapon(ClubAttackAction attack) { final String roll = attack.toHit(this.boardView1.game).getValueAsString(); final String club = attack.getClub().getName(); weaponDescs.add(Messages.getString( "BoardView1.hit", new Object[] { club, roll })); //$NON-NLS-1$ }
/** * Worker function that refreshes the combo box with "up-to-date" ammo names. */ public void refreshAmmoBinNames() { int selectedIndex = ammoBins.getSelectedIndex(); ammoBins.removeAllItems(); int currentIndex = 0; for(Mounted ammoBin : matchingAmmoBins) { ammoBins.addItem("(" + ammoBin.getEntity().getLocationAbbr(ammoBin.getLocation()) + ") " + ammoBin.getName()); if(m_mounted.getLinked() == ammoBin) { selectedIndex = currentIndex; } currentIndex++; } if(selectedIndex >= 0) { ammoBins.setSelectedIndex(selectedIndex); } validate(); }
@Override public String getLocationDamage(int loc) { String toReturn = ""; if(getInternal(loc)<0) { return toReturn; } boolean first = true; for(Mounted m : getEquipment()) { if(m.isMissingForTrooper(loc)) { if (!first) { toReturn += ", "; } toReturn += m.getName(); first = false; } } return toReturn; }
@Override public StringBuffer printWeapon() { if (!getEntity().usesWeaponBays()) { return super.printWeapon(); } StringBuffer buffer = new StringBuffer(); for (Mounted m : getEntity().getWeaponBayList()) { buffer.append(m.getName()).append(" ") .append(getLocationAbbr(m.getLocation())); if (m.isRearMounted()) { buffer.append(" (R)"); } buffer.append("\n"); for (Integer wNum : m.getBayWeapons()) { final Mounted w = getEntity().getEquipment(wNum); buffer.append(" ").append(StringUtil.makeLength(w.getName(), getPrintSize() - 25)).append(w.getType().getTonnage(getEntity())) .append("\n"); } for (Integer aNum : m.getBayAmmo()) { final Mounted a = getEntity().getEquipment(aNum); double weight = a.getType().getTonnage(getEntity()) * a.getBaseShotsLeft() / ((AmmoType)a.getType()).getShots(); buffer.append(" ").append(StringUtil.makeLength(a.getName(), getPrintSize() - 25)).append(weight).append("\n"); } } return buffer; }
@Override public StringBuffer printWeapon() { if (!getEntity().usesWeaponBays()) { return super.printWeapon(); } StringBuffer buffer = new StringBuffer(); for (Mounted m : getEntity().getWeaponBayList()) { buffer.append(m.getName()).append(" ") .append(getLocationAbbr(m.getLocation())); if (m.isRearMounted()) { buffer.append(" (R)"); } buffer.append("\n"); for (Integer wNum : m.getBayWeapons()) { final Mounted w = getEntity().getEquipment(wNum); buffer.append(" ").append(StringUtil.makeLength(w.getName(), getPrintSize() - 25)).append(w.getType().getTonnage(getEntity())) .append("\n"); } for (Integer aNum : m.getBayAmmo()) { final Mounted a = getEntity().getEquipment(aNum); double weight = ceil(a.getType().getTonnage(getEntity()) * a.getBaseShotsLeft() / ((AmmoType)a.getType()).getShots(), Ceil.HALFTON); buffer.append(" ").append(StringUtil.makeLength(a.getName(), getPrintSize() - 25)).append(weight).append("\n"); } } return buffer; }
weaponName.setText("(" + weapon.getEntity().getLocationAbbr(weapon.getLocation()) + ") " + weapon.getName()); add(weaponName, GBC.std());
public Mounted addEquipment(EquipmentType etype, EquipmentType etype2, int loc, boolean omniPod) throws LocationFullException { Mounted mounted = new Mounted(this, etype); Mounted mounted2 = new Mounted(this, etype2); mounted.setOmniPodMounted(omniPod); mounted2.setOmniPodMounted(omniPod); // check criticals for space if (getEmptyCriticals(loc) < 1) { throw new LocationFullException(mounted.getName() + " and " + mounted2.getName() + " do not fit in " + getLocationAbbr(loc) + " on " + getDisplayName() + "\n free criticals in location: " + getEmptyCriticals(loc) + ", criticals needed: " + 1); } super.addEquipment(mounted, loc, false); super.addEquipment(mounted2, loc, false); CriticalSlot cs = new CriticalSlot(mounted); cs.setMount2(mounted2); addCritical(loc, cs); return mounted; }
/** * Returns the name of the heat sinks mounted on this 'mech. * * @return */ public String getHeatSinkTypeName() { for (Mounted m : getMisc()) { // The MiscType name for compact heat sinks is formatted differently if (m.getType().hasFlag(MiscType.F_COMPACT_HEAT_SINK)) { return "Compact Heat Sink"; } if (m.getType().hasFlag(MiscType.F_HEAT_SINK) || m.getType().hasFlag(MiscType.F_DOUBLE_HEAT_SINK) || m.getType().hasFlag(MiscType.F_LASER_HEAT_SINK)) { return m.getName(); } } return ""; }
shooter.getDisplayName() + " tried to load " + currentWeapon.getName() + " with ammo " + mountedAmmo.getDesc() + " but failed somehow.");