public void makeArmorPiercing(AmmoType inType, int modifer) { specCrit = true; if (inType.getRackSize() == 2) { specCritMod = -4; } else if (inType.getRackSize() == 4) { specCritMod = -3; } else if (inType.getRackSize() == 5) { specCritMod = -3; } else if (inType.getRackSize() == 6) { specCritMod = -3; } else if (inType.getRackSize() == 8) { specCritMod = -2; } else if (inType.getRackSize() == 10) { specCritMod = -2; } else if (inType.getRackSize() == 15) { specCritMod = -2; } else if (inType.getRackSize() == 20) { specCritMod = -1; } specCritMod += modifer; }
public BayMunitionsChoicePanel(Entity entity, IGame game) { this.entity = entity; this.game = game; setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(10, 0, 10, 0); for (Mounted bay : entity.getWeaponBayList()) { Map<List<Integer>,List<Mounted>> ammoByType = new HashMap<>(); for (Integer aNum : bay.getBayAmmo()) { final Mounted ammo = entity.getEquipment(aNum); if ((null != ammo) && (ammo.getType() instanceof AmmoType)) { AmmoType atype = (AmmoType) ammo.getType(); List<Integer> key = new ArrayList<>(2); key.add(atype.getAmmoType()); key.add(atype.getRackSize()); ammoByType.putIfAbsent(key, new ArrayList<>()); ammoByType.get(key).add(ammo); } } for (List<Integer> key : ammoByType.keySet()) { AmmoRowPanel row = new AmmoRowPanel(bay, key.get(0), key.get(1), ammoByType.get(key)); gbc.gridy++; add(row, gbc); rows.add(row); } } }
/** * Checks to ensure that the given ammunition type is compatible with the given weapon type. Performs the following * tests:<br/> * {@code ammoType} != null<br/> * {@link AmmoType#getAmmoType()} == {@link WeaponType#getAmmoType()}<br/> * {@link AmmoType#getRackSize()} == {@link WeaponType#getRackSize()} * * @param ammoType The type of ammo to be tested. * @param weaponType The type of weapon the ammo is to be used with. * @return TRUE if the ammo type and weapon type are compatible. */ public static boolean isAmmoValid(AmmoType ammoType, WeaponType weaponType) { if (ammoType == null) { return false; } if (ammoType.getAmmoType() != weaponType.getAmmoType()) { return false; } if (ammoType.getRackSize() != weaponType.getRackSize()) { return false; } return true; } }
.filter(eq -> eq instanceof AmmoType && ((AmmoType)eq).getAmmoType() == weapon.getAmmoType() && ((AmmoType)eq).getRackSize() == weapon.getRackSize()) .findFirst(); if (ammo.isPresent()) { damage = ((AmmoType)ammo.get()).getDamagePerShot() * Math.max(1, ((AmmoType)ammo.get()).getRackSize());
converted = aType.getRackSize(); a.changeAmountAvailable(-1, aType); while (converted < needed && a.getShots() > 0) { converted += aType.getRackSize(); a.changeAmountAvailable(-1, aType); converted = Math.round((float)converted/curType.getRackSize()); as.changeAmountAvailable(converted, curType);
/** * Check all the bins in the same bay that feed the same weapon(s) to determine whether there is * sufficient capacity to load more ammo into this bin. In the case of an ammo swap some ammo * may need to be removed from another bin in this bay before more can be loaded. * * @return The amount of unused capacity that can be used to reload ammo. */ private double bayAvailableCapacity() { if (null != unit) { double space = 0.0; for (Part p : unit.getParts()) { if (p instanceof LargeCraftAmmoBin) { final LargeCraftAmmoBin bin = (LargeCraftAmmoBin) p; if ((bin.getBayEqNum() == bayEqNum) && (((AmmoType) bin.getType()).getAmmoType() == ((AmmoType) type).getAmmoType()) && (((AmmoType) bin.getType()).getRackSize() == ((AmmoType) type).getRackSize())) { space += bin.getCapacity() - bin.getTonnage(); } } } return space; } return 0.0; }
Mockito.when(mockAC5AmmoType.getRackSize()).thenReturn(5); Mockito.when(mockSRM4AmmoType.getAmmoType()).thenReturn(AmmoType.T_SRM); Mockito.when(mockSRM4AmmoType.getRackSize()).thenReturn(4); Mockito.when(mockInferno4AmmoType.getAmmoType()).thenReturn(AmmoType.T_SRM); Mockito.when(mockInferno4AmmoType.getRackSize()).thenReturn(4); Mockito.when(mockAC10AmmoType.getAmmoType()).thenReturn(AmmoType.T_AC); Mockito.when(mockAC10AmmoType.getRackSize()).thenReturn(10); Mockito.when(mockSRM6AmmoType.getAmmoType()).thenReturn(AmmoType.T_SRM); Mockito.when(mockSRM6AmmoType.getRackSize()).thenReturn(6);
public int getAmountAvailable() { int amount = 0; AmmoStorage a = null; AmmoType aType = null; AmmoType thisType = null; for(Part part : campaign.getSpareParts()) { if(!part.isPresent()) { continue; } if(part instanceof AmmoStorage) { a = (AmmoStorage)part; aType = ((AmmoType)((AmmoStorage)a).getType()); thisType = ((AmmoType)getType()); if(aType.equals((Object)getType()) && thisType.getMunitionType() == aType.getMunitionType()) { amount += a.getShots(); if (!(campaign.getCampaignOptions().useAmmoByType())) { break; } } else if (isCompatibleAmmo(aType, thisType) && thisType.getRackSize() != 0) { amount += a.getShots()*aType.getRackSize()/thisType.getRackSize(); } } } return amount; }
for (int i = 0; i < vAmmo.size(); i++) { at = vAmmo.elementAt(i); if ((at.getRackSize() == wt.getRackSize()) && at.isLegal(mounted.getEntity().getTechLevelYear(), mounted.getType().getTechLevel(mounted.getEntity().getTechLevelYear()), if ((at.getRackSize() == wt.getRackSize()) && (TechConstants.isLegal( mounted.getType().getTechLevel(3071), at
return ((getAmmoType() == ((AmmoType) other).getAmmoType()) && (getRackSize() == ((AmmoType) other) .getRackSize()));
|| (at.getAmmoType() == T_MRM_STREAK) || (at.getAmmoType() == T_ROCKET_LAUNCHER)) && (at.getRackSize() >= 20) && ((at.getMunitionType() == M_STANDARD) || (at.getMunitionType() == M_ARTEMIS_CAPABLE) && ((at.getRackSize() >= 12 && at.getMunitionType() != M_EXTENDED_RANGE) || (at.getRackSize() >= 9 && at.getMunitionType() == M_HIGH_EXPLOSIVE))) { return true;
/** * need to check bay location before loading ammo */ @Override public boolean loadWeapon(Mounted mounted, Mounted mountedAmmo) { boolean success = false; WeaponType wtype = (WeaponType) mounted.getType(); AmmoType atype = (AmmoType) mountedAmmo.getType(); if (mounted.getLocation() != mountedAmmo.getLocation()) { return success; } if (mountedAmmo.isAmmoUsable() && !wtype.hasFlag(WeaponType.F_ONESHOT) && (atype.getAmmoType() == wtype.getAmmoType()) && (atype.getRackSize() == wtype.getRackSize())) { mounted.setLinked(mountedAmmo); success = true; } return success; }
if (amount < 0 && campaign.getCampaignOptions().useAmmoByType() && a.getShots() < Math.abs(amount)) { swapAmmoFromCompatible(Math.abs(amount) * aType.getRackSize(), a);
MiscType.F_ARTEMIS)) && atype.getMunitionType() == AmmoType.M_ARTEMIS_CAPABLE) { bonus = (int) Math.ceil(atype.getRackSize() / 5.0); if ((atype.getAmmoType() == AmmoType.T_SRM) || (atype.getAmmoType() == AmmoType.T_SRM_IMP)) { bonus = 2; bonus = (int) Math.ceil(atype.getRackSize() / 5.0); if ((atype.getAmmoType() == AmmoType.T_SRM) || (atype.getAmmoType() == AmmoType.T_SRM_IMP)) { bonus = 2;
if ((atype.getRackSize() == cur_atype.getRackSize()) && (atype.hasFlag(AmmoType.F_BATTLEARMOR) == cur_atype.hasFlag(AmmoType.F_BATTLEARMOR)) && (atype.hasFlag(AmmoType.F_ENCUMBERING) == cur_atype.hasFlag(AmmoType.F_ENCUMBERING))
@Override protected int calcDamagePerHit() { double toReturn = ((AmmoType) ammo.getType()).getRackSize()
/** * need to check bay location before loading ammo */ @Override public boolean loadWeapon(Mounted mounted, Mounted mountedAmmo) { boolean success = false; WeaponType wtype = (WeaponType) mounted.getType(); AmmoType atype = (AmmoType) mountedAmmo.getType(); if (mounted.getLocation() != mountedAmmo.getLocation()) { return success; } // for large craft, ammo must be in the same bay Mounted bay = whichBay(getEquipmentNum(mounted)); if ((bay != null) && !bay.ammoInBay(getEquipmentNum(mountedAmmo))) { return success; } if (mountedAmmo.isAmmoUsable() && !wtype.hasFlag(WeaponType.F_ONESHOT) && (atype.getAmmoType() == wtype.getAmmoType()) && (atype.getRackSize() == wtype.getRackSize())) { mounted.setLinked(mountedAmmo); success = true; } return success; }
/** * need to check bay location before loading ammo */ @Override public boolean loadWeapon(Mounted mounted, Mounted mountedAmmo) { boolean success = false; WeaponType wtype = (WeaponType) mounted.getType(); AmmoType atype = (AmmoType) mountedAmmo.getType(); if (mounted.getLocation() != mountedAmmo.getLocation()) { return success; } // for large craft, ammo must be in the same ba Mounted bay = whichBay(getEquipmentNum(mounted)); if ((bay != null) && !bay.ammoInBay(getEquipmentNum(mountedAmmo))) { return success; } if (mountedAmmo.isAmmoUsable() && !wtype.hasFlag(WeaponType.F_ONESHOT) && (atype.getAmmoType() == wtype.getAmmoType()) && (atype.getRackSize() == wtype.getRackSize())) { mounted.setLinked(mountedAmmo); success = true; } return success; }
private boolean includeMunition(AmmoType atype) { if (!atype.canAeroUse() || (atype.getAmmoType() != at) || (atype.getRackSize() != rackSize) || ((atype.getTechBase() != techBase) && (atype.getTechBase() != AmmoType.TECH_BASE_ALL) && (techBase != AmmoType.TECH_BASE_ALL)) || !atype.isLegal(game.getOptions().intOption(OptionsConstants.ALLOWED_YEAR), SimpleTechLevel.getGameTechLevel(game), techBase == AmmoType.TECH_BASE_CLAN, false)) { return false; } if (atype.hasFlag(AmmoType.F_NUCLEAR) && !game.getOptions().booleanOption( OptionsConstants.ADVAERORULES_AT2_NUKES)) { return false; } if ((atype.getMunitionType() & AmmoType.M_ARTEMIS_CAPABLE) != 0) { return entity.hasWorkingMisc(MiscType.F_ARTEMIS) || entity.hasWorkingMisc(MiscType.F_ARTEMIS_PROTO); } if ((atype.getMunitionType() & AmmoType.M_ARTEMIS_V_CAPABLE) != 0) { return entity.hasWorkingMisc(MiscType.F_ARTEMIS_V); } return true; }
/** * Tries to load the specified weapon with the specified ammo. Returns true * if successful, false otherwise. */ public boolean loadWeapon(Mounted mounted, Mounted mountedAmmo) { boolean success = false; WeaponType wtype = (WeaponType) mounted.getType(); AmmoType atype = (AmmoType) mountedAmmo.getType(); if (mountedAmmo.isAmmoUsable() && !wtype.hasFlag(WeaponType.F_ONESHOT) && (atype.getAmmoType() == wtype.getAmmoType()) && (atype.getRackSize() == wtype.getRackSize())) { mounted.setLinked(mountedAmmo); success = true; } else if (wtype.hasFlag(WeaponType.F_DOUBLE_ONESHOT) && (mountedAmmo.getLocation() == Entity.LOC_NONE)) { // Make sure this ammo is in the chain, then move it to the head. for (Mounted current = mounted; current != null; current = current.getLinked()) { if (current == mountedAmmo) { current.getLinkedBy().setLinked(current.getLinked()); current.setLinked(mounted.getLinked()); mounted.setLinked(current); return true; } } } return success; }