private int getFullShots() { int fullShots = ((AmmoType)type).getShots(); if(oneShot) { fullShots = 1; } return fullShots; }
@Override public String getAcquisitionExtraDesc() { return ((AmmoType)type).getShots() + " shots (1 ton)"; }
@Override public String getAcquisitionExtraDesc() { return ((AmmoType)type).getShots() + " shots (1 ton)"; }
@Override public IAcquisitionWork getAcquisitionWork() { int shots = 1; if(type instanceof AmmoType) { shots = ((AmmoType)type).getShots(); } return new AmmoStorage(1,type,shots,campaign); }
@Override public double getTonnage() { return (1.0 * getFullShots())/((AmmoType)type).getShots(); }
@Override public int getFullShots() { return (int) Math.floor(capacity * ((AmmoType) type).getShots() / type.getTonnage(null)); }
@Override public long getCurrentValue() { return (long)(getStickerPrice() * ((double)shots / ((AmmoType)type).getShots())); }
@Override public IAcquisitionWork getAcquisitionWork() { return new AmmoStorage(1,type,((AmmoType)type).getShots(),campaign); }
private int getFullShots() { return (int) Math.floor(capacity * ((AmmoType) type).getShots() / type.getTonnage(null)); }
protected int getShotsPerTon() { AmmoType atype = (AmmoType)type; if(atype.getKgPerShot() > 0) { return (int)Math.floor(1000.0/atype.getKgPerShot()); } //if not listed by kg per shot, we assume this is a single ton increment return ((AmmoType)type).getShots(); }
public double getUnusedCapacity() { return capacity - Math.ceil(getCurrentShots() * type.getTonnage(null) / ((AmmoType) type).getShots()); }
@Override public double getTonnage() { if(((AmmoType)type).getKgPerShot() > 0) { return ((AmmoType)type).getKgPerShot() * shots/1000.0; } return ((double)shots / ((AmmoType)type).getShots()); }
@Override public double getTonnage() { return getCurrentShots() * type.getTonnage(null) / ((AmmoType) type).getShots(); }
@Override public IAcquisitionWork getAcquisitionWork() { int shots = 1; if (type instanceof AmmoType) { shots = ((AmmoType)type).getShots() * (int) Math.floor(getUnusedCapacity() / type.getTonnage(null)); } return new AmmoStorage(1, type, shots, campaign); }
/** * All ammo must be applied in ratios to the starting load. */ @Override public void applyChoice() { super.applyChoice(); // Calculate the number of shots for the new ammo. // N.B. Some special ammos are twice as heavy as normal // so they have half the number of shots (rounded down). setShotsLeft(Math.round((getShotsLeft() * m_origShotsLeft) / m_origAmmo.getShots())); if (chDump.isSelected()) { setShotsLeft(0); } } }
public void loadBinSingle() { int shots = Math.min(getAmountAvailable(), Math.min(shotsNeeded, ((AmmoType) type).getShots())); if(null != unit) { Mounted mounted = unit.getEntity().getEquipment(equipmentNum); if(null != mounted && mounted.getType() instanceof AmmoType) { mounted.setShotsLeft(mounted.getBaseShotsLeft() + shots); } } changeAmountAvailable(-1 * shots, (AmmoType)type); shotsNeeded -= shots; }
@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; }
public void unloadSingle() { int shots = Math.min(getCurrentShots(), ((AmmoType) type).getShots()); AmmoType curType = (AmmoType)type; if (null != unit) { Mounted mounted = unit.getEntity().getEquipment(equipmentNum); if(null != mounted && mounted.getType() instanceof AmmoType) { shots = Math.min(mounted.getBaseShotsLeft(), shots); mounted.setShotsLeft(mounted.getBaseShotsLeft() - shots); curType = (AmmoType)mounted.getType(); } } shotsNeeded += shots; if(shots > 0) { changeAmountAvailable(shots, curType); } }
@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; }
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); }