public void recover(Entity unit) throws IllegalArgumentException { // If we can't load the unit, throw an exception. if (!canLoad(unit)) { throw new IllegalArgumentException("Can not recover " + unit.getShortName() + " into this bay. " + getUnused()); } currentSpace -= 1; // get the closest open recovery slot and make it unavailable closeSlot(); // Add the unit to our list of troops. troops.addElement(unit.getId()); }
@Override public void destroyDoor() { if (getCurrentDoors() > 0) { setCurrentDoors(getCurrentDoors() - 1); } // get rid of two empty recovery slots // it doesn't matter which ones if (recoverySlots.size() > 0) { recoverySlots.remove(0); } if (recoverySlots.size() > 0) { recoverySlots.remove(0); } }
@Override public void destroyDoorNext() { if (getDoorsNext() > 0) { setDoorsNext(getDoorsNext() - 1); } // get rid of two empty recovery slots // it doesn't matter which ones if (recoverySlots.size() > 0) { recoverySlots.remove(0); } if (recoverySlots.size() > 0) { recoverySlots.remove(0); } }
@Override public String getUnusedString(boolean showrecovery) { if (showrecovery) { return "Aerospace Fighter " + numDoorsString() + " - " + String.format("%1$,.0f", getUnused()) + " units (" + getRecoverySlots() + " recovery open)"; } return String.format("Aerospace Fighter Bay %s - %2$,.0f", numDoorsString(), getUnused()) + (getUnused() > 1 ? " units" : " unit"); }
@Test public void identifyFighterBay() { Bay bay = new ASFBay(1, 1, 0); assertEquals(BayData.getBayType(bay), BayData.FIGHTER); }
/** * Load the given unit. * * @param unit * - the <code>Entity</code> to be loaded. * @exception - If the unit can't be loaded, an * <code>IllegalArgumentException</code> exception will be * thrown. */ @Override public void load(Entity unit) throws IllegalArgumentException { // If we can't load the unit, throw an exception. if (!canLoad(unit)) { throw new IllegalArgumentException("Can not load " + unit.getShortName() + " into this bay. " + getUnused()); } currentSpace -= 1; // Add the unit to our list of troops. troops.addElement(unit.getId()); }
if (getUnused() < 1) { result = false; if (getRecoverySlots() < 1) { result = false;
specialAbilities.merge(BattleForceSPA.AT, (int)((ASFBay)t).getCapacity(), Integer::sum); specialAbilities.merge(BattleForceSPA.ATxD, ((ASFBay)t).getDoors(), Integer::sum); specialAbilities.put(BattleForceSPA.MFB, null); } else if (t instanceof CargoBay) {
/** * @return the launch rate for fighters */ public int getFighterLaunchRate() { int result = 0; // Walk through this entity's transport components; for (Transporter next : transports) { if (next instanceof ASFBay) { result += 2 * ((ASFBay) next).getCurrentDoors(); } } // Return the number. return result; }
/** * damage the door of the first bay that can load this unit */ public void damageDoorRecovery(Entity en) { Enumeration<Transporter> iter = transports.elements(); while (iter.hasMoreElements()) { Transporter next = iter.nextElement(); if ((next instanceof ASFBay) && next.canLoad(en)) { ((ASFBay) next).destroyDoor(); break; } if ((next instanceof SmallCraftBay) && next.canLoad(en)) { ((SmallCraftBay) next).destroyDoor(); break; } } }
Vector<Bay> bays = new Vector<>(2); bays.add(new MechBay(12, 1, 1)); bays.add(new ASFBay(2, 1, 2)); doReturn(bays).when(mockUnionE).getTransportBays();
/** * @return only entities in ASF Bays */ public Vector<Entity> getLoadedFighters() { Vector<Entity> result = new Vector<Entity>(); // Walk through this entity's transport components; // add all of their lists to ours. // I should only add entities in bays that are functional for (Transporter next : transports) { if ((next instanceof ASFBay) && (((ASFBay) next).getCurrentDoors() > 0)) { for (Entity e : next.getLoadedUnits()) { result.addElement(e); } } } // Return the list. return result; }
String numbers = transporter.substring(7); ParsedBayInfo pbi = new ParsedBayInfo(numbers, usedBayNumbers); e.addTransporter(new ASFBay(pbi.getSize(), pbi.getDoors(), pbi.getBayNumber())); } else if (transporter.startsWith("smallcraftbay:", 0)) { String numbers = transporter.substring(14);
/** * @return only entities in ASF Bays that can be launched (i.e. not in * recovery) */ public Vector<Entity> getLaunchableFighters() { Vector<Entity> result = new Vector<Entity>(); // Walk through this entity's transport components; // add all of their lists to ours. // I should only add entities in bays that are functional for (Transporter next : transports) { if ((next instanceof ASFBay) && (((ASFBay) next).getCurrentDoors() > 0)) { Bay nextbay = (Bay) next; for (Entity e : nextbay.getLaunchableUnits()) { result.addElement(e); } } } // Return the list. return result; }
transportBay = new MechBay(4, 1, 1); bayList.add(transportBay); transportBay = new ASFBay(2, 0, 2); bayList.add(transportBay); transportBay = new LightVehicleBay(22, 0, 3);