@Override public int calculateBattleValue() { if (useManualBV) { return manualBV; } return calculateBattleValue(false, false); }
/** * Unload the given unit. TODO: need to strip out ammo * * @param unit * - the <code>Entity</code> to be unloaded. * @return <code>true</code> if the unit was contained in this space, * <code>false</code> otherwise. */ @Override public boolean unload(Entity unit) { // Remove the unit if we are carrying it. boolean success = fighters.removeElement(unit.getId()); if (game.getPhase() != Phase.PHASE_LOUNGE) { computeSquadronBombLoadout(); // updateWeaponGroups() and loadAllWeapons() are called in // computeSquadronBombLoadout() } else { updateWeaponGroups(); loadAllWeapons(); } updateSkills(); return success; }
public double getAveWeight() { List<Entity> activeFighters = getActiveSubEntities() .orElse(Collections.emptyList()); return activeFighters.isEmpty() ? Double.NaN : (getWeight() / activeFighters.size()); }
private List<ViewElement> getArmor() { FighterSquadron fs = (FighterSquadron) entity; List<ViewElement> retVal = new ArrayList<>(); retVal.add(new LabeledElement(Messages.getString("MechView.Armor"), //$NON-NLS-1$ String.valueOf(fs.getTotalArmor()))); retVal.add(new LabeledElement(Messages.getString("MechView.ActiveFighters"), //$NON-NLS-1$ String.valueOf(fs.getActiveSubEntities().orElse(Collections.emptyList()).size()))); return retVal; }
while (iter.hasNext()) { String key = iter.next(); this.getEquipment(weaponGroups.get(key)).setNWeapons(0); this.getEquipment(weaponGroups.get(key)).setNWeapons(groups.get(key)); } else { if (etype != null) { try { newmount = addWeaponGroup(etype, loc); newmount.setNWeapons(groups.get(key)); weaponGroups.put(key, getEquipmentNum(newmount)); } catch (LocationFullException ex) { System.out.println("Unable to compile weapon groups"); //$NON-NLS-1$ addFailedEquipment(name); setRapidFire();
&& (type != BombType.B_HOMING)) { try { addBomb(EquipmentType.get(BombType.getBombWeaponName(type)), LOC_NOSE); } catch (LocationFullException ex) { addEquipment(EquipmentType.get(BombType.getBombInternalName(type)), LOC_NOSE, false); } catch (LocationFullException ex) { && game.getBoard().inSpace() && (getBombs(AmmoType.F_SPACE_BOMB).size() > 0)) { try { addEquipment(EquipmentType.get(SPACE_BOMB_ATTACK), LOC_NOSE, false); } catch (LocationFullException ex) { if (!game.getBoard().inSpace() && (getBombs(AmmoType.F_GROUND_BOMB).size() > 0)) { try { addEquipment(EquipmentType.get(DIVE_BOMB_ATTACK), LOC_NOSE, false); } catch (LocationFullException ex) { for (int i = 0; i < Math.min(10, getBombs(AmmoType.F_GROUND_BOMB).size()); i++) { try { addEquipment(EquipmentType.get(ALT_BOMB_ATTACK), LOC_NOSE, false); } catch (LocationFullException ex) { updateWeaponGroups(); loadAllWeapons();
/** * Update sensors. Use the active sensor of the first fighter in the squadron that hasn't taken 3 sensor hits * BAPs don't count as active sensors in space, but they do make detection rolls easier */ public void updateSensors() { if (getActiveSensor() == null) { for (Integer fId : fighters) { Entity entity = game.getEntity(fId); Aero fighter = (Aero) entity; if (fighter.getSensorHits() > 2) { // Sensors destroyed. Check the next fighter continue; } if (fighter.getActiveSensor().isBAP()) { //BAP active. Check the next fighter continue; } if (fighter.getActiveSensor() != null) { for (Sensor sensor : fighter.getSensors()) { getSensors().add(sensor); } setNextSensor(getSensors().firstElement()); break; } } } }
public void loadFS(Vector<Integer> fighterIds) { String name = JOptionPane.showInputDialog(clientgui.frame, "Choose a squadron designation"); if ((name == null) || (name.trim().length() == 0)) { name = "Flying Circus"; } FighterSquadron fs = new FighterSquadron(name); fs.setOwner(clientgui.getClient().getGame().getEntity(fighterIds.firstElement()).getOwner()); clientgui.getClient().sendAddSquadron(fs, fighterIds); }
/** * update the skills for this squadron */ public void updateSkills() { List<Entity> activeFighters = getActiveSubEntities().orElse(Collections.emptyList()); if(activeFighters.isEmpty()) { return; } int pilotingTotal = 0; int gunneryTotal = 0; int gunneryLTotal = 0; int gunneryMTotal = 0; int gunneryBTotal = 0; for(Entity fighter : activeFighters) { pilotingTotal += fighter.getCrew().getPiloting(); gunneryTotal += fighter.getCrew().getGunnery(); gunneryLTotal += fighter.getCrew().getGunneryL(); gunneryMTotal += fighter.getCrew().getGunneryM(); gunneryBTotal += fighter.getCrew().getGunneryB(); } getCrew().setPiloting(pilotingTotal / activeFighters.size(), 0); getCrew().setGunnery(gunneryTotal / activeFighters.size(), 0); getCrew().setGunneryL(gunneryLTotal / activeFighters.size(), 0); getCrew().setGunneryM(gunneryMTotal / activeFighters.size(), 0); getCrew().setGunneryB(gunneryBTotal / activeFighters.size(), 0); }
@Override public boolean hasTargComp() { List<Entity> activeFighters = getActiveSubEntities() .orElse(Collections.emptyList()); if (activeFighters.isEmpty()) { return false; } int nTC = activeFighters.stream() .mapToInt(ent -> ent.hasTargComp() ? 1 : 0).sum(); return (nTC * 1.0 / activeFighters.size() >= 0.5); }
@Override public void applyBombs() { // Make sure all of the aeros have their bombs applied, otherwise // problems // once the bombs are applied, the choices are cleared, so it's not an // issue if the bombs are applied twice for an Aero for (Integer fId : fighters) { IBomber fighter = (IBomber) game.getEntity(fId); fighter.applyBombs(); } computeSquadronBombLoadout(); }
public void load(Entity unit, boolean checkFalse) throws IllegalArgumentException { if (!canLoad(unit)) { throw new IllegalArgumentException("Can not load " + unit.getShortName() + " into this squadron. "); computeSquadronBombLoadout(); updateWeaponGroups(); loadAllWeapons(); updateSkills();