/** * Returns how many of the given equipment are present in the mech, * destroyed or not. */ public int getNumberOf(EquipmentType etype) { int total = 0; for (Mounted m : equipmentList) { if (m.getType().equals(etype)) { total++; } } return total; }
@Override public boolean isSamePartType(Part part) { return part instanceof LargeCraftAmmoBin && getType().equals( ((AmmoBin)part).getType() ); }
public static boolean compareMounted (Mounted a, Mounted b) { if (!a.getType().equals(b.getType())) return false; if (!a.getClass().equals(b.getClass())) return false; if (!a.getName().equals(b.getName())) return false; if (a.getLocation()!=b.getLocation()) return false; return true; }
@Override public int getBaseTime() { if(null != unit) { Mounted mounted = unit.getEntity().getEquipment(equipmentNum); if(null != mounted) { if(!type.equals(mounted.getType())) { return 30; } } } return 15; }
@Override public boolean isAcceptableReplacement(Part part, boolean refit) { if(part instanceof BattleArmorEquipmentPart) { BattleArmorEquipmentPart eqpart = (BattleArmorEquipmentPart)part; EquipmentType et = eqpart.getType(); return type.equals(et) && getTonnage() == part.getTonnage(); } return false; }
public int getAmmoAvailable(AmmoType type) { for(Part part : oldUnit.campaign.getSpareParts()) { if(part instanceof AmmoStorage) { AmmoStorage a = (AmmoStorage)part; if(a.getType().equals(type)) { return a.getShots(); } } } return 0; }
@Override public boolean isAcceptableReplacement(Part part, boolean refit) { if ((part instanceof AmmoBin) && !(part instanceof LargeCraftAmmoBin)) { EquipmentPart eqpart = (EquipmentPart)part; EquipmentType et = eqpart.getType(); return type.equals(et) && ((AmmoBin)part).getFullShots() == getFullShots(); } return false; }
@Override public boolean isAcceptableReplacement(Part part, boolean refit) { if (part instanceof LargeCraftAmmoBin) { EquipmentPart eqpart = (EquipmentPart)part; EquipmentType et = eqpart.getType(); return type.equals(et) && ((AmmoBin)part).getFullShots() == getFullShots(); } return false; }
@Override public boolean isAcceptableReplacement(Part part, boolean refit) { if(part instanceof MASC) { EquipmentPart eqpart = (EquipmentPart)part; EquipmentType et = eqpart.getType(); return type.equals(et) && getTonnage() == part.getTonnage() && ((MASC)part).getEngineRating() == engineRating; } return false; }
@Override public boolean isSamePartType(Part part) { return part instanceof BattleArmorEquipmentPart && getType().equals(((BattleArmorEquipmentPart)part).getType()) && getTonnage() == part.getTonnage(); }
@Override public boolean isSamePartType(Part part) { return (part instanceof AmmoBin) && !(part instanceof LargeCraftAmmoBin) && getType().equals( ((AmmoBin)part).getType() ) && ((AmmoBin)part).getFullShots() == getFullShots(); }
/** * Returns the number of critical slots present in the section, destroyed or * not. */ public int getNumberOfCriticals(EquipmentType etype, int loc) { int num = 0; int numberOfCriticals = getNumberOfCriticals(loc); for (int i = 0; i < numberOfCriticals; i++) { CriticalSlot ccs = getCritical(loc, i); if ((ccs != null) && (getEquipmentType(ccs) != null) && getEquipmentType(ccs).equals(etype)) { num++; } } return num; }
@Override public boolean isSamePartTypeAndStatus (Part part) { if(needsFixing() || part.needsFixing()) { return false; } return part instanceof MASC && getType().equals(((EquipmentPart)part).getType()) && getTonnage() == part.getTonnage() && getEngineRating() == ((MASC)part).getEngineRating(); }
@Override public boolean isAcceptableReplacement(Part part, boolean refit) { //According to official answer, if sticker prices are different then //they are not acceptable substitutes, so we need to check for that as //well //http://bg.battletech.com/forums/strategic-operations/(answered)-can-a-lance-for-a-35-ton-mech-be-used-on-a-40-ton-mech-and-so-on/ Part newPart = getNewPart(); newPart.setUnit(unit); if(part instanceof EquipmentPart) { EquipmentPart eqpart = (EquipmentPart)part; EquipmentType et = eqpart.getType(); return type.equals(et) && getTonnage() == part.getTonnage() && part.getStickerPrice() == newPart.getStickerPrice(); } return false; }
@Override public boolean isSamePartType(Part part) { //According to official answer, if sticker prices are different then //they are not acceptable substitutes, so we need to check for that as //well //http://bg.battletech.com/forums/strategic-operations/(answered)-can-a-lance-for-a-35-ton-mech-be-used-on-a-40-ton-mech-and-so-on/ return part instanceof EquipmentPart && getType().equals(((EquipmentPart)part).getType()) && getTonnage() == part.getTonnage() && getStickerPrice() == part.getStickerPrice() && isOmniPodded() == part.isOmniPodded(); }
&& etype.equals(unit.getEntity().getEquipment(eqnum).getType())) { equipNums.remove(equipNums.indexOf(eqnum)); } else { continue; if (m.getType().equals(epart.getType()) && !m.isDestroyed()) { epart.setEquipmentNum(equipNum); continue; if (m.getType().equals(epart.getType()) && !m.isDestroyed()) { epart.setEquipmentNum(equipNum);
/** * Determine how much ammunition (of all munition types) remains which is * compatible with the given ammo. * * @param et - the <code>EquipmentType</code> of the ammo to be found. This * value may be <code>null</code>. * @return the <code>int</code> count of the amount of shots of all * munitions equivalent to the given ammo type. */ public int getTotalMunitionsOfType(@Nullable EquipmentType et) { int totalShotsLeft = 0; // specifically don't count caseless munitions as being of the same type as non-caseless for (Mounted amounted : getAmmo()) { boolean amCaseless = ((AmmoType) amounted.getType()).getMunitionType() == AmmoType.M_CASELESS; boolean etCaseless = (et != null) && ((AmmoType) et).getMunitionType() == AmmoType.M_CASELESS; boolean caselessMismatch = amCaseless != etCaseless; if (amounted.getType().equals(et) && !caselessMismatch && !amounted.isDumping()) { totalShotsLeft += amounted.getUsableShotsLeft(); } } return totalShotsLeft; }
if (bWeap.getType().equals(sWeap.getType())) { entity.loadWeapon(bWeap, mAmmo);
@Override public void loadBin() { int shots = Math.min(getAmountAvailable(), shotsNeeded); int shotsPerTrooper = shots / getNumTroopers(); shots = shotsPerTrooper * getNumTroopers(); if(null != unit) { Mounted mounted = unit.getEntity().getEquipment(equipmentNum); if(null != mounted) { if(mounted.getType().equals(type) && ((AmmoType)mounted.getType()).getMunitionType() == getMunitionType()) { //just a simple reload mounted.setShotsLeft(mounted.getBaseShotsLeft() + shotsPerTrooper); } else { //loading a new type of ammo unload(); mounted.changeAmmoType((AmmoType)type); mounted.setShotsLeft(shotsPerTrooper); } } } changeAmountAvailable(-1 * shots, (AmmoType)type); shotsNeeded -= shots; }