@Override public Mounted addEquipment(EquipmentType etype, int loc, boolean rearMounted, int shots) throws LocationFullException { Mounted mounted = new Mounted(this, etype); addEquipment(mounted, loc, rearMounted, shots); return mounted; }
@Override public Mounted addEquipment(EquipmentType etype, int loc, boolean rearMounted) throws LocationFullException { Mounted mounted = new Mounted(this, etype); addEquipment(mounted, loc, rearMounted, -1); return mounted; }
public Mounted addWeaponGroup(EquipmentType etype, int loc) throws LocationFullException { Mounted mounted = new Mounted(this, etype); addEquipment(mounted, loc, false, true); return mounted; }
/** * indicate whether this is a bomb mount */ public Mounted addBomb(EquipmentType etype, int loc) throws LocationFullException { Mounted mounted = new Mounted(this, etype); addBomb(mounted, loc); return mounted; }
/** * mounting weapons needs to take account of ammo * * @param etype * @param loc * @param rearMounted * @param nAmmo * @return * @throws LocationFullException */ public Mounted addEquipment(EquipmentType etype, int loc, boolean rearMounted, int nAmmo) throws LocationFullException { Mounted mounted = new Mounted(this, etype); addEquipment(mounted, loc, rearMounted, nAmmo); return mounted; }
@Override public Mounted addEquipment(EquipmentType etype, int loc, boolean rearMounted) throws LocationFullException { if (etype instanceof BombType) { Mounted mounted = new Mounted(this, etype); addBomb(mounted, loc); return mounted; } else { return super.addEquipment(etype, loc, rearMounted); } }
/** * add heat sinks into the engine * * @param sinkName * the <code>String</code> determining the type of heatsink to * add. must be a lookupname of a heatsinktype * @param toAllocate * Number of hs to add to the Engine. */ public void addEngineSinks(String sinkName, int toAllocate) { // this relies on these being the correct internalNames for these items EquipmentType sinkType = EquipmentType.get(sinkName); if (sinkType == null) { System.out.println("Mech: can't find heat sink to add to engine"); } for (int i = 0; i < toAllocate; i++) { try { addEquipment(new Mounted(this, sinkType), Entity.LOC_NONE, false); } catch (LocationFullException ex) { // um, that's impossible. } } }
/** * indicate whether this is bodymounted for BAs */ public Mounted addEquipment(EquipmentType etype, int loc, boolean rearMounted, int baMountLoc, boolean dwpMounted) throws LocationFullException { Mounted mounted = new Mounted(this, etype); mounted.setBaMountLoc(baMountLoc); mounted.setDWPMounted(dwpMounted); addEquipment(mounted, loc, rearMounted); return mounted; }
@Test public void testEDPArmorTakesTorsoSlot() { Protomech mockProto = mock(Protomech.class); when(mockProto.hasMainGun()).thenReturn(true); when(mockProto.locations()).thenReturn(Protomech.NUM_PMECH_LOCATIONS); when(mockProto.getArmorType(anyInt())).thenReturn(EquipmentType.T_ARMOR_EDP); when(mockProto.getArmorTechLevel(anyInt())).thenReturn(TechConstants.T_CLAN_EXPERIMENTAL); Mounted m = new Mounted(mockProto, EquipmentType.get("CLERSmallLaser")); m.setLocation(Protomech.LOC_TORSO); ArrayList<Mounted> eqList = new ArrayList<>(); eqList.add(m); when(mockProto.getEquipment()).thenReturn(eqList); TestProtomech test = new TestProtomech(mockProto, option, null); assertFalse(test.hasIllegalEquipmentCombinations(new StringBuffer())); eqList.add(m); assertTrue(test.hasIllegalEquipmentCombinations(new StringBuffer())); }
@Test public void testNoArmMountsForQuads() { Protomech mockProto = createGenericMockProto(); when(mockProto.isQuad()).thenReturn(true); Mounted m = new Mounted(mockProto, EquipmentType.get("CLERSmallLaser")); m.setLocation(Protomech.LOC_LARM); ArrayList<Mounted> eqList = new ArrayList<>(); eqList.add(m); when(mockProto.getEquipment()).thenReturn(eqList); TestProtomech test = new TestProtomech(mockProto, option, null); assertTrue(test.hasIllegalEquipmentCombinations(new StringBuffer())); }
/** * Worker function that takes an entity, a location, an ammo type string and the critical index * of a weapons bay in the given location and attempts to add the ammo type there. * @param entity The entity we're working on loading * @param loc The location index on the entity * @param type The ammo type string * @param bayIndex The crit index of the bay where we want to load the ammo on the location where the bay is * @return A generated critical slot entry */ private void addExtraAmmoToBay(Entity entity, int loc, String type, String bayIndex) { // here, we need to do the following: // 1: get the bay to which this ammo belongs, and add it to said bay // 2: add the ammo to the entity as a "new" piece of equipment // 3: add the ammo to a crit slot on the bay's location int bayCritIndex = Integer.parseInt(bayIndex); Mounted bay = entity.getCritical(loc, bayCritIndex - 1).getMount(); Mounted ammo = new Mounted(entity, AmmoType.get(type)); try { entity.addEquipment(ammo, loc, bay.isRearMounted()); } catch(LocationFullException lfe) { // silently swallow it, since dropship locations have about a hundred crit slots } bay.addAmmoToBay(entity.getEquipmentNum(ammo)); }
Mounted mounted = null; if (mountIndex >= row.ammoMounts.size()) { mounted = new Mounted(entity, row.munitions.get(i)); try { entity.addEquipment(mounted, row.bay.getLocation(), row.bay.isRearMounted());
public Mounted addEquipment(EquipmentType etype, int loc, boolean rearMounted, int baMountLoc, boolean isArmored, boolean isTurreted, boolean isSponsonTurreted, boolean isPintleTurreted, boolean isOmniPodded) throws LocationFullException { Mounted mounted = new Mounted(this, etype); mounted.setArmored(isArmored); mounted.setBaMountLoc(baMountLoc); mounted.setMechTurretMounted(isTurreted); mounted.setSponsonTurretMounted(isSponsonTurreted); mounted.setPintleTurretMounted(isPintleTurreted); mounted.setOmniPodMounted(isOmniPodded); addEquipment(mounted, loc, rearMounted); return mounted; }
@Test public void testExcessiveSlots() { Protomech mockProto = createGenericMockProto(); Mounted m = new Mounted(mockProto, EquipmentType.get("CLERSmallLaser")); m.setLocation(Protomech.LOC_TORSO); ArrayList<Mounted> eqList = new ArrayList<>(); eqList.add(m); when(mockProto.getEquipment()).thenReturn(eqList); TestProtomech test = new TestProtomech(mockProto, option, null); assertFalse(test.hasIllegalEquipmentCombinations(new StringBuffer())); m.setLocation(Protomech.LOC_HEAD); assertTrue(test.hasIllegalEquipmentCombinations(new StringBuffer())); }
@Test public void testHeatSinkCount() { Protomech mockProto = createGenericMockProto(); Mounted laser = new Mounted(mockProto, EquipmentType.get("CLERSmallLaser")); laser.setLocation(Protomech.LOC_TORSO); ArrayList<Mounted> eqList = new ArrayList<>(); eqList.add(laser); when(mockProto.getEquipment()).thenReturn(eqList); when(mockProto.getWeaponList()).thenReturn(eqList); TestProtomech test = new TestProtomech(mockProto, option, null); assertEquals(test.getCountHeatSinks(), ((WeaponType) laser.getType()).getHeat()); eqList.add(new Mounted(mockProto, EquipmentType.get("CLUltraAC5"))); assertEquals(test.getCountHeatSinks(), ((WeaponType) laser.getType()).getHeat()); } }
public Mounted addEquipment(EquipmentType etype, EquipmentType etype2, int loc, boolean omniPod) throws LocationFullException { Mounted mounted = new Mounted(this, etype); Mounted mounted2 = new Mounted(this, etype2); mounted.setOmniPodMounted(omniPod); mounted2.setOmniPodMounted(omniPod); // check criticals for space if (getEmptyCriticals(loc) < 1) { throw new LocationFullException(mounted.getName() + " and " + mounted2.getName() + " do not fit in " + getLocationAbbr(loc) + " on " + getDisplayName() + "\n free criticals in location: " + getEmptyCriticals(loc) + ", criticals needed: " + 1); } super.addEquipment(mounted, loc, false); super.addEquipment(mounted2, loc, false); CriticalSlot cs = new CriticalSlot(mounted); cs.setMount2(mounted2); addCritical(loc, cs); return mounted; }
/** * Adds clan CASE in every location */ public void addClanCase() { boolean explosiveFound = false; EquipmentType clCase = EquipmentType.get("CLCASE"); for (int i = 0; i < locations(); i++) { explosiveFound = false; for (Mounted m : getEquipment()) { if (m.getType().isExplosive(m) && (m.getLocation() == i)) { explosiveFound = true; } } if (explosiveFound) { try { addEquipment(new Mounted(this, clCase), i, false); } catch (LocationFullException ex) { // um, that's impossible. } } } }
/** * Adds clan CASE in every location */ public void addClanCase() { boolean explosiveFound = false; EquipmentType clCase = EquipmentType.get("CLCASE"); for (int i = 0; i < locations(); i++) { // Ignore wings location: it's not a valid loc to put equipment in if (i == LOC_WINGS) { continue; } explosiveFound = false; for (Mounted m : getEquipment()) { if (m.getType().isExplosive(m) && (m.getLocation() == i)) { explosiveFound = true; } } if (explosiveFound) { try { addEquipment(new Mounted(this, clCase), i, false); } catch (LocationFullException ex) { // um, that's impossible. } } } }
@Test public void testRearMountTorsoOnly() { Protomech mockProto = createGenericMockProto(); Mounted m = new Mounted(mockProto, EquipmentType.get("CLERSmallLaser")); ArrayList<Mounted> eqList = new ArrayList<>(); eqList.add(m); when(mockProto.getEquipment()).thenReturn(eqList); TestProtomech test = new TestProtomech(mockProto, option, null); m.setLocation(Protomech.LOC_TORSO, true); assertFalse(test.hasIllegalEquipmentCombinations(new StringBuffer())); m.setLocation(Protomech.LOC_LARM, true); assertTrue(test.hasIllegalEquipmentCombinations(new StringBuffer())); m.setLocation(Protomech.LOC_RARM, true); assertTrue(test.hasIllegalEquipmentCombinations(new StringBuffer())); m.setLocation(Protomech.LOC_MAINGUN, true); assertTrue(test.hasIllegalEquipmentCombinations(new StringBuffer())); }
Mounted ammo = new Mounted((Entity)this, EquipmentType.get(BombType.getBombInternalName(type))); ammo.setShotsLeft(1);