private JMenu createClubMenu() { JMenu menu = new JMenu("Weapon"); for (int pos = 0; pos < myEntity.getClubs().size(); pos++) { Mounted club = myEntity.getClubs().get(pos); if (!club.isDestroyed()) { menu.add(createClubJMenuItem(club.getName(), pos)); } } return menu; }
/** * Returns the number of destroyed jump jets. */ public int damagedJumpJets() { int jumpJets = 0; for (Mounted mounted : getMisc()) { EquipmentType etype = mounted.getType(); if (!mounted.isDestroyed()) { continue; } if (etype.hasFlag(MiscType.F_JUMP_JET)) { jumpJets++; } } return jumpJets; }
public boolean hasModularArmor(int loc) { for (Mounted mount : this.getEquipment()) { if ((loc == -1) || (mount.getLocation() == loc)) { if (!mount.isDestroyed() && (mount.getType() instanceof MiscType) && ((MiscType) mount.getType()) .hasFlag(MiscType.F_MODULAR_ARMOR)) { return true; } } } return false; }
public int getHeatInArc(int location, boolean rearMount) { int arcHeat = 0; for (Mounted mounted : getTotalWeaponList()) { // is the weapon usable? if (mounted.isDestroyed() || mounted.isJammed()) { continue; } if ((mounted.getLocation() == location) && (mounted.isRearMounted() == rearMount)) { arcHeat += mounted.getCurrentHeat(); } } return arcHeat; }
private Entity setupGunEmplacement() { Entity testEntity = Mockito.mock(GunEmplacement.class); Mockito.when(testEntity.calculateBattleValue()).thenCallRealMethod(); Mockito.when(testEntity.calculateBattleValue(Mockito.anyBoolean(), Mockito.anyBoolean())).thenCallRealMethod(); Mockito.when(testEntity.getTotalArmor()).thenReturn(100); ArrayList<Mounted> equipment = new ArrayList<Mounted>(2); WeaponType ppcType = Mockito.mock(WeaponType.class); Mockito.when(ppcType.getBV(Mockito.any(Entity.class))).thenReturn(50.0); Mounted ppc = Mockito.mock(Mounted.class); Mockito.when(ppc.getType()).thenReturn(ppcType); Mockito.when(ppc.isDestroyed()).thenReturn(false); equipment.add(ppc); equipment.add(ppc); Mockito.when(testEntity.getEquipment()).thenReturn(equipment); Mockito.when(testEntity.getWeaponList()).thenReturn(equipment); Mockito.when(testEntity.getAmmo()).thenReturn(new ArrayList<Mounted>(0)); return testEntity; }
/** * Returns the number of destroyed heat sinks. */ public int damagedHeatSinks() { int sinks = 0; for (Mounted mounted : getMisc()) { EquipmentType etype = mounted.getType(); if (!mounted.isDestroyed()) { continue; } if (etype.hasFlag(MiscType.F_HEAT_SINK) || etype.hasFlag(MiscType.F_DOUBLE_HEAT_SINK) || etype.hasFlag(MiscType.F_IS_DOUBLE_HEAT_SINK_PROTOTYPE)) { sinks++; } } return sinks; }
public int getNumberOfSinks() { int sinks = 0; for (Mounted mounted : getMisc()) { if (mounted.isDestroyed() || mounted.isBreached()) { continue; } if (mounted.getType().hasFlag(MiscType.F_HEAT_SINK)) { sinks++; } else if (mounted.getType().hasFlag(MiscType.F_DOUBLE_HEAT_SINK)) { sinks++; } } return sinks; }
/** * does this mech have working jump boosters? * * @return */ public boolean hasJumpBoosters() { boolean jumpBoosters = false; for (Mounted mEquip : getMisc()) { MiscType mtype = (MiscType) mEquip.getType(); if (mtype.hasFlag(MiscType.F_JUMP_BOOSTER)) { // one crit destroyed they all all screwed // --Torren if (mEquip.isBreached() || mEquip.isDestroyed() || mEquip.isMissing()) { return false; } jumpBoosters = true; } } return jumpBoosters; }
public boolean hasLinkedMGA(Mounted mounted) { for (Mounted m : getWeaponList()) { if ((m.getLocation() == mounted.getLocation()) && m.getType().hasFlag(WeaponType.F_MGA) && !(m.isDestroyed() || m.isBreached()) && m.getBayWeapons().contains(getEquipmentNum(mounted)) && m.getType().hasModes() && m.curMode().equals("Linked")) { return true; } } return false; }
/** * Checks if a mech has an armed MASC system. Note that the mech will have * to exceed its normal run to actually engage the MASC system */ public boolean hasArmedMASC() { for (Mounted m : getEquipment()) { if (!m.isDestroyed() && !m.isBreached() && (m.getType() instanceof MiscType) && m.getType().hasFlag(MiscType.F_MASC) && m.curMode().equals("Armed")) { return true; } } return false; }
@Override public void updateConditionFromEntity(boolean checkForDestruction) { if(null != unit) { Mounted mounted = unit.getEntity().getEquipment(equipmentNum); if(null != mounted) { capacity = mounted.getAmmoCapacity(); type = mounted.getType(); if(mounted.isMissing() || mounted.isDestroyed()) { mounted.setShotsLeft(0); return; } shotsNeeded = getFullShots() - mounted.getBaseShotsLeft(); } } }
@Override public void updateConditionFromEntity(boolean checkForDestruction) { if(null != unit) { Mounted mounted = unit.getEntity().getEquipment(equipmentNum); if(null != mounted) { if(mounted.isMissing() || mounted.isDestroyed()) { mounted.setShotsLeft(0); remove(false); return; } if (type == mounted.getType()) { shotsNeeded = getFullShots() - mounted.getBaseShotsLeft(); } } } }
/** * Set the retractable blade in the given location as extended Takes the * first piece of appropriate equipment */ public void extendBlade(int loc) { for (Mounted m : getEquipment()) { if ((m.getLocation() == loc) && !m.isDestroyed() && !m.isBreached() && (m.getType() instanceof MiscType) && m.getType().hasFlag(MiscType.F_CLUB) && m.getType().hasSubType(MiscType.S_RETRACTABLE_BLADE)) { m.setMode("extended"); return; } } }
@Override protected void useAmmo() { int[] payload = waa.getBombPayload(); if (!ae.isBomber() || (null == payload)) { return; } for (int type = 0; type < payload.length; type++) { for (int i = 0; i < payload[type]; i++) { // find the first mounted bomb of this type and drop it for (Mounted bomb : ae.getBombs()) { if (!bomb.isDestroyed() && (bomb.getUsableShotsLeft() > 0) && (((BombType) bomb.getType()).getBombType() == type)) { bomb.setShotsLeft(0); break; } } } } super.useAmmo(); }
/** * Checks if a mech has an armed MASC system. Note that the mech will have * to exceed its normal run to actually engage the MASC system */ public boolean hasArmedMASC() { for (Mounted m : getEquipment()) { if (!m.isDestroyed() && !m.isBreached() && (m.getType() instanceof MiscType) && m.getType().hasFlag(MiscType.F_MASC) && (m.curMode().equals("Armed") || m.getType().hasSubType( MiscType.S_JETBOOSTER))) { return true; } } return false; }
/** * Does the entity have a retracted blade in the given location */ @Override public boolean hasRetractedBlade(int loc) { for (Mounted m : getEquipment()) { if ((m.getLocation() == loc) && !m.isDestroyed() && !m.isBreached() && (m.getType() instanceof MiscType) && m.getType().hasFlag(MiscType.F_CLUB) && m.getType().hasSubType(MiscType.S_RETRACTABLE_BLADE) && !m .curMode().equals("extended")) { return true; } } return false; }
/** * Checks to see if this unit has a functional Blue Shield Particle Field * Damper that is turned on * * @return <code>true</code> if the entity has a working, switched on blue * field <code>false</code> otherwise */ public boolean hasActiveBlueShield() { if (!isShutDown()) { for (Mounted m : getMisc()) { EquipmentType type = m.getType(); if ((type instanceof MiscType) && type.hasFlag(MiscType.F_BLUE_SHIELD) && m.curMode().equals("On")) { return !(m.isDestroyed() || m.isMissing() || m.isBreached() || isShutDown()); } } } return false; }
/** * Checks is Biped Mek has functional AES in the location. Only works for * Arms */ @Override public boolean hasFunctionalArmAES(int location) { boolean hasAES = false; if ((location != Mech.LOC_RARM) && (location != Mech.LOC_LARM)) { return false; } for (Mounted mounted : getMisc()) { if ((mounted.getLocation() == location) && mounted.getType().hasFlag(MiscType.F_ACTUATOR_ENHANCEMENT_SYSTEM) && !mounted.isDestroyed() && !mounted.isBreached() && !mounted.isMissing()) { hasAES = true; } // AES is destroyed their for it cannot be used. else if ((mounted.getLocation() == location) && mounted.getType().hasFlag(MiscType.F_ACTUATOR_ENHANCEMENT_SYSTEM)) { return false; } } return hasAES; }
/** * QuadVees cannot benefit from MASC in vehicle mode, so in that case we only return true if there * is an armed supercharger. */ @Override public boolean hasArmedMASC() { boolean superchargerOnly = getConversionMode() == CONV_MODE_VEHICLE; for (Mounted m : getEquipment()) { if (!m.isDestroyed() && !m.isBreached() && (m.getType() instanceof MiscType) && m.getType().hasFlag(MiscType.F_MASC) && (!superchargerOnly || m.getType().getSubType() == MiscType.S_SUPERCHARGER) && m.curMode().equals("Armed")) { return true; } } return false; }
/** * Does the entity have a retracted blade in the given location */ @Override public boolean hasRetractedBlade(int loc) { for (Mounted m : getEquipment()) { if ((m.getLocation() == loc) && !m.isDestroyed() && !m.isBreached() && (m.getType() instanceof MiscType) && m.getType().hasFlag(MiscType.F_CLUB) && m.getType().hasSubType(MiscType.S_RETRACTABLE_BLADE) && !m.curMode().equals("extended")) { return true; } } return false; }