/** * Iterate through current weapons and count the number in each capital * fighter location. * * @return A map with keys in the format "weaponName:loc", with the number * of weapons of that type in that location as the value. */ @Override public Map<String, Integer> groupWeaponsByLocation() { Map<String, Integer> groups = new HashMap<>(); for (Mounted mounted : getTotalWeaponList()) { int loc = mounted.getLocation(); if (isFighter() && ((loc == Aero.LOC_RWING) || (loc == Aero.LOC_LWING))) { loc = Aero.LOC_WINGS; } if (mounted.isRearMounted()) { loc = Aero.LOC_AFT; } String key = mounted.getType().getInternalName() + ":" + loc; if (null == groups.get(key)) { groups.put(key, mounted.getNWeapons()); } else { groups.put(key, groups.get(key) + mounted.getNWeapons()); } } return groups; }
@Override public boolean isDmgLight() { if (getArmorRemainingPercent() <= 0.75) { return true; } if (getInternalRemainingPercent() < 0.9) { return true; } if ((getCrew() != null) && (getCrew().getHits() == 1)) { return true; } // If this is not a military unit, we don't care about weapon status. if (!isMilitary()) { return false; } int totalWeapons = getTotalWeaponList().size(); int totalInoperable = 0; for (Mounted weap : getTotalWeaponList()) { if (weap.isCrippled()) { totalInoperable++; } } return ((double) totalInoperable / totalWeapons) >= 0.25; }
@Override public boolean isDmgModerate() { if (getArmorRemainingPercent() <= 0.5) { return true; } if (getInternalRemainingPercent() < 0.75) { return true; } if ((getCrew() != null) && (getCrew().getHits() == 2)) { return true; } // If this is not a military unit, we don't care about weapon status. if (!isMilitary()) { return false; } int totalWeapons = getTotalWeaponList().size(); int totalInoperable = 0; for (Mounted weap : getTotalWeaponList()) { if (weap.isCrippled()) { totalInoperable++; } } return ((double) totalInoperable / totalWeapons) >= 0.5; }
@Override public boolean isDmgHeavy() { if (getArmorRemainingPercent() <= 0.33) { return true; } if (getInternalRemainingPercent() < 0.67) { return true; } if ((getCrew() != null) && (getCrew().getHits() == 3)) { return true; } // If this is not a military unit, we don't care about weapon status. if (!isMilitary()) { return false; } List<Mounted> weaponList = getTotalWeaponList(); int totalWeapons = weaponList.size(); int totalInoperable = 0; for (Mounted weap : weaponList) { if (weap.isCrippled()) { totalInoperable++; } } return ((double) totalInoperable / totalWeapons) >= 0.75; }
List<Mounted> weapons = getTotalWeaponList(); for (Mounted weapon : weapons) { WeaponType wtype = (WeaponType) weapon.getType(); for (Mounted possibleMG : getTotalWeaponList()) { if (possibleMG.getType().hasFlag(WeaponType.F_MG) && (possibleMG.getLocation() == weapon.getLocation())) { for (Mounted mounted : getTotalWeaponList()) { WeaponType wtype = (WeaponType) mounted.getType(); double weaponHeat = wtype.getHeat(); for (Mounted possibleMG : getTotalWeaponList()) { if (possibleMG.getType().hasFlag(WeaponType.F_MG) && (possibleMG.getLocation() == mounted.getLocation())) {
/** * One gunner is required for each capital weapon and each six standard scale weapons, rounding up * @return The vessel's minimum gunner requirements. */ public static int requiredGunners(Aero aero) { if (!aero.isLargeCraft() && !aero.hasETypeFlag(Entity.ETYPE_SMALL_CRAFT)) { return 0; } int capitalWeapons = 0; int stdWeapons = 0; for (Mounted m : aero.getTotalWeaponList()) { if (m.getType() instanceof BayWeapon) { continue; } if ((((WeaponType)m.getType()).getLongRange() <= 1) // MML range depends on ammo, and getLongRange() returns 0 && (((WeaponType) m.getType()).getAmmoType() != AmmoType.T_MML)) { continue; } if (((WeaponType)m.getType()).isCapital() || (m.getType() instanceof ScreenLauncherWeapon)) { capitalWeapons++; } else { stdWeapons++; } } return capitalWeapons + (int)Math.ceil(stdWeapons / 6.0); }