private void recalcMaxValues() { double[] currentWeight = new double[spinners.size()]; double remaining = tonnage; for (int i = 0; i < spinners.size(); i++) { currentWeight[i] += Math.ceil(munitions.get(i).getTonnage(entity) * ((Integer) spinners.get(i).getValue() / (double) munitions.get(i).getShots())); remaining -= currentWeight[i]; } for (int i = 0; i < spinners.size(); i++) { int max = (int) Math.floor((currentWeight[i] + remaining) / munitions.get(i).getTonnage(entity) * munitions.get(i).getShots()); spinners.get(i).removeChangeListener(this); ((SpinnerNumberModel) spinners.get(i).getModel()).setMaximum(max); spinners.get(i).addChangeListener(this); } lblTonnage.setText(String.format(Messages.getString("CustomMechDialog.formatAmmoTonnage"), //$NON-NLS-1$ tonnage - remaining, tonnage)); }
public StringBuffer printAmmo(StringBuffer buff, int posLoc, int posWeight) { for (Mounted m : getEntity().getAmmo()) { AmmoType mt = (AmmoType) m.getType(); // Don't think this can happen, but ... if (m.getLocation() == Entity.LOC_NONE) { continue; } buff.append(StringUtil.makeLength(mt.getName(), 20)); buff.append(" ").append( StringUtil.makeLength(getLocationAbbr(m.getLocation()), getPrintSize() - 5 - 20)) .append(TestEntity.makeWeightString(mt .getTonnage(getEntity()))).append("\n"); } return buff; }
spn.setName(atype.getInternalName()); spn.addChangeListener(this); if (atype.getTonnage(entity) > 1) { spn.setToolTipText(String.format(Messages.getString("CustomMechDialog.formatMissileTonnage"), atype.getName(), atype.getTonnage(entity))); } else { spn.setToolTipText(String.format(Messages.getString("CustomMechDialog.formatShotsPerTon"),
@Override public double getWeightAmmo() { double weight = 0.0; for (Mounted m : getEntity().getAmmo()) { // One Shot Ammo if (m.getLocation() == Entity.LOC_NONE) { continue; } AmmoType mt = (AmmoType) m.getType(); int slots = (int)Math.ceil(m.getBaseShotsLeft() / mt.getShots()); weight += mt.getTonnage(getEntity()) * slots; } return weight; }
@Override public double getWeightAmmo() { double weight = 0.0; for (Mounted m : getEntity().getAmmo()) { // One Shot Ammo if (m.getLocation() == Entity.LOC_NONE) { continue; } AmmoType mt = (AmmoType) m.getType(); int slots = (int)Math.ceil(m.getBaseShotsLeft() / mt.getShots()); weight += ceil(mt.getTonnage(getEntity()) * slots, Ceil.HALFTON); } return weight; }
int slots = (int) Math.ceil((double) shots / row.munitions.get(i).getShots()); mounted.setOriginalShots(slots * row.munitions.get(i).getShots()); mounted.setAmmoCapacity(slots * row.munitions.get(i).getTonnage(entity)); remainingWeight -= mounted.getAmmoCapacity(); mountIndex++; AmmoType at = (AmmoType) m.getType(); m.setAmmoCapacity(m.getAmmoCapacity() + remainingWeight); m.setOriginalShots((int) Math.floor(m.getAmmoCapacity() / (at.getShots() * at.getTonnage(entity))));
protected void addEquipment(Mounted mounted, int loc, boolean rearMounted, int nAmmo) throws LocationFullException { if ((mounted.getType() instanceof AmmoType) && (nAmmo > 1)) { mounted.setByShot(true); mounted.setShotsLeft(nAmmo); mounted.setOriginalShots(nAmmo); double tonnage = Math.max(1, nAmmo / ((AmmoType) mounted.getType()).getShots()) * ((AmmoType) mounted.getType()).getTonnage(this); mounted.setAmmoCapacity(tonnage); } addEquipment(mounted, loc, rearMounted); }
public double getWeightAmmo() { double weight = 0.0; for (Mounted m : getEntity().getAmmo()) { // One Shot Ammo if (m.getLocation() == Entity.LOC_NONE) { continue; } // Bombs on ASF don't count! if ((getEntity() instanceof Aero) && (m.getType() instanceof BombType)) { continue; } AmmoType mt = (AmmoType) m.getType(); weight += mt.getTonnage(getEntity()); } return weight; }
munition.setTonnage(base.getTonnage(null));
&& (atype.hasFlag(AmmoType.F_BATTLEARMOR) == cur_atype.hasFlag(AmmoType.F_BATTLEARMOR)) && (atype.hasFlag(AmmoType.F_ENCUMBERING) == cur_atype.hasFlag(AmmoType.F_ENCUMBERING)) && ((atype.getTonnage(entity) == cur_atype.getTonnage(entity)) || atype.hasFlag(AmmoType.F_CAP_MISSILE))) { atypes.add(atype);
&& (atCheck.hasFlag(AmmoType.F_ENCUMBERING) == at .hasFlag(AmmoType.F_ENCUMBERING)) && (atCheck.getTonnage(entity) == at.getTonnage(entity))) { vTypes.add(atCheck);