diff --git a/megamek/i18n/megamek/client/messages.properties b/megamek/i18n/megamek/client/messages.properties index 667aad271fb..51d49f68624 100644 --- a/megamek/i18n/megamek/client/messages.properties +++ b/megamek/i18n/megamek/client/messages.properties @@ -4477,8 +4477,8 @@ BotConfigDialog.fallShameSliderMin=Highway Menace BotConfigDialog.fallShameSliderMax=Never takes a risk. BotConfigDialog.fallShameSliderTitle=Piloting Caution BotConfigDialog.fallShameToolTip=Piloting Caution: How much do I want to avoid failed Piloting Rolls? -BotConfigDialog.braverySliderMin=I fear nothing! -BotConfigDialog.braverySliderMax=Run Away! +BotConfigDialog.braverySliderMax=I fear nothing! +BotConfigDialog.braverySliderMin=Run Away! BotConfigDialog.braverySliderTitle=Bravery BotConfigDialog.braveryTooltip=Bravery: How worried about enemy damage am I? BotConfigDialog.targetsLabel=Strategic Targets diff --git a/megamek/src/megamek/client/bot/princess/BasicPathRanker.java b/megamek/src/megamek/client/bot/princess/BasicPathRanker.java index cb1090e8ea4..397ac667231 100644 --- a/megamek/src/megamek/client/bot/princess/BasicPathRanker.java +++ b/megamek/src/megamek/client/bot/princess/BasicPathRanker.java @@ -801,6 +801,7 @@ private double checkHexForHazards(Hex hex, Entity movingUnit, boolean endHex, Mo Terrains.BUILDING, Terrains.BRIDGE, Terrains.BLACK_ICE, + Terrains.SNOW, Terrains.SWAMP, Terrains.MUD, Terrains.TUNDRA)); @@ -854,6 +855,12 @@ private double checkHexForHazards(Hex hex, Entity movingUnit, boolean endHex, Mo case Terrains.BLACK_ICE: hazardValue += calcIceHazard(movingUnit, hex, step, movePath, jumpLanding, logMsg); break; + case Terrains.SNOW: + hazardValue += calcSnowHazard(hex, endHex, movingUnit, logMsg); + break; + case Terrains.RUBBLE: + hazardValue += calcRubbleHazard(hex, endHex, movingUnit, jumpLanding, step, logMsg); + break; case Terrains.SWAMP: hazardValue += calcSwampHazard(hex, endHex, movingUnit, jumpLanding, step, logMsg); break; @@ -1317,6 +1324,35 @@ private double calcBogDownFactor(String name, boolean endHex, boolean jumpLandin return factor; } + private double calcSnowHazard(Hex hex, boolean endHex, Entity movingUnit, StringBuilder logMsg) { + logMsg.append("\n\tCalculating Deep Snow hazard: "); + + // Hover units are above the surface. + if (EntityMovementMode.HOVER == movingUnit.getMovementMode() + || EntityMovementMode.WIGE == movingUnit.getMovementMode()) { + logMsg.append("Hovering above Snow (0)."); + return 0; + } + + if (hex.terrainLevel(Terrains.SNOW) > 1) { + // PSR checks _to bog down_ and _escape bogged down_ are at (mod - 1); all others are at a +1 mod + int psrMod = 0; + // Infantry use 4+ check instead of Pilot / Driving skill + int pilotSkill = (movingUnit.isInfantry()) ? 4 : movingUnit.getCrew().getPiloting(); + double hazard; + + // Base hazard is arbitrarily set to 10 + hazard = 10 * calcBogDownFactor( + "Deep Snow", endHex, false, pilotSkill, psrMod, logMsg); + + logMsg.append("\nBase hazard value: ").append(LOG_DECIMAL.format(hazard)); + return Math.round(hazard); + } + + // Thin snow poses no hazard; MP malus accounted for elsewhere. + return 0; + } + private double calcSwampHazard(Hex hex, boolean endHex, Entity movingUnit, boolean jumpLanding, MoveStep step, StringBuilder logMsg) { @@ -1410,6 +1446,42 @@ private double calcTundraHazard(boolean endHex, boolean jumpLanding, Entity movi return Math.round(hazard); } + private double calcRubbleHazard(Hex hex, boolean endHex, Entity movingUnit, + boolean jumpLanding, MoveStep step, + StringBuilder logMsg) { + + logMsg.append("\n\tCalculating Rubble hazard: "); + + // Hover units are above the surface. + if (EntityMovementMode.HOVER == movingUnit.getMovementMode() + || EntityMovementMode.WIGE == movingUnit.getMovementMode()) { + logMsg.append("Hovering above Rubble (0)."); + return 0; + } + + double hazard = 0; + + boolean caresAboutRubble = ( + (!jumpLanding || endHex) + && (hex.terrainLevel(Terrains.RUBBLE) > 0) && (hex.terrainLevel(Terrains.PAVEMENT) == Terrain.LEVEL_NONE) + && movingUnit.canFall() + ); + + if (caresAboutRubble) { + // PSR checks are at +0 for Rubble levels up to 6, Ultra, which is +1 + int psrMod = (hex.terrainLevel(Terrains.RUBBLE) < 6) ? 0 : 1; + if (movingUnit.hasAbility(OptionsConstants.PILOT_TM_MOUNTAINEER)) { + psrMod -= 1; + } + int pilotSkill = movingUnit.getCrew().getPiloting(); + + // The only hazard is the +1 to PSRs, which are difficult to quantify + hazard = calcBogDownFactor( + "Rubble", endHex, jumpLanding, pilotSkill, psrMod, false, logMsg); + } + logMsg.append("\nBase hazard value: ").append(LOG_DECIMAL.format(hazard)); + return Math.round(hazard); + } /** * Simple data structure that holds a separate firing and physical damage number. * diff --git a/megamek/src/megamek/client/ui/dialogs/BotConfigDialog.java b/megamek/src/megamek/client/ui/dialogs/BotConfigDialog.java index 5c698c38582..aacdbbf56c7 100644 --- a/megamek/src/megamek/client/ui/dialogs/BotConfigDialog.java +++ b/megamek/src/megamek/client/ui/dialogs/BotConfigDialog.java @@ -37,7 +37,9 @@ import org.apache.logging.log4j.LogManager; import javax.swing.*; +import javax.swing.border.Border; import javax.swing.border.EmptyBorder; +import javax.swing.border.TitledBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.ListSelectionEvent; @@ -439,7 +441,11 @@ private boolean isChangedPreset() { private JPanel buildSlider(JSlider thisSlider, String minMsgProperty, String maxMsgProperty, String toolTip, String title) { + TitledBorder border = BorderFactory.createTitledBorder(title); + border.setTitlePosition(TitledBorder.TOP); + border.setTitleJustification(TitledBorder.CENTER); var result = new TipPanel(); + result.setBorder(border); result.setLayout(new BoxLayout(result, BoxLayout.PAGE_AXIS)); result.setToolTipText(toolTip); thisSlider.setToolTipText(toolTip); @@ -455,6 +461,7 @@ private JPanel buildSlider(JSlider thisSlider, String minMsgProperty, result.add(panLabels); result.add(thisSlider); + result.revalidate(); return result; } diff --git a/megamek/src/megamek/common/Compute.java b/megamek/src/megamek/common/Compute.java index 253fecc3d49..8f7009d58f1 100644 --- a/megamek/src/megamek/common/Compute.java +++ b/megamek/src/megamek/common/Compute.java @@ -566,7 +566,12 @@ public static boolean isPilotingSkillNeeded(Game game, int entityId, Coords src, Coords dest, EntityMovementType movementType, boolean isTurning, boolean prevStepIsOnPavement, int srcElevation, int destElevation, MoveStep moveStep) { + // It's possible to get a real ID for an entity we've forgotten (Double Blind, for instance). final Entity entity = game.getEntity(entityId); + if (entity == null) { + throw new IllegalArgumentException("Entity invalid. ID " + entityId); + } + final Hex srcHex = game.getBoard().getHex(src); final Hex destHex = game.getBoard().getHex(dest); final boolean isInfantry = (entity instanceof Infantry); @@ -574,9 +579,6 @@ public static boolean isPilotingSkillNeeded(Game game, int entityId, - (srcElevation + srcHex.getLevel()); // arguments valid? - if (entity == null) { - throw new IllegalArgumentException("Entity invalid. ID " + entityId); - } if (src.distance(dest) > 1) { throw new IllegalArgumentException("Coordinates must be adjacent."); } diff --git a/megamek/src/megamek/common/Entity.java b/megamek/src/megamek/common/Entity.java index e28e6001338..c82af414bcd 100644 --- a/megamek/src/megamek/common/Entity.java +++ b/megamek/src/megamek/common/Entity.java @@ -1,17 +1,17 @@ /* -* Copyright (c) 2000-2005 - Ben Mazur (bmazur@sev.org). -* Copyright (c) 2018-2022 - The MegaMek Team. All Rights Reserved. -* -* This program is free software; you can redistribute it and/or modify it under -* the terms of the GNU General Public License as published by the Free Software -* Foundation; either version 2 of the License, or (at your option) any later -* version. -* -* This program is distributed in the hope that it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -* details. -*/ + * Copyright (c) 2000-2005 - Ben Mazur (bmazur@sev.org). + * Copyright (c) 2018-2022 - The MegaMek Team. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + */ package megamek.common; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; @@ -135,7 +135,7 @@ public abstract class Entity extends TurnOrdered implements Transporter, Targeta public static final int DMG_CRIPPLED = 4; public static final int USE_STRUCTURAL_RATING = -1; - + protected transient Game game; protected int id = Entity.NONE; @@ -352,7 +352,7 @@ public abstract class Entity extends TurnOrdered implements Transporter, Targeta private OffBoardDirection offBoardDirection = OffBoardDirection.NONE; private OffBoardDirection retreatedDirection = OffBoardDirection.NONE; - protected int[] vectors = { 0, 0, 0, 0, 0, 0 }; + protected int[] vectors = {0, 0, 0, 0, 0, 0}; private int recoveryTurn = 0; // need to keep a list of areas that this entity has passed through on the current turn @@ -736,9 +736,9 @@ public abstract class Entity extends TurnOrdered implements Transporter, Targeta // is calculated by getArmorTonnage protected double armorTonnage; - protected static int[] MASC_FAILURE = { 3, 5, 7, 11, 13, 13, 13 }; - protected static int[] ALTERNATE_MASC_FAILURE = { 0, 3, 5, 7, 11, 13, 13, 13 }; - protected static int[] ALTERNATE_MASC_FAILURE_ENHANCED = { 0, 3, 3, 5, 7, 11, 13, 13, 13 }; + protected static int[] MASC_FAILURE = {3, 5, 7, 11, 13, 13, 13}; + protected static int[] ALTERNATE_MASC_FAILURE = {0, 3, 5, 7, 11, 13, 13, 13}; + protected static int[] ALTERNATE_MASC_FAILURE_ENHANCED = {0, 3, 3, 5, 7, 11, 13, 13, 13}; // MASCLevel is the # of turns MASC has been used previously protected int nMASCLevel = 0; @@ -835,8 +835,8 @@ public abstract class Entity extends TurnOrdered implements Transporter, Targeta * Primarily used by Princess to speed up TAG utility calculations. */ protected ArrayList incomingGuidedAttacks; - - /** + + /** * Map containing all the objects this entity is carrying as cargo, indexed by location */ private Map carriedObjects = new HashMap<>(); @@ -845,7 +845,7 @@ public abstract class Entity extends TurnOrdered implements Transporter, Targeta * Round-long flag indicating that this entity has picked up an object this round. */ private boolean endOfTurnCargoInteraction; - + /** The icon for this unit; This is empty unless the unit file has an embedded icon. */ protected Base64Image icon = new Base64Image(); @@ -1235,7 +1235,7 @@ public String getTechBaseDescription() { return techBase; } - public static List getTechBaseDescriptions(){ + public static List getTechBaseDescriptions() { List result = new ArrayList<>(); result.add(Messages.getString("Entity.IS")); result.add(Messages.getString("Entity.Clan")); @@ -1303,11 +1303,11 @@ public void recalculateTechAdvancement() { .setStaticTechLevel(SimpleTechLevel.STANDARD); // Tech Progression tweaked to combine IntOps with TRO Prototypes/3145 NTNU RS protected static final TechAdvancement TA_ARMORED_COMPONENT = new TechAdvancement(TECH_BASE_ALL) - .setISAdvancement(3061, 3082,DATE_NONE,DATE_NONE,DATE_NONE) + .setISAdvancement(3061, 3082, DATE_NONE, DATE_NONE, DATE_NONE) .setISApproximate(false, true, false, false, false) - .setClanAdvancement(3061, 3082,DATE_NONE,DATE_NONE,DATE_NONE) + .setClanAdvancement(3061, 3082, DATE_NONE, DATE_NONE, DATE_NONE) .setClanApproximate(false, true, false, false, false) - .setPrototypeFactions(F_CSF,F_FW).setProductionFactions(F_CJF,F_FW) + .setPrototypeFactions(F_CSF, F_FW).setProductionFactions(F_CJF, F_FW) .setTechRating(RATING_E).setAvailability(RATING_X, RATING_X, RATING_F, RATING_E) .setStaticTechLevel(SimpleTechLevel.ADVANCED); @@ -1381,7 +1381,7 @@ public void setManualShutdown(boolean tf) { public void performManualShutdown() { if (isManualShutdown() || (getTaserShutdownRounds() != 0) - || isShutDown()) { + || isShutDown()) { return; } setShutDown(true); @@ -1501,7 +1501,7 @@ public void setOmni(boolean omni) { * Determines where to place equipment that does not require a specific location. What * this means varies by {@link Entity} type. * - * @return The location to place equipment that is not required to be assigned a location, + * @return The location to place equipment that is not required to be assigned a location, * defaulting to Entity.LOC_NONE for unit types that do not have such a location. */ public int getBodyLocation() { @@ -1558,7 +1558,7 @@ public boolean isEnemyOf(Entity other) { return ((id != other.getId()) && (ownerId != other.ownerId)); } return (id != other.getId()) - && ((null == other.getOwner()) || getOwner().isEnemyOf(other.getOwner())); + && ((null == other.getOwner()) || getOwner().isEnemyOf(other.getOwner())); } public Crew getCrew() { @@ -1727,7 +1727,7 @@ public boolean isActive(int turn) { */ public boolean isSelectableThisTurn() { return !done && (conveyance == Entity.NONE) && !unloadedThisTurn - && !isClearingMinefield() && !isCarcass(); + && !isClearingMinefield() && !isCarcass(); } /** @@ -1736,7 +1736,7 @@ public boolean isSelectableThisTurn() { */ public boolean isLoadableThisTurn() { return (delta_distance == 0) && (conveyance == Entity.NONE) - && !unloadedThisTurn && !isClearingMinefield() && (getTractor() == Entity.NONE); + && !unloadedThisTurn && !isClearingMinefield() && (getTractor() == Entity.NONE); } /** @@ -1760,8 +1760,8 @@ public boolean wasLoadedThisTurn() { */ public boolean isTargetable() { return !destroyed && !doomed && deployed && !isOffBoard() - && (conveyance == Entity.NONE) && !captured - && (getPosition() != null); + && (conveyance == Entity.NONE) && !captured + && (getPosition() != null); } public boolean isProne() { @@ -1867,7 +1867,7 @@ public boolean isTargetOfDisplacementAttack() { public @Nullable DisplacementAttackAction findTargetedDisplacement() { for (Entity other : game.getEntitiesVector()) { if (other.hasDisplacementAttack() - && (other.getDisplacementAttack().getTargetId() == id)) { + && (other.getDisplacementAttack().getTargetId() == id)) { return other.getDisplacementAttack(); } } @@ -2011,7 +2011,7 @@ public void setElevation(int elevation) { * to be at w/r/t its new hex. */ public int calcElevation(Hex current, Hex next, int assumedElevation, - boolean climb, boolean wigeEndClimbPrevious) { + boolean climb, boolean wigeEndClimbPrevious) { int retVal = assumedElevation; if (isAero()) { return retVal; @@ -2052,7 +2052,7 @@ public int calcElevation(Hex current, Hex next, int assumedElevation, // Elevation is this height of the level above the actual surface elevation of the hex. retVal = nextLevel - next.getLevel(); } else if (((getMovementMode().isSubmarine() || getMovementMode().isUMUInfantry()) - && next.containsTerrain(Terrains.WATER) && current.containsTerrain(Terrains.WATER)) + && next.containsTerrain(Terrains.WATER) && current.containsTerrain(Terrains.WATER)) || getMovementMode().isVTOL() || (getMovementMode().isQuadSwim() && hasUMU()) || (getMovementMode().isBipedSwim() && hasUMU())) { @@ -2070,7 +2070,7 @@ public int calcElevation(Hex current, Hex next, int assumedElevation, if (current.containsTerrain(Terrains.WATER)) { prevWaterLevel = current.terrainLevel(Terrains.WATER); if (!(current.containsTerrain(Terrains.ICE)) - || (assumedElevation < 0)) { + || (assumedElevation < 0)) { // count water, only if the entity isn't on ice surface retVal += current.terrainLevel(Terrains.WATER); } @@ -2083,8 +2083,8 @@ public int calcElevation(Hex current, Hex next, int assumedElevation, // mech on the surface will stay on the surface if (((waterLevel == 1) && (prevWaterLevel == 1)) - || ((prevWaterLevel <= 2) && climb) - || (assumedElevation >= 0)) { + || ((prevWaterLevel <= 2) && climb) + || (assumedElevation >= 0)) { retVal += waterLevel; } } @@ -2096,7 +2096,7 @@ public int calcElevation(Hex current, Hex next, int assumedElevation, int bldcur = Math.max(-current.depth(true), current.terrainLevel(Terrains.BLDG_ELEV)); int bldnex = Math.max(-next.depth(true), next.terrainLevel(Terrains.BLDG_ELEV)); if (((assumedElevation == bldcur) - && (climb || isJumpingNow) && (this instanceof Mech)) + && (climb || isJumpingNow) && (this instanceof Mech)) || (retVal > bldnex)) { retVal = bldnex; } else if ((bldnex + next.getLevel()) > (bldcur + current.getLevel())) { @@ -2104,7 +2104,7 @@ public int calcElevation(Hex current, Hex next, int assumedElevation, int collapsedBasement = next.terrainLevel(Terrains.BLDG_BASE_COLLAPSED); if (climb || isJumpingNow) { retVal = bldnex + next.getLevel(); - // If the basement is collapsed, there is no level 0 + // If the basement is collapsed, there is no level 0 } else if ((assumedElevation == 0) && !nextBasement.isUnknownOrNone() && (collapsedBasement > 0)) { @@ -2118,7 +2118,7 @@ public int calcElevation(Hex current, Hex next, int assumedElevation, if (climb || isJumpingNow) { retVal = bldnex + next.getLevel(); } else if (!currentBasement.isUnknownOrNone() - && (assumedElevation == -currentBasement.getDepth())) { + && (assumedElevation == -currentBasement.getDepth())) { retVal = -BasementType.getType(next.terrainLevel(Terrains.BLDG_BASEMENT_TYPE)).getDepth(); } else { retVal += current.getLevel(); @@ -2130,7 +2130,7 @@ public int calcElevation(Hex current, Hex next, int assumedElevation, if ((getMovementMode() != EntityMovementMode.NAVAL) && (getMovementMode() != EntityMovementMode.HYDROFOIL) && (next.containsTerrain(Terrains.BRIDGE) || current - .containsTerrain(Terrains.BRIDGE))) { + .containsTerrain(Terrains.BRIDGE))) { int bridgeElev; if (next.containsTerrain(Terrains.BRIDGE)) { bridgeElev = next.terrainLevel(Terrains.BRIDGE_ELEV); @@ -2349,8 +2349,8 @@ public boolean isElevationValid(int assumedElevation, Hex hex) { if (getMovementMode() == EntityMovementMode.VTOL) { if ((this instanceof Infantry) && (hex.containsTerrain(Terrains.BUILDING) - || hex.containsTerrain(Terrains.WOODS) - || hex.containsTerrain(Terrains.JUNGLE))) { + || hex.containsTerrain(Terrains.WOODS) + || hex.containsTerrain(Terrains.JUNGLE))) { // VTOL BA (sylph) can move as ground unit as well return ((assumedElevation <= 50) && (assumedAlt >= hex.floor())); } else { @@ -2377,10 +2377,10 @@ public boolean isElevationValid(int assumedElevation, Hex hex) { return allowed; } } else if ((getMovementMode() == EntityMovementMode.SUBMARINE) - || ((getMovementMode() == EntityMovementMode.INF_UMU) && hex + || ((getMovementMode() == EntityMovementMode.INF_UMU) && hex .containsTerrain(Terrains.WATER)) - || ((getMovementMode() == EntityMovementMode.QUAD_SWIM) && hasUMU()) - || ((getMovementMode() == EntityMovementMode.BIPED_SWIM) && hasUMU())) { + || ((getMovementMode() == EntityMovementMode.QUAD_SWIM) && hasUMU()) + || ((getMovementMode() == EntityMovementMode.BIPED_SWIM) && hasUMU())) { if (this instanceof Infantry && ((Infantry) this).hasSpecialization(Infantry.SCUBA) && getMovementMode() == EntityMovementMode.INF_UMU) { return assumedAlt >= Math.max(hex.floor(), -2) @@ -2388,7 +2388,7 @@ && getMovementMode() == EntityMovementMode.INF_UMU) { } return ((assumedAlt >= hex.floor()) && (assumedAlt <= hex.getLevel())); } else if ((getMovementMode() == EntityMovementMode.HYDROFOIL) - || (getMovementMode() == EntityMovementMode.NAVAL)) { + || (getMovementMode() == EntityMovementMode.NAVAL)) { return assumedAlt == hex.getLevel(); } else if (getMovementMode() == EntityMovementMode.WIGE) { // WiGEs can possibly be at any location above or on the surface @@ -2396,8 +2396,8 @@ && getMovementMode() == EntityMovementMode.INF_UMU) { } else { // regular ground units if (hex.containsTerrain(Terrains.ICE) - || (((getMovementMode() == EntityMovementMode.HOVER) || hasWorkingMisc(MiscType.F_FULLY_AMPHIBIOUS)) && - hex.containsTerrain(Terrains.WATER))) { + || (((getMovementMode() == EntityMovementMode.HOVER) || hasWorkingMisc(MiscType.F_FULLY_AMPHIBIOUS)) && + hex.containsTerrain(Terrains.WATER))) { // surface of ice is OK, surface of water is OK for hovers and "fully amphibious" units if (assumedAlt == hex.getLevel()) { return true; @@ -2428,7 +2428,7 @@ && getMovementMode() == EntityMovementMode.INF_UMU) { // Mechs, protos and infantry can occupy any floor in the // building if ((this instanceof Mech) || (this instanceof Protomech) - || (this instanceof Infantry)) { + || (this instanceof Infantry)) { return (assumedAlt >= (hex.getLevel() - hex.depth(true))) && (assumedAlt <= hex.ceiling()); } } @@ -2463,7 +2463,7 @@ public boolean isOnAtmosphericGroundMap() { // covers maps that are within a planet's gravity well getGame().getBoard().inAtmosphere(); PlanetaryConditions conditions = getGame().getPlanetaryConditions(); - return conditions.getAtmosphere().isDenserThan(Atmosphere.TRACE) + return conditions.getAtmosphere().isDenserThan(Atmosphere.TRACE) && onGroundOrinAtmosphere; } @@ -2545,7 +2545,7 @@ protected void setDisplayName(String displayName) { */ public synchronized void generateDisplayName() { displayName = createDisplayName(duplicateMarker); - } + } /** * Creates a display name for the entity. @@ -2725,7 +2725,7 @@ public void postProcessFacingChange() { /** * @return whether this entity already changed a secondary facing in an earlier phase */ - public boolean getAlreadyTwisted(){ + public boolean getAlreadyTwisted() { return twistedPhase != null && twistedPhase.isBefore(game.getPhase()); } @@ -2747,18 +2747,18 @@ public boolean canUnjamRAC() { for (WeaponMounted mounted : getTotalWeaponList()) { int ammotype = mounted.getType().getAmmoType(); if ((ammotype == AmmoType.T_AC_ROTARY) - && mounted.isJammed() && !mounted.isDestroyed()) { + && mounted.isJammed() && !mounted.isDestroyed()) { return true; } if (((ammotype == AmmoType.T_AC_ULTRA) - || (ammotype == AmmoType.T_AC_ULTRA_THB) - || (ammotype == AmmoType.T_AC) - || (ammotype == AmmoType.T_LAC) - || (ammotype == AmmoType.T_AC_IMP) - || (ammotype == AmmoType.T_PAC)) - && mounted.isJammed() - && !mounted.isDestroyed() - && game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_UNJAM_UAC)) { + || (ammotype == AmmoType.T_AC_ULTRA_THB) + || (ammotype == AmmoType.T_AC) + || (ammotype == AmmoType.T_LAC) + || (ammotype == AmmoType.T_AC_IMP) + || (ammotype == AmmoType.T_PAC)) + && mounted.isJammed() + && !mounted.isDestroyed() + && game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_UNJAM_UAC)) { return true; } } @@ -2771,140 +2771,140 @@ public boolean canUnjamRAC() { public boolean canFlipArms() { return false; } - + /** * Returns true if the entity can pick up ground objects */ public boolean canPickupGroundObject() { - return false; + return false; } - + /** * The maximum tonnage of ground objects that can be picked up by this unit */ public double maxGroundObjectTonnage() { - return 0.0; + return 0.0; } - + /** * Put a ground object into the given location */ public void pickupGroundObject(ICarryable carryable, Integer location) { - if (carriedObjects == null) { - carriedObjects = new HashMap<>(); - } - - // "none" means we should just put it wherever it goes by default. - // rules checks are done prior to this, so we just set the data - if (location == null || location == LOC_NONE) { - for (Integer defaultLocation : getDefaultPickupLocations()) { - carriedObjects.put(defaultLocation, carryable); - } - } else { - carriedObjects.put(location, carryable); - } - endOfTurnCargoInteraction = true; - } - + if (carriedObjects == null) { + carriedObjects = new HashMap<>(); + } + + // "none" means we should just put it wherever it goes by default. + // rules checks are done prior to this, so we just set the data + if (location == null || location == LOC_NONE) { + for (Integer defaultLocation : getDefaultPickupLocations()) { + carriedObjects.put(defaultLocation, carryable); + } + } else { + carriedObjects.put(location, carryable); + } + endOfTurnCargoInteraction = true; + } + /** * Remove a specific carried object - useful for when you have the object * but not its location, or when an object is being carried in multiple locations. */ public void dropGroundObject(ICarryable carryable, boolean isUnload) { - // build list of locations to clear out - List locationsToClear = new ArrayList<>(); - - for (Integer location : carriedObjects.keySet()) { - if (carriedObjects.get(location).equals(carryable)) { - locationsToClear.add(location); - } - } - - for (Integer location : locationsToClear) { - carriedObjects.remove(location); - } - - // if it's not an "unload", we're going to leave the "end of turn cargo interaction" flag alone - if (isUnload) { - endOfTurnCargoInteraction = true; - } - } - - /** + // build list of locations to clear out + List locationsToClear = new ArrayList<>(); + + for (Integer location : carriedObjects.keySet()) { + if (carriedObjects.get(location).equals(carryable)) { + locationsToClear.add(location); + } + } + + for (Integer location : locationsToClear) { + carriedObjects.remove(location); + } + + // if it's not an "unload", we're going to leave the "end of turn cargo interaction" flag alone + if (isUnload) { + endOfTurnCargoInteraction = true; + } + } + + /** * Remove a ground object (cargo) from the given location */ public void dropGroundObject(int location) { - carriedObjects.remove(location); + carriedObjects.remove(location); } - + /** * Convenience method to drop all cargo. */ public void dropGroundObjects() { - carriedObjects.clear(); + carriedObjects.clear(); } - + /** * Get the object carried in the given location. May return null. */ public ICarryable getCarriedObject(int location) { - return carriedObjects.get(location); + return carriedObjects.get(location); } - + public Map getCarriedObjects() { - return carriedObjects; + return carriedObjects; } - + public void setCarriedObjects(Map value) { - carriedObjects = value; + carriedObjects = value; } - + public List getDistinctCarriedObjects() { - return carriedObjects.values().stream().distinct().toList(); + return carriedObjects.values().stream().distinct().toList(); } - + /** * A list of the "default" cargo pick up locations for when none is specified */ protected List getDefaultPickupLocations() { - return Arrays.asList(LOC_NONE); + return Arrays.asList(LOC_NONE); } - + /** - * A list of all the locations that the entity can use to pick up cargo following the TacOps + * A list of all the locations that the entity can use to pick up cargo following the TacOps * "one handed" pickup rules */ public List getValidHalfWeightPickupLocations(ICarryable cargo) { - return Arrays.asList(LOC_NONE); + return Arrays.asList(LOC_NONE); } - + /** - * Whether a weapon in a given location can be fired, + * Whether a weapon in a given location can be fired, * given the entity's currently carried cargo */ public boolean canFireWeapon(int location) { - if (getBlockedFiringLocations() == null) { - return true; - } - - // loop through everything we are carrying - // if the weapon location is blocked by the carried object, then we cannot fire the weapon - for (int carriedObjectLocation : getCarriedObjects().keySet()) { - if (getBlockedFiringLocations().containsKey(carriedObjectLocation) && - getBlockedFiringLocations().get(carriedObjectLocation).contains(location)) { - return false; - } - } - - return true; - } - + if (getBlockedFiringLocations() == null) { + return true; + } + + // loop through everything we are carrying + // if the weapon location is blocked by the carried object, then we cannot fire the weapon + for (int carriedObjectLocation : getCarriedObjects().keySet()) { + if (getBlockedFiringLocations().containsKey(carriedObjectLocation) && + getBlockedFiringLocations().get(carriedObjectLocation).contains(location)) { + return false; + } + } + + return true; + } + /** * Method that returns the mapping between locations which, if cargo is carried, * block other locations from firing. */ protected Map> getBlockedFiringLocations() { - return null; + return null; } /** @@ -3161,13 +3161,13 @@ public int elevationOccupied(Hex hex, int elevation) { return 0; } if ((movementMode == EntityMovementMode.VTOL) - || (movementMode == EntityMovementMode.WIGE)) { + || (movementMode == EntityMovementMode.WIGE)) { return hex.getLevel() + elevation; } else if (((movementMode == EntityMovementMode.HOVER) - || (movementMode == EntityMovementMode.NAVAL) - || (movementMode == EntityMovementMode.HYDROFOIL) - || hex.containsTerrain(Terrains.ICE)) - && hex.containsTerrain(Terrains.WATER)) { + || (movementMode == EntityMovementMode.NAVAL) + || (movementMode == EntityMovementMode.HYDROFOIL) + || hex.containsTerrain(Terrains.ICE)) + && hex.containsTerrain(Terrains.WATER)) { return hex.getLevel(); } else { return hex.floor(); @@ -3293,9 +3293,9 @@ public String getLocationName(int loc) { */ public String getLocationAbbr(HitData hit) { return getLocationAbbr(hit.getLocation()) - + (hit.isRear() && hasRearArmor(hit.getLocation()) ? "R" : "") - + (((hit.getEffect() & HitData.EFFECT_CRITICAL) == HitData.EFFECT_CRITICAL) ? " (critical)" - : ""); + + (hit.isRear() && hasRearArmor(hit.getLocation()) ? "R" : "") + + (((hit.getEffect() & HitData.EFFECT_CRITICAL) == HitData.EFFECT_CRITICAL) ? " (critical)" + : ""); } /** @@ -3333,7 +3333,7 @@ public int getLocationFromAbbr(String abbr) { * * @param locations A list of location indices * @param limit The maximum number of locations to show in full - * @return A string formatted for display that shows the locations + * @return A string formatted for display that shows the locations */ public String joinLocationAbbr(List locations, int limit) { if (locations.size() > limit) { @@ -3635,7 +3635,7 @@ public double getInternalRemainingPercent() { */ public boolean isLocationBad(int loc) { return (getInternal(loc) == IArmorState.ARMOR_DESTROYED) - || (isLocationBlownOff(loc) && !isLocationBlownOffThisPhase(loc)); + || (isLocationBlownOff(loc) && !isLocationBlownOffThisPhase(loc)); } public boolean isLocationTrulyDestroyed(int loc) { @@ -3647,7 +3647,7 @@ public boolean isLocationTrulyDestroyed(int loc) { */ public boolean isLocationDoomed(int loc) { return (getInternal(loc) == IArmorState.ARMOR_DOOMED) - || isLocationBlownOff(loc); + || isLocationBlownOff(loc); } /** @@ -3718,7 +3718,7 @@ public static String armorStringFor(int value) { if (value == IArmorState.ARMOR_NA) { return "N/A"; } else if ((value == IArmorState.ARMOR_DOOMED) - || (value == IArmorState.ARMOR_DESTROYED)) { + || (value == IArmorState.ARMOR_DESTROYED)) { return "***"; } else { return Integer.toString(value); @@ -3772,41 +3772,41 @@ public Mounted addEquipment(EquipmentType etype, int loc) * Creates a new mount for this equipment and adds it in. */ public Mounted addEquipment(EquipmentType etype, int loc, - boolean rearMounted) throws LocationFullException { + boolean rearMounted) throws LocationFullException { return addEquipment(etype, loc, rearMounted, - BattleArmor.MOUNT_LOC_NONE, false, false, false, false, false); + BattleArmor.MOUNT_LOC_NONE, false, false, false, false, false); } /** * Creates a new mount for this equipment and adds it in. */ public Mounted addEquipment(EquipmentType etype, int loc, - boolean rearMounted, int baMountLoc, boolean isArmored, - boolean isTurreted) throws LocationFullException { + boolean rearMounted, int baMountLoc, boolean isArmored, + boolean isTurreted) throws LocationFullException { return addEquipment(etype, loc, rearMounted, baMountLoc, isArmored, - isTurreted, false, false, false); + isTurreted, false, false, false); } public Mounted addEquipment(EquipmentType etype, int loc, - boolean rearMounted, int baMountLoc, boolean isArmored, - boolean isTurreted, boolean isSponsonTurreted) + boolean rearMounted, int baMountLoc, boolean isArmored, + boolean isTurreted, boolean isSponsonTurreted) throws LocationFullException { return addEquipment(etype, loc, rearMounted, baMountLoc, isArmored, - isTurreted, isSponsonTurreted, false, false); + isTurreted, isSponsonTurreted, false, false); } public Mounted addEquipment(EquipmentType etype, int loc, - boolean rearMounted, int baMountLoc, boolean isArmored, - boolean isTurreted, boolean isSponsonTurreted, - boolean isPintleTurreted) throws LocationFullException { + boolean rearMounted, int baMountLoc, boolean isArmored, + boolean isTurreted, boolean isSponsonTurreted, + boolean isPintleTurreted) throws LocationFullException { return addEquipment(etype, loc, rearMounted, baMountLoc, isArmored, isTurreted, isSponsonTurreted, isPintleTurreted, false); } public Mounted addEquipment(EquipmentType etype, int loc, - boolean rearMounted, int baMountLoc, boolean isArmored, - boolean isTurreted, boolean isSponsonTurreted, - boolean isPintleTurreted, boolean isOmniPodded) throws LocationFullException { + boolean rearMounted, int baMountLoc, boolean isArmored, + boolean isTurreted, boolean isSponsonTurreted, + boolean isPintleTurreted, boolean isOmniPodded) throws LocationFullException { Mounted mounted = Mounted.createMounted(this, etype); mounted.setArmored(isArmored); mounted.setBaMountLoc(baMountLoc); @@ -3829,7 +3829,7 @@ public Mounted addEquipment(EquipmentType etype, int loc, * @throws LocationFullException */ public Mounted addEquipment(EquipmentType etype, int loc, - boolean rearMounted, int nAmmo) throws LocationFullException { + boolean rearMounted, int nAmmo) throws LocationFullException { Mounted mounted = Mounted.createMounted(this, etype); addEquipment(mounted, loc, rearMounted, nAmmo); return mounted; @@ -3863,7 +3863,7 @@ public WeaponMounted addWeaponGroup(EquipmentType etype, int loc) * indicate whether this is bodymounted for BAs */ public Mounted addEquipment(EquipmentType etype, int loc, - boolean rearMounted, int baMountLoc, boolean dwpMounted) + boolean rearMounted, int baMountLoc, boolean dwpMounted) throws LocationFullException { Mounted mounted = Mounted.createMounted(this, etype); mounted.setBaMountLoc(baMountLoc); @@ -4165,7 +4165,7 @@ public int getFirstWeapon() { if (!(mounted.getType().hasFlag(WeaponType.F_ARTILLERY) || mounted.isInBearingsOnlyMode() || (this.getAltitude() == 0 - && mounted.getType() instanceof CapitalMissileWeapon))) { + && mounted.getType() instanceof CapitalMissileWeapon))) { continue; } @@ -4205,12 +4205,12 @@ public boolean isWeaponValidForPhase(int weapNum) { public boolean isWeaponValidForPhase(WeaponMounted mounted) { // Start reached, now we can attempt to pick a weapon. if ((mounted != null) - && (mounted.isReady()) - && (!(mounted.getType().hasFlag(WeaponType.F_AMS) && mounted.curMode().equals(Weapon.MODE_AMS_ON))) - && (!(mounted.getType().hasFlag(WeaponType.F_AMS) && mounted.curMode().equals(Weapon.MODE_AMS_OFF))) - && (!mounted.getType().hasFlag(WeaponType.F_AMSBAY)) - && (!(mounted.hasModes() && mounted.curMode().equals("Point Defense"))) - && ((mounted.getLinked() == null) + && (mounted.isReady()) + && (!(mounted.getType().hasFlag(WeaponType.F_AMS) && mounted.curMode().equals(Weapon.MODE_AMS_ON))) + && (!(mounted.getType().hasFlag(WeaponType.F_AMS) && mounted.curMode().equals(Weapon.MODE_AMS_OFF))) + && (!mounted.getType().hasFlag(WeaponType.F_AMSBAY)) + && (!(mounted.hasModes() && mounted.curMode().equals("Point Defense"))) + && ((mounted.getLinked() == null) || mounted.getLinked().getType().hasFlag(MiscType.F_AP_MOUNT) || (mounted.getLinked().getUsableShotsLeft() > 0))) { @@ -4223,8 +4223,8 @@ public boolean isWeaponValidForPhase(WeaponMounted mounted) { // Artillery or Bearings-only missiles only in the targeting phase... if (getGame().getPhase().isTargeting() && !(mounted.getType().hasFlag(WeaponType.F_ARTILLERY) - || mounted.isInBearingsOnlyMode() - || ((this.getAltitude() == 0) && (mounted.getType() instanceof CapitalMissileWeapon)))) { + || mounted.isInBearingsOnlyMode() + || ((this.getAltitude() == 0) && (mounted.getType() instanceof CapitalMissileWeapon)))) { return false; } // No Bearings-only missiles in the firing phase @@ -4318,12 +4318,12 @@ public boolean loadWeapon(WeaponMounted mounted, AmmoMounted mountedAmmo) { AmmoType atype = mountedAmmo.getType(); if (mountedAmmo.isAmmoUsable() && !wtype.hasFlag(WeaponType.F_ONESHOT) - && (atype.getAmmoType() == wtype.getAmmoType()) - && (atype.getRackSize() == wtype.getRackSize())) { + && (atype.getAmmoType() == wtype.getAmmoType()) + && (atype.getRackSize() == wtype.getRackSize())) { mounted.setLinked(mountedAmmo); success = true; } else if ((wtype.hasFlag(WeaponType.F_DOUBLE_ONESHOT) - || (wtype.getAmmoType() == AmmoType.T_INFANTRY)) + || (wtype.getAmmoType() == AmmoType.T_INFANTRY)) && (mountedAmmo.getLocation() == Entity.LOC_NONE)) { // Make sure this ammo is in the chain, then move it to the head. for (Mounted current = mounted; current != null; current = current.getLinked()) { @@ -4376,12 +4376,12 @@ public boolean weaponFiredFrom(int loc) { CriticalSlot slot = getCritical(loc, i); // ignore empty & system slots if ((slot == null) - || (slot.getType() != CriticalSlot.TYPE_EQUIPMENT)) { + || (slot.getType() != CriticalSlot.TYPE_EQUIPMENT)) { continue; } Mounted mounted = slot.getMount(); if ((mounted.getType() instanceof WeaponType) - && mounted.isUsedThisRound()) { + && mounted.isUsedThisRound()) { return true; } } @@ -4401,7 +4401,7 @@ public List getAmmo(WeaponMounted weapon) { ArrayList ammos = new ArrayList<>(); // Only add one valid ammo to the list to reduce repeat calculations - for (AmmoMounted ammo: ammoList) { + for (AmmoMounted ammo : ammoList) { if (AmmoType.isAmmoValid(ammo, weapon.getType())) { if (etypes.add(ammo.getType())) { ammos.add(ammo); @@ -4425,12 +4425,13 @@ public List getBombs(BigInteger flag) { for (BombMounted bomb : getBombs()) { BombType btype = (BombType) bomb.getType(); if (!bomb.isInoperable() && (bomb.getUsableShotsLeft() > 0) - && btype.hasFlag(flag)) { + && btype.hasFlag(flag)) { bombs.add(bomb); } } return bombs; } + /** * Reset bomb attacks according to what bombs are available. */ @@ -4445,7 +4446,7 @@ protected void resetBombAttacks() { if (eq.getType().equals(spaceBomb) || eq.getType().equals(altBomb) || eq.getType().equals(diveBomb)) { bombAttacksToRemove.add(eq); - } else if (eq.getLinked() != null && eq.getLinked().isInternalBomb()){ + } else if (eq.getLinked() != null && eq.getLinked().isInternalBomb()) { // Remove any used internal bombs if (eq.getLinked().getUsableShotsLeft() <= 0) { bombAttacksToRemove.add(eq); @@ -4483,7 +4484,7 @@ && isBomber() if (!game.getBoard().inSpace() && m.getType().hasFlag(AmmoType.F_GROUND_BOMB) && !((this instanceof LandAirMech) - && (getConversionMode() == LandAirMech.CONV_MODE_MECH))) { + && (getConversionMode() == LandAirMech.CONV_MODE_MECH))) { if (addedBombAttacks < 1) { try { WeaponMounted bomb = (WeaponMounted) addEquipment(diveBomb, m.getLocation(), false); @@ -4611,9 +4612,9 @@ public boolean hasMisc(BigInteger flag) { } public List getMiscEquipment(BigInteger flag) { - return miscList.stream() - .filter(item -> item.getType().hasFlag(flag)) - .collect(Collectors.toList()); + return miscList.stream() + .filter(item -> item.getType().hasFlag(flag)) + .collect(Collectors.toList()); } /** @@ -4639,11 +4640,12 @@ public int countWorkingMisc(BigInteger flag) { public int countWorkingMisc(BigInteger flag, int location) { int count = 0; - OUTER: for (MiscMounted m : getMisc()) { + OUTER: + for (MiscMounted m : getMisc()) { if (!m.isInoperable() && m.getType().hasFlag(flag) && ((location == -1) || (m.getLocation() == location))) { if (m.hasModes()) { - for (Enumeration e = m.getType().getModes(); e.hasMoreElements();) { + for (Enumeration e = m.getType().getModes(); e.hasMoreElements(); ) { if (e.nextElement().equals("On") && !m.curMode().equals("On")) { continue OUTER; } @@ -4657,11 +4659,12 @@ public int countWorkingMisc(BigInteger flag, int location) { public int countWorkingMisc(String internalName, int location) { int count = 0; - OUTER: for (MiscMounted m : getMisc()) { + OUTER: + for (MiscMounted m : getMisc()) { if (!m.isInoperable() && m.getType().getInternalName().equalsIgnoreCase(internalName) && ((location == -1) || (m.getLocation() == location))) { if (m.hasModes()) { - for (Enumeration e = m.getType().getModes(); e.hasMoreElements();) { + for (Enumeration e = m.getType().getModes(); e.hasMoreElements(); ) { if (e.nextElement().equals("On") && !m.curMode().equals("On")) { continue OUTER; } @@ -4702,7 +4705,7 @@ public boolean hasWorkingMisc(BigInteger flag, long secondary, int location) { for (int slot = 0; slot < getNumberOfCriticals(location); slot++) { CriticalSlot crit = getCritical(location, slot); if ((null != crit) - && (crit.getType() == CriticalSlot.TYPE_EQUIPMENT)) { + && (crit.getType() == CriticalSlot.TYPE_EQUIPMENT)) { Mounted mount = crit.getMount(); if (mount == null) { continue; @@ -4710,7 +4713,7 @@ public boolean hasWorkingMisc(BigInteger flag, long secondary, int location) { if ((mount.getType() instanceof MiscType) && mount.isReady()) { MiscType type = (MiscType) mount.getType(); if (type.hasFlag(flag) - && ((secondary == -1) || type.hasSubType(secondary))) { + && ((secondary == -1) || type.hasSubType(secondary))) { return true; } } @@ -4791,7 +4794,7 @@ public boolean hasWorkingWeapon(BigInteger flag, int secondary, int location) { for (int slot = 0; slot < getNumberOfCriticals(location); slot++) { CriticalSlot crit = getCritical(location, slot); if ((null != crit) - && (crit.getType() == CriticalSlot.TYPE_EQUIPMENT)) { + && (crit.getType() == CriticalSlot.TYPE_EQUIPMENT)) { Mounted mount = crit.getMount(); if (mount == null) { continue; @@ -4799,7 +4802,7 @@ public boolean hasWorkingWeapon(BigInteger flag, int secondary, int location) { if ((mount.getType() instanceof WeaponType) && mount.isReady()) { WeaponType type = (WeaponType) mount.getType(); if (type.hasFlag(flag) - && ((secondary == -1) || type.hasSubType(secondary))) { + && ((secondary == -1) || type.hasSubType(secondary))) { return true; } } @@ -5099,7 +5102,7 @@ protected int critStateCount(int type, int index, int loc, Predicate= noOfSlots.length) - || (loc == LOC_NONE)) { + || (loc == LOC_NONE)) { return 0; } return noOfSlots[loc]; @@ -5115,7 +5118,7 @@ public int getNumberOfCriticals(int type, int index, int loc) { for (int i = 0; i < numCrits; i++) { CriticalSlot ccs = getCritical(loc, i); if ((ccs != null) && (ccs.getType() == type) - && (ccs.getIndex() == index)) { + && (ccs.getIndex() == index)) { num++; } } @@ -5132,7 +5135,7 @@ public int getNumberOfCriticals(EquipmentType etype, int loc) { for (int i = 0; i < numberOfCriticals; i++) { CriticalSlot ccs = getCritical(loc, i); if ((ccs != null) && (getEquipmentType(ccs) != null) - && getEquipmentType(ccs).equals(etype)) { + && getEquipmentType(ccs).equals(etype)) { num++; } } @@ -5182,13 +5185,13 @@ public boolean hasLegActuatorCrit() { for (int i = 0; i < locations(); i++) { if (locationIsLeg(i)) { if ((getBadCriticals(CriticalSlot.TYPE_SYSTEM, - Mech.ACTUATOR_HIP, i) > 0) - || (getBadCriticals(CriticalSlot.TYPE_SYSTEM, - Mech.ACTUATOR_UPPER_LEG, i) > 0) - || (getBadCriticals(CriticalSlot.TYPE_SYSTEM, - Mech.ACTUATOR_LOWER_LEG, i) > 0) - || (getBadCriticals(CriticalSlot.TYPE_SYSTEM, - Mech.ACTUATOR_FOOT, i) > 0)) { + Mech.ACTUATOR_HIP, i) > 0) + || (getBadCriticals(CriticalSlot.TYPE_SYSTEM, + Mech.ACTUATOR_UPPER_LEG, i) > 0) + || (getBadCriticals(CriticalSlot.TYPE_SYSTEM, + Mech.ACTUATOR_LOWER_LEG, i) > 0) + || (getBadCriticals(CriticalSlot.TYPE_SYSTEM, + Mech.ACTUATOR_FOOT, i) > 0)) { hasCrit = true; break; } @@ -5205,8 +5208,8 @@ public boolean hasWorkingSystem(int system, int loc) { for (int i = 0; i < getNumberOfCriticals(loc); i++) { CriticalSlot ccs = getCritical(loc, i); if ((ccs != null) && (ccs.getType() == CriticalSlot.TYPE_SYSTEM) - && (ccs.getIndex() == system) && !ccs.isDamaged() - && !ccs.isBreached()) { + && (ccs.getIndex() == system) && !ccs.isDamaged() + && !ccs.isBreached()) { return true; } } @@ -5221,7 +5224,7 @@ public boolean isSystemRepairable(int system, int loc) { for (int i = 0; i < getNumberOfCriticals(loc); i++) { CriticalSlot ccs = getCritical(loc, i); if ((ccs != null) && (ccs.getType() == CriticalSlot.TYPE_SYSTEM) - && (ccs.getIndex() == system) && !ccs.isRepairable()) { + && (ccs.getIndex() == system) && !ccs.isRepairable()) { return false; } } @@ -5235,7 +5238,7 @@ public boolean hasSystem(int system, int loc) { for (int i = 0; i < getNumberOfCriticals(loc); i++) { CriticalSlot ccs = getCritical(loc, i); if ((ccs != null) && (ccs.getType() == CriticalSlot.TYPE_SYSTEM) - && (ccs.getIndex() == system)) { + && (ccs.getIndex() == system)) { return true; } } @@ -5387,7 +5390,7 @@ public boolean hasActiveECM() { public boolean hasActiveECM(boolean stealth) { // no ECM in space unless strat op option enabled if (game.getBoard().inSpace() - && !game.getOptions().booleanOption(OptionsConstants.ADVAERORULES_STRATOPS_ECM)) { + && !game.getOptions().booleanOption(OptionsConstants.ADVAERORULES_STRATOPS_ECM)) { return false; } if (!isShutDown()) { @@ -5399,7 +5402,7 @@ public boolean hasActiveECM(boolean stealth) { // TacOps p. 100 Angle ECM can have 1 ECM and 1 ECCM at the same // time if (m.getType().hasFlag(MiscType.F_ECM) - && (m.curMode().equals("ECM") + && (m.curMode().equals("ECM") || m.curMode().equals("ECM & ECCM") || m .curMode().equals("ECM & Ghost Targets"))) { return !(m.isInoperable()); @@ -5415,14 +5418,14 @@ public boolean hasActiveECM(boolean stealth) { public boolean hasActiveAngelECM() { // no ECM in space unless strat op option enabled if (game.getBoard().inSpace() - && !game.getOptions().booleanOption(OptionsConstants.ADVAERORULES_STRATOPS_ECM)) { + && !game.getOptions().booleanOption(OptionsConstants.ADVAERORULES_STRATOPS_ECM)) { return false; } if (game.getOptions().booleanOption(OptionsConstants.ADVANCED_TACOPS_ANGEL_ECM) - && !isShutDown()) { + && !isShutDown()) { for (MiscMounted m : getMisc()) { if (m.getType().hasFlag(MiscType.F_ANGEL_ECM) - && (m.curMode().equals("ECM") + && (m.curMode().equals("ECM") || m.curMode().equals("ECM & ECCM") || m .curMode().equals("ECM & Ghost Targets"))) { return !(m.isInoperable()); @@ -5438,7 +5441,7 @@ public boolean hasActiveAngelECM() { public boolean hasActiveNovaECM() { // no ECM in space unless strat op option enabled if (game.getBoard().inSpace() - && !game.getOptions().booleanOption(OptionsConstants.ADVAERORULES_STRATOPS_ECM)) { + && !game.getOptions().booleanOption(OptionsConstants.ADVAERORULES_STRATOPS_ECM)) { return false; } if (!isShutDown()) { @@ -5481,16 +5484,16 @@ public boolean hasGhostTargets(boolean active) { // TacOps p. 100 Angle ECM can have ECM/ECCM and Ghost Targets at // the same time if (type.hasFlag(MiscType.F_ECM) - && (m.curMode().equals("Ghost Targets") + && (m.curMode().equals("Ghost Targets") || m.curMode().equals("ECM & Ghost Targets") || m .curMode().equals("ECCM & Ghost Targets")) - && !(m.isInoperable() || getCrew().isUnconscious())) { + && !(m.isInoperable() || getCrew().isUnconscious())) { hasGhost = true; } if (type.hasFlag(MiscType.F_COMMUNICATIONS) - && m.curMode().equals("Ghost Targets") - && (getTotalCommGearTons() >= 7) - && !(m.isInoperable() || getCrew().isUnconscious())) { + && m.curMode().equals("Ghost Targets") + && (getTotalCommGearTons() >= 7) + && !(m.isInoperable() || getCrew().isUnconscious())) { hasGhost = true; } } @@ -5508,7 +5511,7 @@ public boolean hasGhostTargets(boolean active) { public boolean hasActiveECCM() { // no ECM in space unless strat op option enabled if (game.getBoard().inSpace() - && !game.getOptions().booleanOption(OptionsConstants.ADVAERORULES_STRATOPS_ECM)) { + && !game.getOptions().booleanOption(OptionsConstants.ADVAERORULES_STRATOPS_ECM)) { return false; } if ((game.getOptions().booleanOption(OptionsConstants.ADVANCED_TACOPS_ECCM) || game @@ -5538,12 +5541,12 @@ public boolean hasActiveECCM() { */ public boolean hasActiveAngelECCM() { if (game.getOptions().booleanOption(OptionsConstants.ADVANCED_TACOPS_ANGEL_ECM) - && game.getOptions().booleanOption(OptionsConstants.ADVANCED_TACOPS_ECCM) - && !isShutDown()) { + && game.getOptions().booleanOption(OptionsConstants.ADVANCED_TACOPS_ECCM) + && !isShutDown()) { for (MiscMounted m : getMisc()) { EquipmentType type = m.getType(); if (m.getType().hasFlag(MiscType.F_ANGEL_ECM) - && (m.curMode().equals("ECCM") + && (m.curMode().equals("ECCM") || m.curMode().equals("ECM & ECCM") || m .curMode().equals("ECCM & Ghost Targets"))) { return !(m.isDestroyed() || m.isMissing() || m.isBreached() || isShutDown()); @@ -5563,7 +5566,7 @@ public boolean hasActiveAngelECCM() { public int getECMRange() { // no ECM in space unless strat op option enabled if (game.getBoard().inSpace() - && !game.getOptions().booleanOption(OptionsConstants.ADVAERORULES_STRATOPS_ECM)) { + && !game.getOptions().booleanOption(OptionsConstants.ADVAERORULES_STRATOPS_ECM)) { return Entity.NONE; } // If we have stealth up and running, there's no bubble. @@ -5575,13 +5578,13 @@ public int getECMRange() { for (MiscMounted m : getMisc()) { MiscType type = m.getType(); if (type.hasFlag(MiscType.F_ECM) - && !m.isInoperable()) { + && !m.isInoperable()) { if (type.hasFlag(MiscType.F_SINGLE_HEX_ECM)) { return 0; } int toReturn = 6; if (type.hasFlag(MiscType.F_ANGEL_ECM) - && (this instanceof BattleArmor)) { + && (this instanceof BattleArmor)) { toReturn = 2; } if (type.hasFlag(MiscType.F_EW_EQUIPMENT)) { @@ -5768,7 +5771,7 @@ public boolean hasAimModeTargComp() { } for (MiscMounted m : getMisc()) { if (m.getType().hasFlag(MiscType.F_TARGCOMP) - && m.curMode().equals("Aimed shot")) { + && m.curMode().equals("Aimed shot")) { return !m.isInoperable(); } } @@ -5825,8 +5828,8 @@ public boolean hasCASEII(int location) { public boolean hasHarJelIn(int location) { for (MiscMounted mounted : getMisc()) { if ((mounted.getLocation() == location) - && mounted.isReady() - && (mounted.getType().hasFlag(MiscType.F_HARJEL))) { + && mounted.isReady() + && (mounted.getType().hasFlag(MiscType.F_HARJEL))) { return true; } } @@ -5840,7 +5843,7 @@ public boolean hasBoostedC3() { for (Mounted m : getEquipment()) { if (((m.getType() instanceof MiscType) && m.getType().hasFlag(MiscType.F_C3SBS)) || ((m.getType() instanceof WeaponType) && m.getType().hasFlag(WeaponType.F_C3MBS)) - && !m.isInoperable()) { + && !m.isInoperable()) { return true; } } @@ -5883,17 +5886,17 @@ public boolean hasC3MM() { while ((c3CompanyMasterIndex == LOC_DESTROYED) && e.hasNext()) { Mounted m = e.next(); if ((m.getType() instanceof WeaponType) - && (m.getType().hasFlag(WeaponType.F_C3M) || m + && (m.getType().hasFlag(WeaponType.F_C3M) || m .getType().hasFlag(WeaponType.F_C3MBS)) - && !m.isInoperable()) { + && !m.isInoperable()) { // Now look for the company command master. while ((c3CompanyMasterIndex == LOC_DESTROYED) - && e.hasNext()) { + && e.hasNext()) { m = e.next(); if ((m.getType() instanceof WeaponType) - && (m.getType().hasFlag(WeaponType.F_C3M) || m + && (m.getType().hasFlag(WeaponType.F_C3M) || m .getType().hasFlag(WeaponType.F_C3MBS)) - && !m.isInoperable()) { + && !m.isInoperable()) { // Found the comany command master c3CompanyMasterIndex = getEquipmentNum(m); } @@ -5973,8 +5976,8 @@ public boolean hasC3i() { // check for Manei Domini implants if ((this instanceof Infantry) && (null != crew) //Fix for Bug Report #1194 - && hasAbility(OptionsConstants.MD_ENH_MM_IMPLANTS) - && hasAbility(OptionsConstants.MD_BOOST_COMM_IMPLANT)) { + && hasAbility(OptionsConstants.MD_ENH_MM_IMPLANTS) + && hasAbility(OptionsConstants.MD_BOOST_COMM_IMPLANT)) { return true; } return false; @@ -6176,17 +6179,17 @@ public Entity getC3Top() { Entity m = this; Entity master = m.getC3Master(); while ((master != null) - && !master.equals(m) - && master.hasC3() - && ((m.hasBoostedC3() && !ComputeECM.isAffectedByAngelECM(m, - m.getPosition(), - master.getPosition())) || !(ComputeECM - .isAffectedByECM(m, m.getPosition(), - master.getPosition()))) - && ((master.hasBoostedC3() && !ComputeECM.isAffectedByAngelECM( + && !master.equals(m) + && master.hasC3() + && ((m.hasBoostedC3() && !ComputeECM.isAffectedByAngelECM(m, + m.getPosition(), + master.getPosition())) || !(ComputeECM + .isAffectedByECM(m, m.getPosition(), + master.getPosition()))) + && ((master.hasBoostedC3() && !ComputeECM.isAffectedByAngelECM( master, master.getPosition(), master.getPosition())) || !(ComputeECM - .isAffectedByECM(master, master.getPosition(), - master.getPosition())))) { + .isAffectedByECM(master, master.getPosition(), + master.getPosition())))) { m = master; master = m.getC3Master(); } @@ -6242,7 +6245,7 @@ else if (eMaster.isShutDown()) { // Has our company commander lost his company command computer? else if (((eMaster.c3CompanyMasterIndex > LOC_NONE) && !eMaster .hasC3MM()) - || ((eMaster.c3CompanyMasterIndex <= LOC_NONE) && !eMaster + || ((eMaster.c3CompanyMasterIndex <= LOC_NONE) && !eMaster .hasC3M())) { c3Master = NONE; } @@ -6250,7 +6253,7 @@ else if (((eMaster.c3CompanyMasterIndex > LOC_NONE) && !eMaster else if (eMaster != this) { Entity eCompanyMaster = eMaster.getC3Master(); if ((eCompanyMaster != null) - && (eCompanyMaster.getC3Master() != eCompanyMaster)) { + && (eCompanyMaster.getC3Master() != eCompanyMaster)) { c3Master = NONE; } } @@ -6391,7 +6394,7 @@ public boolean onSameC3NetworkAs(Entity e, boolean ignoreECM) { return true; } return !(ComputeECM.isAffectedByECM(e, e.getPosition(), e.getPosition())) - && !(ComputeECM.isAffectedByECM(this, getPosition(), getPosition())); + && !(ComputeECM.isAffectedByECM(this, getPosition(), getPosition())); } // NC3 is easy too - if they both have NC3, and their net ID's match, @@ -6415,7 +6418,7 @@ public boolean onSameC3NetworkAs(Entity e, boolean ignoreECM) { // they're on the same network! // At least I hope thats how it works. if (hasActiveNovaCEWS() && e.hasActiveNovaCEWS() - && getC3NetId().equals(e.getC3NetId())) { + && getC3NetId().equals(e.getC3NetId())) { if (ignoreECM) { return true; } @@ -6446,7 +6449,7 @@ && getC3NetId().equals(e.getC3NetId())) { public boolean locationHasCase(int loc) { for (MiscMounted mounted : getMisc()) { if ((mounted.getLocation() == loc) - && mounted.getType().hasFlag(MiscType.F_CASE)|(mounted.getType().hasFlag(MiscType.F_CASEP))) { + && mounted.getType().hasFlag(MiscType.F_CASE) | (mounted.getType().hasFlag(MiscType.F_CASEP))) { return true; } } @@ -6462,7 +6465,7 @@ public boolean hasCase() { return true; } for (MiscMounted mounted : getMisc()) { - if (mounted.getType().hasFlag(MiscType.F_CASE)||(mounted.getType().hasFlag(MiscType.F_CASEP))) { + if (mounted.getType().hasFlag(MiscType.F_CASE) || (mounted.getType().hasFlag(MiscType.F_CASEP))) { return true; } } @@ -6548,9 +6551,9 @@ public void newRound(int roundNumber) { // for dropping troops, check to see if they are going to land // this turn, if so, then set their assault drop status to true if (isAirborne() - && !isAero() - && (getAltitude() <= game.getPlanetaryConditions() - .getDropRate())) { + && !isAero() + && (getAltitude() <= game.getPlanetaryConditions() + .getDropRate())) { setAssaultDropInProgress(true); } @@ -6685,7 +6688,7 @@ public void newRound(int roundNumber) { setClimbMode(GUIP.getMoveDefaultClimbMode()); endOfTurnCargoInteraction = false; - + setTurnInterrupted(false); } @@ -6784,7 +6787,7 @@ public List getActiveAMS() { // Make sure the AMS is good to go if (!weapon.isReady() || weapon.isMissing() - || !weapon.curMode().equals(Weapon.MODE_AMS_ON)) { + || !weapon.curMode().equals(Weapon.MODE_AMS_ON)) { continue; } @@ -6838,40 +6841,40 @@ public void assignAMS(final List attacks) { getActiveAMS().stream() .filter(ams -> !ams.isAPDS()) .forEach(ams -> { - // make a new list of only incoming attacks in arc - final List attacksInArc = attacks.stream() - .filter(weaponHandler -> (weaponHandler.getWaa() != null) - && !targets.contains(weaponHandler.getWaa()) - && Compute.isInArc(getGame(), getId(), getEquipmentNum(ams), + // make a new list of only incoming attacks in arc + final List attacksInArc = attacks.stream() + .filter(weaponHandler -> (weaponHandler.getWaa() != null) + && !targets.contains(weaponHandler.getWaa()) + && Compute.isInArc(getGame(), getId(), getEquipmentNum(ams), (weaponHandler instanceof CapitalMissileBearingsOnlyHandler) ? getGame().getTarget(weaponHandler.getWaa().getOriginalTargetType(), - weaponHandler.getWaa().getOriginalTargetId()) + weaponHandler.getWaa().getOriginalTargetId()) : getGame().getEntity(weaponHandler.getWaa().getEntityId()))) - .map(WeaponHandler::getWaa) - .collect(Collectors.toList()); + .map(WeaponHandler::getWaa) + .collect(Collectors.toList()); - if (attacksInArc.isEmpty()) { - return; - } + if (attacksInArc.isEmpty()) { + return; + } - // AMS Bays can fire at all incoming attacks each round - // So can standard AMS if the unofficial option is turned on - if ((ams.getType().hasFlag(WeaponType.F_AMSBAY)) - || (getGame().getOptions().booleanOption(OptionsConstants.ADVCOMBAT_MULTI_USE_AMS) + // AMS Bays can fire at all incoming attacks each round + // So can standard AMS if the unofficial option is turned on + if ((ams.getType().hasFlag(WeaponType.F_AMSBAY)) + || (getGame().getOptions().booleanOption(OptionsConstants.ADVCOMBAT_MULTI_USE_AMS) && ams.getType().hasFlag(WeaponType.F_AMS))) { - attacksInArc.forEach(waa -> waa.addCounterEquipment(ams)); - } else if (ams.getType().hasFlag(WeaponType.F_PDBAY)) { - // Point defense bays are assigned to the attack with the greatest threat - // Unlike single AMS, PD bays can gang up on 1 attack - Compute.getHighestExpectedDamage(getGame(), attacksInArc, true).addCounterEquipment(ams); - } else { - // Otherwise, find the most dangerous salvo by expected damage and target it - // this ensures that only 1 AMS targets the strike. Use for non-bays. - final WeaponAttackAction waa = Compute.getHighestExpectedDamage(getGame(), attacksInArc, true); - waa.addCounterEquipment(ams); - targets.add(waa); - } - }); + attacksInArc.forEach(waa -> waa.addCounterEquipment(ams)); + } else if (ams.getType().hasFlag(WeaponType.F_PDBAY)) { + // Point defense bays are assigned to the attack with the greatest threat + // Unlike single AMS, PD bays can gang up on 1 attack + Compute.getHighestExpectedDamage(getGame(), attacksInArc, true).addCounterEquipment(ams); + } else { + // Otherwise, find the most dangerous salvo by expected damage and target it + // this ensures that only 1 AMS targets the strike. Use for non-bays. + final WeaponAttackAction waa = Compute.getHighestExpectedDamage(getGame(), attacksInArc, true); + waa.addCounterEquipment(ams); + targets.add(waa); + } + }); } /** @@ -7188,53 +7191,53 @@ public PilotingRollData getBasePilotingRoll(EntityMovementType moveType) { // Crew dead? if (getCrew().isDead() || getCrew().isDoomed() - || (getCrew().getHits() >= 6)) { + || (getCrew().getHits() >= 6)) { // Following line switched from impossible to automatic failure // -- bug fix for dead units taking PSRs return new PilotingRollData(entityId, TargetRoll.AUTOMATIC_FAIL, - "Pilot dead"); + "Pilot dead"); } // pilot awake? else if (!getCrew().isActive()) { return new PilotingRollData(entityId, TargetRoll.IMPOSSIBLE, - "Pilot unconscious"); + "Pilot unconscious"); } // gyro operational? does not apply if using tracked/quadvee vehicle/lam fighter movement if (isGyroDestroyed() && canFall() && moveType != EntityMovementType.MOVE_VTOL_WALK && moveType != EntityMovementType.MOVE_VTOL_RUN) { return new PilotingRollData(entityId, TargetRoll.AUTOMATIC_FAIL, - getCrew().getPiloting() + 6, "Gyro destroyed"); + getCrew().getPiloting() + 6, "Gyro destroyed"); } // both legs present? if ((this instanceof BipedMech) - && (((BipedMech) this).countBadLegs() == 2) - && (moveType != EntityMovementType.MOVE_VTOL_WALK) - && (moveType != EntityMovementType.MOVE_VTOL_RUN)) { - return new PilotingRollData(entityId, - TargetRoll.AUTOMATIC_FAIL, - getCrew().getPiloting() + 10, "Both legs destroyed"); + && (((BipedMech) this).countBadLegs() == 2) + && (moveType != EntityMovementType.MOVE_VTOL_WALK) + && (moveType != EntityMovementType.MOVE_VTOL_RUN)) { + return new PilotingRollData(entityId, + TargetRoll.AUTOMATIC_FAIL, + getCrew().getPiloting() + 10, "Both legs destroyed"); } else if (this instanceof QuadMech) { if (((QuadMech) this).countBadLegs() >= 3) { return new PilotingRollData(entityId, - TargetRoll.AUTOMATIC_FAIL, getCrew().getPiloting() - + (((Mech) this).countBadLegs() * 5), - ((Mech) this).countBadLegs() + " legs destroyed"); + TargetRoll.AUTOMATIC_FAIL, getCrew().getPiloting() + + (((Mech) this).countBadLegs() * 5), + ((Mech) this).countBadLegs() + " legs destroyed"); } } // entity shut down? if (isShutDown() && isShutDownThisPhase()) { return new PilotingRollData(entityId, TargetRoll.AUTOMATIC_FAIL, - getCrew().getPiloting() + 3, "Reactor shut down"); + getCrew().getPiloting() + 3, "Reactor shut down"); } else if (isShutDown()) { return new PilotingRollData(entityId, TargetRoll.AUTOMATIC_FAIL, - TargetRoll.IMPOSSIBLE, "Reactor shut down"); + TargetRoll.IMPOSSIBLE, "Reactor shut down"); } // okay, let's figure out the stuff then roll = new PilotingRollData(entityId, getCrew().getPiloting(moveType), - "Base piloting skill"); + "Base piloting skill"); // Let's see if we have a modifier to our piloting skill roll. We'll // pass in the roll @@ -7286,7 +7289,7 @@ TargetRoll.AUTOMATIC_FAIL, getCrew().getPiloting() * Add in any modifiers due to global conditions like light/weather/etc. */ public PilotingRollData addConditionBonuses(PilotingRollData roll, - EntityMovementType moveType) { + EntityMovementType moveType) { PlanetaryConditions conditions = game.getPlanetaryConditions(); if (moveType == EntityMovementType.MOVE_SPRINT @@ -7389,8 +7392,8 @@ && getCrew().getOptions().stringOption(OptionsConstants.MISC_ENV_SPECIALIST).equ */ public PilotingRollData checkGetUp(MoveStep step, EntityMovementType moveType) { if ((step == null) - || ((step.getType() != MoveStepType.GET_UP) - && (step.getType() != MoveStepType.CAREFUL_STAND))) { + || ((step.getType() != MoveStepType.GET_UP) + && (step.getType() != MoveStepType.CAREFUL_STAND))) { return new PilotingRollData(id, TargetRoll.CHECK_FALSE, "Check false: Entity is not attempting to get up."); } @@ -7400,7 +7403,7 @@ public PilotingRollData checkGetUp(MoveStep step, EntityMovementType moveType) { if (this instanceof BipedMech) { if ((((Mech) this).countBadLegs() >= 1) && (isLocationBad(Mech.LOC_LARM) - && isLocationBad(Mech.LOC_RARM))) { + && isLocationBad(Mech.LOC_RARM))) { roll.addModifier(TargetRoll.IMPOSSIBLE, "can't get up with destroyed leg and arms"); return roll; @@ -7436,19 +7439,19 @@ public PilotingRollData checkRunningWithDamage( PilotingRollData roll = getBasePilotingRoll(overallMoveType); int gyroDamage = getBadCriticals(CriticalSlot.TYPE_SYSTEM, - Mech.SYSTEM_GYRO, Mech.LOC_CT); + Mech.SYSTEM_GYRO, Mech.LOC_CT); if (getGyroType() == Mech.GYRO_HEAVY_DUTY) { gyroDamage--; // HD gyro ignores 1st damage } if (((overallMoveType == EntityMovementType.MOVE_RUN) || (overallMoveType == EntityMovementType.MOVE_SPRINT)) - && canFall() && ((gyroDamage > 0) || hasHipCrit())) { + && canFall() && ((gyroDamage > 0) || hasHipCrit())) { // append the reason modifier roll.append(new PilotingRollData(getId(), 0, - "running with damaged hip actuator or gyro")); + "running with damaged hip actuator or gyro")); } else { roll.addModifier(TargetRoll.CHECK_FALSE, - "Check false: Entity is not attempting to run with damage"); + "Check false: Entity is not attempting to run with damage"); } addPilotingModifierForTerrain(roll); return roll; @@ -7464,12 +7467,12 @@ public PilotingRollData checkSprintingWithMASCXorSupercharger( if ((overallMoveType == EntityMovementType.MOVE_SPRINT || overallMoveType == EntityMovementType.MOVE_VTOL_SPRINT) - && (used > ((int) Math.ceil(2.0 * this.getWalkMP())))) { + && (used > ((int) Math.ceil(2.0 * this.getWalkMP())))) { roll.append(new PilotingRollData(getId(), 0, - "sprinting with active MASC or Supercharger")); + "sprinting with active MASC or Supercharger")); } else { roll.addModifier(TargetRoll.CHECK_FALSE, - "Check false: Entity is not attempting to sprint with MASC or Supercharger"); + "Check false: Entity is not attempting to sprint with MASC or Supercharger"); } addPilotingModifierForTerrain(roll); @@ -7486,12 +7489,12 @@ public PilotingRollData checkSprintingWithMASCAndSupercharger( if ((overallMoveType == EntityMovementType.MOVE_SPRINT || overallMoveType == EntityMovementType.MOVE_VTOL_SPRINT) - && (used > ((int) Math.ceil(2.5 * this.getWalkMP())))) { + && (used > ((int) Math.ceil(2.5 * this.getWalkMP())))) { roll.append(new PilotingRollData(getId(), 0, - "sprinting with active MASC and Supercharger")); + "sprinting with active MASC and Supercharger")); } else { roll.addModifier(TargetRoll.CHECK_FALSE, - "Check false: Entity is not attempting to sprint with MASC and Supercharger"); + "Check false: Entity is not attempting to sprint with MASC and Supercharger"); } addPilotingModifierForTerrain(roll); @@ -7502,17 +7505,17 @@ public PilotingRollData checkSprintingWithMASCAndSupercharger( * Checks if the entity is attempting to sprint with supercharger engaged. * If so, returns the target roll for the piloting skill check. */ - public PilotingRollData checkUsingOverdrive (EntityMovementType overallMoveType) { + public PilotingRollData checkUsingOverdrive(EntityMovementType overallMoveType) { PilotingRollData roll = getBasePilotingRoll(overallMoveType); if ((overallMoveType == EntityMovementType.MOVE_SPRINT || overallMoveType == EntityMovementType.MOVE_VTOL_SPRINT) && (this instanceof Tank - || (this instanceof QuadVee && getConversionMode() == QuadVee.CONV_MODE_VEHICLE))) { + || (this instanceof QuadVee && getConversionMode() == QuadVee.CONV_MODE_VEHICLE))) { roll.append(new PilotingRollData(getId(), 0, "using overdrive")); } else { roll.addModifier(TargetRoll.CHECK_FALSE, - "Check false: Entity is not using overdrive"); + "Check false: Entity is not using overdrive"); } return roll; @@ -7522,21 +7525,21 @@ public PilotingRollData checkUsingOverdrive (EntityMovementType overallMoveType) * Checks if the entity is attempting to increase two speed categories. * If so, returns the target roll for the piloting skill check. */ - public PilotingRollData checkGunningIt (EntityMovementType overallMoveType) { + public PilotingRollData checkGunningIt(EntityMovementType overallMoveType) { PilotingRollData roll = getBasePilotingRoll(overallMoveType); if (game.getOptions().booleanOption(OptionsConstants.ADVGRNDMOV_VEHICLE_ACCELERATION) && (this instanceof Tank - || (this instanceof QuadVee && getConversionMode() == QuadVee.CONV_MODE_VEHICLE))) { + || (this instanceof QuadVee && getConversionMode() == QuadVee.CONV_MODE_VEHICLE))) { if (((overallMoveType == EntityMovementType.MOVE_SPRINT || overallMoveType == EntityMovementType.MOVE_VTOL_SPRINT) && (movedLastRound == EntityMovementType.MOVE_WALK || movedLastRound == EntityMovementType.MOVE_VTOL_WALK)) || ((overallMoveType == EntityMovementType.MOVE_RUN || overallMoveType == EntityMovementType.MOVE_VTOL_RUN) - && (movedLastRound == EntityMovementType.MOVE_NONE - || movedLastRound == EntityMovementType.MOVE_JUMP - || movedLastRound == EntityMovementType.MOVE_SKID))) { + && (movedLastRound == EntityMovementType.MOVE_NONE + || movedLastRound == EntityMovementType.MOVE_JUMP + || movedLastRound == EntityMovementType.MOVE_SKID))) { roll.append(new PilotingRollData(getId(), 0, "gunning it")); return roll; } @@ -7551,8 +7554,8 @@ public PilotingRollData checkGunningIt (EntityMovementType overallMoveType) { * carefully */ public PilotingRollData checkRecklessMove(MoveStep step, - EntityMovementType moveType, Hex curHex, Coords lastPos, - Coords curPos, Hex prevHex) { + EntityMovementType moveType, Hex curHex, Coords lastPos, + Coords curPos, Hex prevHex) { PlanetaryConditions conditions = game.getPlanetaryConditions(); PilotingRollData roll = getBasePilotingRoll(moveType); // no need to go further if movement is careful @@ -7629,13 +7632,13 @@ public PilotingRollData checkLandingWithDamage( if (gyroHits > 0 || hasLegActuatorCrit()) { // append the reason modifier roll.append(new PilotingRollData(getId(), 0, - "landing with damaged leg actuator or gyro")); + "landing with damaged leg actuator or gyro")); addPilotingModifierForTerrain(roll); } else { roll.addModifier( TargetRoll.CHECK_FALSE, "Entity does not have gyro or leg actuator damage -- checking for purposes of determining PSR " + - "after jump."); + "after jump."); } return roll; } @@ -7651,7 +7654,7 @@ public PilotingRollData checkLandingWithPrototypeJJ( if (getJumpType() == Mech.JUMP_PROTOTYPE) { // append the reason modifier roll.append(new PilotingRollData(getId(), 3, - "landing with prototype jump jets")); + "landing with prototype jump jets")); addPilotingModifierForTerrain(roll); } else { roll.addModifier( @@ -7690,14 +7693,14 @@ public PilotingRollData checkLandingOnIce( PilotingRollData roll = getBasePilotingRoll(overallMoveType); if (curHex.containsTerrain(Terrains.ICE) - && (curHex.terrainLevel(Terrains.WATER) > 0)) { + && (curHex.terrainLevel(Terrains.WATER) > 0)) { roll.append(new PilotingRollData(getId(), 0, - "landing on ice-covered water")); + "landing on ice-covered water")); addPilotingModifierForTerrain(roll); adjustDifficultTerrainPSRModifier(roll); } else { roll.addModifier(TargetRoll.CHECK_FALSE, - "hex is not covered by ice"); + "hex is not covered by ice"); } return roll; @@ -7731,7 +7734,7 @@ public PilotingRollData checkLandingOnBlackIce( * @return */ public PilotingRollData checkMovedTooFast(MoveStep step, - EntityMovementType moveType) { + EntityMovementType moveType) { PilotingRollData roll = getBasePilotingRoll(moveType); addPilotingModifierForTerrain(roll, step); int maxSafeMP = 0; @@ -7761,7 +7764,7 @@ public PilotingRollData checkMovedTooFast(MoveStep step, } else { roll.addModifier(TargetRoll.CHECK_FALSE, "Check false: Entity did not use more " - + "MPs walking/running than possible at 1G"); + + "MPs walking/running than possible at 1G"); } return roll; } @@ -7771,9 +7774,9 @@ public PilotingRollData checkMovedTooFast(MoveStep step, * roll for the piloting skill check. */ public PilotingRollData checkSkid(EntityMovementType moveType, Hex prevHex, - EntityMovementType overallMoveType, MoveStep prevStep, MoveStep currStep, - int prevFacing, int curFacing, Coords lastPos, Coords curPos, - boolean isInfantry, int distance) { + EntityMovementType overallMoveType, MoveStep prevStep, MoveStep currStep, + int prevFacing, int curFacing, Coords lastPos, Coords curPos, + boolean isInfantry, int distance) { PlanetaryConditions conditions = game.getPlanetaryConditions(); PilotingRollData roll = getBasePilotingRoll(overallMoveType); @@ -7869,10 +7872,9 @@ public PilotingRollData checkSkid(EntityMovementType moveType, Hex prevHex, * roll for the piloting skill check. */ public PilotingRollData checkRubbleMove(MoveStep step, - EntityMovementType moveType, Hex curHex, Coords lastPos, - Coords curPos, boolean isLastStep, boolean isPavementStep) { + EntityMovementType moveType, Hex curHex, Coords lastPos, + Coords curPos, boolean isLastStep, boolean isPavementStep) { PilotingRollData roll = getBasePilotingRoll(moveType); - boolean enteringRubble = true; addPilotingModifierForTerrain(roll, curPos, true); if (!lastPos.equals(curPos) @@ -7896,8 +7898,8 @@ public PilotingRollData checkRubbleMove(MoveStep step, * down. If so, returns the target roll for the piloting skill check. */ public PilotingRollData checkBogDown(MoveStep step, - EntityMovementType moveType, Hex curHex, Coords lastPos, - Coords curPos, int lastElev, boolean isPavementStep) { + EntityMovementType moveType, Hex curHex, Coords lastPos, + Coords curPos, int lastElev, boolean isPavementStep) { PilotingRollData roll = getBasePilotingRoll(moveType); int bgMod = curHex.getBogDownModifier(getMovementMode(), this instanceof LargeSupportTank); @@ -7926,7 +7928,7 @@ public PilotingRollData checkBogDown(MoveStep step, } else { roll.addModifier(TargetRoll.CHECK_FALSE, "Check false: Not entering bog-down terrain, " - + "or jumping/hovering over such terrain"); + + "or jumping/hovering over such terrain"); } return roll; } @@ -7936,22 +7938,22 @@ public PilotingRollData checkBogDown(MoveStep step, * target roll for the piloting skill check. */ public PilotingRollData checkWaterMove(MoveStep step, - EntityMovementType moveType, Hex curHex, Coords lastPos, - Coords curPos, boolean isPavementStep) { + EntityMovementType moveType, Hex curHex, Coords lastPos, + Coords curPos, boolean isPavementStep) { if ((curHex.terrainLevel(Terrains.WATER) > 0) - && (step.getElevation() < 0) && !lastPos.equals(curPos) - && (moveType != EntityMovementType.MOVE_JUMP) - && (getMovementMode() != EntityMovementMode.HOVER) - && (getMovementMode() != EntityMovementMode.VTOL) - && (getMovementMode() != EntityMovementMode.NAVAL) - && (getMovementMode() != EntityMovementMode.HYDROFOIL) - && (getMovementMode() != EntityMovementMode.SUBMARINE) - && (getMovementMode() != EntityMovementMode.INF_UMU) - && (getMovementMode() != EntityMovementMode.BIPED_SWIM) - && (getMovementMode() != EntityMovementMode.QUAD_SWIM) - && (getMovementMode() != EntityMovementMode.WIGE) - && canFall() - && !isPavementStep) { + && (step.getElevation() < 0) && !lastPos.equals(curPos) + && (moveType != EntityMovementType.MOVE_JUMP) + && (getMovementMode() != EntityMovementMode.HOVER) + && (getMovementMode() != EntityMovementMode.VTOL) + && (getMovementMode() != EntityMovementMode.NAVAL) + && (getMovementMode() != EntityMovementMode.HYDROFOIL) + && (getMovementMode() != EntityMovementMode.SUBMARINE) + && (getMovementMode() != EntityMovementMode.INF_UMU) + && (getMovementMode() != EntityMovementMode.BIPED_SWIM) + && (getMovementMode() != EntityMovementMode.QUAD_SWIM) + && (getMovementMode() != EntityMovementMode.WIGE) + && canFall() + && !isPavementStep) { return checkWaterMove(curHex.terrainLevel(Terrains.WATER), moveType); } return checkWaterMove(0, moveType); @@ -7962,7 +7964,7 @@ && canFall() * target roll for the piloting skill check. */ public PilotingRollData checkWaterMove(int waterLevel, - EntityMovementType overallMoveType) { + EntityMovementType overallMoveType) { PilotingRollData roll = getBasePilotingRoll(overallMoveType); int mod; @@ -7996,7 +7998,7 @@ public PilotingRollData checkWaterMove(int waterLevel, * the piloting skill check to dislodge them. */ public PilotingRollData checkDislodgeSwarmers(MoveStep step, - EntityMovementType moveType) { + EntityMovementType moveType) { // If we're not being swarmed, return CHECK_FALSE if (Entity.NONE == getSwarmAttackerId()) { @@ -8023,7 +8025,7 @@ public PilotingRollData checkDislodgeSwarmers(MoveStep step, public int checkMovementInBuilding(MoveStep step, MoveStep prevStep, Coords curPos, Coords prevPos) { if ((prevPos == null) - || (prevPos.equals(curPos) && !(this instanceof Protomech))) { + || (prevPos.equals(curPos) && !(this instanceof Protomech))) { return 0; } Hex curHex = game.getBoard().getHex(curPos); @@ -8034,22 +8036,22 @@ public int checkMovementInBuilding(MoveStep step, MoveStep prevStep, } if ((this instanceof Infantry) - && (step.getMovementType(false) != EntityMovementType.MOVE_JUMP)) { + && (step.getMovementType(false) != EntityMovementType.MOVE_JUMP)) { return 0; } if ((this instanceof Protomech) && (prevStep != null) - && (prevStep.getMovementType(false) == EntityMovementType.MOVE_JUMP)) { + && (prevStep.getMovementType(false) == EntityMovementType.MOVE_JUMP)) { return 0; } // check for movement inside a hangar Building curBldg = game.getBoard().getBuildingAt(curPos); if ((null != curBldg) - && curBldg.isIn(prevPos) - && (curBldg.getBldgClass() == Building.HANGAR) - && (curHex.terrainLevel(Terrains.BLDG_ELEV) > height()) - && (step.getElevation() < curHex + && curBldg.isIn(prevPos) + && (curBldg.getBldgClass() == Building.HANGAR) + && (curHex.terrainLevel(Terrains.BLDG_ELEV) > height()) + && (step.getElevation() < curHex .terrainLevel(Terrains.BLDG_ELEV))) { return 0; } @@ -8061,7 +8063,7 @@ public int checkMovementInBuilding(MoveStep step, MoveStep prevStep, } else if (((step.getElevation() == curHex .terrainLevel(Terrains.BLDG_ELEV)) || (step.getElevation() == curHex .terrainLevel(Terrains.BRIDGE_ELEV))) - && (step.getMovementType(false) != EntityMovementType.MOVE_JUMP)) { + && (step.getMovementType(false) != EntityMovementType.MOVE_JUMP)) { rv += 4; } // check previous hex for building @@ -8071,7 +8073,7 @@ public int checkMovementInBuilding(MoveStep step, MoveStep prevStep, prevEl = prevStep.getElevation(); } if ((prevEl < prevHex.terrainLevel(Terrains.BLDG_ELEV)) - && ((curHex.terrainLevel(Terrains.BLDG_CLASS) != 1) || (getHeight() >= curHex + && ((curHex.terrainLevel(Terrains.BLDG_CLASS) != 1) || (getHeight() >= curHex .terrainLevel(Terrains.BLDG_ELEV)))) { rv += 1; } @@ -8088,10 +8090,10 @@ public int checkMovementInBuilding(MoveStep step, MoveStep prevStep, // Check for changing levels within a building if (curPos.equals(prevPos) - && (curBldg != null) - && (prevStep != null) - && (step.getElevation() != prevStep.getElevation()) - && ((step.getType() == MoveStepType.UP) || (step.getType() == MoveStepType.DOWN))) { + && (curBldg != null) + && (prevStep != null) + && (step.getElevation() != prevStep.getElevation()) + && ((step.getType() == MoveStepType.UP) || (step.getType() == MoveStepType.DOWN))) { rv = 8; } @@ -8175,7 +8177,7 @@ public PilotingRollData rollMovementInBuilding(Building bldg, int distance, // append the reason modifier roll.append(new PilotingRollData(getId(), mod, "moving through " + desc - + " " + bldg.getName())); + + " " + bldg.getName())); adjustDifficultTerrainPSRModifier(roll); // Modify the roll by the distance moved so far. @@ -8215,10 +8217,10 @@ public boolean usesTurnMode() { * @param mpUsed The total number of movement points used by the entity during the current turn. * @param currPos The position of the hex where the turn is taking place, which may * modify a roll for terrain. - * @return True if the entity failed a driving check due to turning too sharply. + * @return True if the entity failed a driving check due to turning too sharply. */ public PilotingRollData checkTurnModeFailure(EntityMovementType overallMoveType, - int straightLineHexes, int mpUsed, Coords currPos) { + int straightLineHexes, int mpUsed, Coords currPos) { PlanetaryConditions conditions = game.getPlanetaryConditions(); PilotingRollData roll = getBasePilotingRoll(overallMoveType); @@ -8252,7 +8254,7 @@ public PilotingRollData checkTurnModeFailure(EntityMovementType overallMoveType, roll.addModifier(+1, "mud"); } if (currHex.containsTerrain(Terrains.ICE)) { - roll.addModifier(movementMode == EntityMovementMode.TRACKED? 1 : 2, "ice"); + roll.addModifier(movementMode == EntityMovementMode.TRACKED ? 1 : 2, "ice"); } if (conditions.isSleeting() || conditions.getFog().isFogHeavy() @@ -8260,7 +8262,7 @@ public PilotingRollData checkTurnModeFailure(EntityMovementType overallMoveType, roll.addModifier(+1, "fog/rain"); } if (conditions.getWeather().isHeavySnow()) { - roll.addModifier(movementMode == EntityMovementMode.TRACKED? 1 : 2, "snow"); + roll.addModifier(movementMode == EntityMovementMode.TRACKED ? 1 : 2, "snow"); } } @@ -8457,8 +8459,8 @@ public void load(Entity unit, boolean checkElev, int bayNumber) { if (next.canLoad(unit) && (!checkElev || (unit.getElevation() == getElevation())) && ((bayNumber == -1) - || ((next instanceof Bay) && (((Bay) next).getBayNumber() == bayNumber)) - || ((next instanceof DockingCollar) && (((DockingCollar) next).getCollarNumber() == bayNumber)))) { + || ((next instanceof Bay) && (((Bay) next).getBayNumber() == bayNumber)) + || ((next instanceof DockingCollar) && (((DockingCollar) next).getCollarNumber() == bayNumber)))) { next.load(unit); unit.setTargetBay(-1); // Reset the target bay for later. return; @@ -8982,7 +8984,7 @@ public Vector getLoadedSmallCraft() { // add all of their lists to ours. for (Transporter next : transports) { if ((next instanceof SmallCraftBay) - && (((SmallCraftBay) next).getCurrentDoors() > 0)) { + && (((SmallCraftBay) next).getCurrentDoors() > 0)) { for (Entity e : next.getLoadedUnits()) { result.addElement(e); } @@ -9000,7 +9002,7 @@ public Vector getLaunchableSmallCraft() { // add all of their lists to ours. for (Transporter next : transports) { if ((next instanceof SmallCraftBay) - && (((SmallCraftBay) next).getCurrentDoors() > 0)) { + && (((SmallCraftBay) next).getCurrentDoors() > 0)) { Bay nextbay = (Bay) next; for (Entity e : nextbay.getLaunchableUnits()) { result.addElement(e); @@ -9034,7 +9036,7 @@ public Vector getSmallCraftBays() { for (Transporter next : transports) { if ((next instanceof SmallCraftBay) - && (((SmallCraftBay) next).getCurrentDoors() > 0)) { + && (((SmallCraftBay) next).getCurrentDoors() > 0)) { result.addElement((SmallCraftBay) next); } } @@ -9125,12 +9127,12 @@ public String getUnusedString(ViewFormatting formatting) { } if (formatting == ViewFormatting.HTML && (next instanceof Bay) && (((Bay) next).getBayDamage() > 0)) { result.append("") - .append(next.getUnusedString()) - .append(""); + .append(next.getUnusedString()) + .append(""); } else if (formatting == ViewFormatting.DISCORD && (next instanceof Bay) && (((Bay) next).getBayDamage() > 0)) { result.append(DiscordFormat.RED) - .append(next.getUnusedString()) - .append(DiscordFormat.RESET); + .append(next.getUnusedString()) + .append(DiscordFormat.RESET); } else { result.append(next.getUnusedString()); } @@ -9370,7 +9372,7 @@ public TargetRoll getStealthModifier(int range, Entity ae) { break; default: throw new IllegalArgumentException("Unknown range constant: " - + range); + + range); } // Return the result. @@ -9582,7 +9584,7 @@ public String statusToString() { String str = "Entity [" + getDisplayName() + ", " + getId() + "]:"; if (getPosition() != null) { str = str + "Location: (" + (getPosition().getX() + 1) + ", " - + (getPosition().getY() + 1) + ") "; + + (getPosition().getY() + 1) + ") "; str += "Facing: " + Facing.valueOfInt(getFacing()).name(); } @@ -9591,8 +9593,8 @@ public String statusToString() { str += " Jump: " + getJumpMP(); } str += " Owner: " + getOwner().getName() + " Armor: " + getTotalArmor() - + "/" + getTotalOArmor() + " Internal Structure: " - + getTotalInternal() + "/" + getTotalOInternal(); + + "/" + getTotalOArmor() + " Internal Structure: " + + getTotalInternal() + "/" + getTotalOInternal(); if (!isActive()) { str += " Inactive"; @@ -9623,9 +9625,9 @@ public String statusToString(int loc) { } String str = getLocationName(loc) + " (" + getLocationAbbr(loc) - + "): Armor: " + getArmorString(loc) + "/" + getOArmor(loc) - + " Structure: " + getInternalString(loc) + "/" - + getOInternal(loc) + "\n "; + + "): Armor: " + getArmorString(loc) + "/" + getOArmor(loc) + + " Structure: " + getInternalString(loc) + "/" + + getOInternal(loc) + "\n "; for (CriticalSlot cs : crits[loc]) { if (cs != null) { Mounted mount = cs.getMount(); @@ -9711,8 +9713,8 @@ public void setNeverDeployed(boolean neverDeployed) { */ public boolean shouldDeploy(int round) { return !isDeployed() - && (getDeployRound() <= round) - && !isOffBoard(); + && (getDeployRound() <= round) + && !isOffBoard(); } /** @@ -9723,8 +9725,8 @@ public boolean shouldDeploy(int round) { */ public boolean shouldOffBoardDeploy(int round) { return isOffBoard() - && !isDeployed() - && (getDeployRound() <= round); + && !isDeployed() + && (getDeployRound() <= round); } /** @@ -9761,8 +9763,8 @@ public boolean canFlee() { && !getCrew().isUnconscious() && (getSwarmTargetId() == NONE) && (isOffBoard() || ((pos != null) - && ((pos.getX() == 0) || (pos.getX() == (getGame().getBoard().getWidth() - 1)) - || (pos.getY() == 0) || (pos.getY() == (getGame().getBoard().getHeight() - 1))))); + && ((pos.getX() == 0) || (pos.getX() == (getGame().getBoard().getWidth() - 1)) + || (pos.getY() == 0) || (pos.getY() == (getGame().getBoard().getHeight() - 1))))); } public void setEverSeenByEnemy(boolean b) { @@ -9945,8 +9947,8 @@ public boolean hasDetectedEntity(Player p) { public boolean isSensorReturn(Player spotter) { boolean alliedUnit = !getOwner().isEnemyOf(spotter) - || (getOwner().getTeam() == spotter.getTeam() - && game.getOptions().booleanOption(OptionsConstants.ADVANCED_TEAM_VISION)); + || (getOwner().getTeam() == spotter.getTeam() + && game.getOptions().booleanOption(OptionsConstants.ADVANCED_TEAM_VISION)); boolean sensors = (game.getOptions().booleanOption( OptionsConstants.ADVANCED_TACOPS_SENSORS) @@ -10079,7 +10081,7 @@ public boolean canAssist(GamePhase phase) { } // if you're charging or finding a club, it's already declared if (isUnjammingRAC() || isCharging() || isMakingDfa() || isRamming() - || isFindingClub() || isOffBoard()) { + || isFindingClub() || isOffBoard()) { return false; } // must be active @@ -10148,7 +10150,7 @@ public boolean isEligibleForMovement() { boolean isActive = (!shutDown || isManualShutdown()) && !destroyed && getCrew().isActive() && !unloadedThisTurn && deployed; if (!isActive - || (isImmobile() && !isManualShutdown() && !canUnjamRAC() && + || (isImmobile() && !isManualShutdown() && !canUnjamRAC() && !game.getOptions().booleanOption(OptionsConstants.ADVGRNDMOV_VEHICLES_CAN_EJECT))) { return false; } @@ -10170,7 +10172,7 @@ public boolean isEligibleForOffboard() { for (WeaponMounted mounted : getWeaponList()) { WeaponType wtype = mounted.getType(); if ((wtype != null) - && (wtype.hasFlag(WeaponType.F_TAG) && mounted.isReady())) { + && (wtype.hasFlag(WeaponType.F_TAG) && mounted.isReady())) { return true; } } @@ -10181,7 +10183,7 @@ public boolean isAttackingThisTurn() { List actions = game.getActionsVector(); for (EntityAction ea : actions) { if ((ea.getEntityId() == getId()) - && (ea instanceof AbstractAttackAction)) { + && (ea instanceof AbstractAttackAction)) { return true; } } @@ -10201,7 +10203,7 @@ public boolean isEligibleForPhysical() { if ((this instanceof Infantry) && hasWorkingMisc(MiscType.F_TOOLS, - MiscType.S_DEMOLITION_CHARGE)) { + MiscType.S_DEMOLITION_CHARGE)) { Hex hex = game.getBoard().getHex(getPosition()); if (hex == null) { return false; @@ -10216,8 +10218,8 @@ && hasWorkingMisc(MiscType.F_TOOLS, // if you're charging or finding a club, it's already declared if (isUnjammingRAC() || isCharging() || isMakingDfa() || isRamming() - || isFindingClub() || isOffBoard() || isAssaultDropInProgress() - || isDropping() || isBracing()) { + || isFindingClub() || isOffBoard() || isAssaultDropInProgress() + || isDropping() || isBracing()) { return false; } @@ -10271,7 +10273,7 @@ && getCrew().isClanPilot() && !hasINarcPodsAttached() } // No physical attack works at distances > 1. if ((target.getPosition() != null) - && (Compute.effectiveDistance(game, this, target) > 1)) { + && (Compute.effectiveDistance(game, this, target) > 1)) { continue; } @@ -10279,7 +10281,7 @@ && getCrew().isClanPilot() && !hasINarcPodsAttached() // check if we can dodge and target can attack us, // then we are eligible. canHit |= ((this instanceof Mech) && !isProne() - && hasAbility(OptionsConstants.PILOT_DODGE_MANEUVER) && Compute + && hasAbility(OptionsConstants.PILOT_DODGE_MANEUVER) && Compute .canPhysicalTarget(game, target.getId(), this)); } @@ -10300,7 +10302,7 @@ && hasAbility(OptionsConstants.PILOT_DODGE_MANEUVER) && Compute // Can the entity target *this* hex of the building? final BuildingTarget target = new BuildingTarget(coords, - game.getBoard(), false); + game.getBoard(), false); canHit |= Compute.canPhysicalTarget(game, getId(), target); } // Check the next hex of the building @@ -10319,7 +10321,7 @@ && hasAbility(OptionsConstants.PILOT_DODGE_MANEUVER) && Compute */ public boolean isEligibleForArtyAutoHitHexes() { return isEligibleForTargetingPhase() - && (isOffBoard() || game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_ON_MAP_PREDESIGNATE)); + && (isOffBoard() || game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_ON_MAP_PREDESIGNATE)); } public boolean isEligibleForTargetingPhase() { @@ -10570,7 +10572,7 @@ public boolean hasExternalSearchlight() { public boolean hasSearchlight() { for (MiscMounted m : getMisc()) { if (m.getType().hasFlag(MiscType.F_SEARCHLIGHT) - && !m.isInoperable()) { + && !m.isInoperable()) { return true; } } @@ -10593,7 +10595,7 @@ public void destroyOneSearchlight() { for (MiscMounted m : getMisc()) { if (m.getType().hasFlag(MiscType.F_SEARCHLIGHT) - && !m.isInoperable()) { + && !m.isInoperable()) { m.setDestroyed(true); break; } @@ -10915,7 +10917,7 @@ public void setStructureType(String strucType) { } public int getArmorType(int loc) { - if ((loc >= 0 ) && (loc < armorType.length)) { + if ((loc >= 0) && (loc < armorType.length)) { return armorType[loc]; } else { return EquipmentType.T_ARMOR_UNKNOWN; @@ -11022,27 +11024,27 @@ public boolean removePartialCoverHits(int location, int cover, int side) { break; case LosEffects.COVER_LEFT: if ((location == Mech.LOC_LLEG) - || (location == Mech.LOC_LARM) - || (location == Mech.LOC_LT)) { + || (location == Mech.LOC_LARM) + || (location == Mech.LOC_LT)) { return true; } break; case LosEffects.COVER_RIGHT: if ((location == Mech.LOC_RLEG) - || (location == Mech.LOC_RARM) - || (location == Mech.LOC_RT)) { + || (location == Mech.LOC_RARM) + || (location == Mech.LOC_RT)) { return true; } break; case LosEffects.COVER_HORIZONTAL: if ((location == Mech.LOC_LLEG) - || (location == Mech.LOC_RLEG)) { + || (location == Mech.LOC_RLEG)) { return true; } break; case LosEffects.COVER_UPPER: if ((location == Mech.LOC_LLEG) - || (location == Mech.LOC_RLEG)) { + || (location == Mech.LOC_RLEG)) { return false; } return true; @@ -11050,13 +11052,13 @@ public boolean removePartialCoverHits(int location, int cover, int side) { return true; case LosEffects.COVER_75LEFT: if ((location == Mech.LOC_RARM) - || (location == Mech.LOC_RLEG)) { + || (location == Mech.LOC_RLEG)) { return false; } return true; case LosEffects.COVER_75RIGHT: if ((location == Mech.LOC_LLEG) - || (location == Mech.LOC_LARM)) { + || (location == Mech.LOC_LARM)) { return false; } return true; @@ -11226,17 +11228,17 @@ public int sideTable(Coords src, boolean usePrior, int face, Coords effectivePos Hex curHex = game.getBoard().getHex(getPosition()); if ((srcHex != null) && (curHex != null)) { LosEffects.AttackInfo ai = LosEffects.buildAttackInfo(src, - getPosition(), 1, getElevation(), srcHex.floor(), - curHex.floor()); + getPosition(), 1, getElevation(), srcHex.floor(), + curHex.floor()); ArrayList in = Coords.intervening(ai.attackPos, - ai.targetPos, true); + ai.targetPos, true); leftBetter = LosEffects.dividedLeftBetter(in, game, ai, - Compute.isInBuilding(game, this), new LosEffects()); + Compute.isInBuilding(game, this), new LosEffects()); } } boolean targetIsTank = (this instanceof Tank) - || (game.getOptions().booleanOption( + || (game.getOptions().booleanOption( OptionsConstants.ADVCOMBAT_TACOPS_ADVANCED_MECH_HIT_LOCATIONS) && (this instanceof QuadMech)); if (targetIsTank) { if ((leftBetter == 1) && (fa == 150)) { @@ -11299,7 +11301,7 @@ public int sideTable(Coords src, boolean usePrior, int face, Coords effectivePos if ((fa == 90) && (leftBetter == 1)) { return ToHitData.SIDE_RIGHT; } else if (((fa == 150) && (leftBetter == 1)) - || ((leftBetter == 0) && (fa == 210))) { + || ((leftBetter == 0) && (fa == 210))) { return ToHitData.SIDE_REAR; } else if ((leftBetter == 0) && (fa == 270)) { return ToHitData.SIDE_LEFT; @@ -11359,7 +11361,7 @@ public void addPilotingModifierForTerrain(PilotingRollData roll, Coords c) { * @param enteringRubble True if entering rubble, else false */ public void addPilotingModifierForTerrain(PilotingRollData roll, Coords c, - boolean enteringRubble) { + boolean enteringRubble) { if ((c == null) || (roll == null)) { return; } @@ -11381,7 +11383,7 @@ public void addPilotingModifierForTerrain(PilotingRollData roll, Coords c, * @param step the move step the PSR occurs at */ public void addPilotingModifierForTerrain(PilotingRollData roll, - MoveStep step) { + MoveStep step) { if (step.getElevation() > 0) { return; } @@ -11405,7 +11407,7 @@ public void addPilotingModifierForTerrain(PilotingRollData roll) { */ public boolean fixElevation() { if (!isDeployed() || isOffBoard() - || !game.getBoard().contains(getPosition())) { + || !game.getBoard().contains(getPosition())) { return false; } @@ -11619,8 +11621,8 @@ public void destroyLocation(int loc, boolean blownOff) { if (cs != null) { // count engine hits for maxtech engine explosions if ((cs.getType() == CriticalSlot.TYPE_SYSTEM) - && (cs.getIndex() == Mech.SYSTEM_ENGINE) - && !cs.isDamaged()) { + && (cs.getIndex() == Mech.SYSTEM_ENGINE) + && !cs.isDamaged()) { engineHitsThisPhase++; } @@ -11656,11 +11658,11 @@ public void destroyLocation(int loc, boolean blownOff) { // but is present in the location, so we'll need to look at it as well for (Mounted mounted : getEquipment()) { if (((mounted.getLocation() == loc) && mounted.getType().isHittable()) - || (mounted.isSplit() && (mounted.getSecondLocation() == loc))) { + || (mounted.isSplit() && (mounted.getSecondLocation() == loc))) { if (blownOff) { mounted.setMissing(true); - // we don't want to hit something twice here to avoid triggering - // things that fire off when a mounted is hit + // we don't want to hit something twice here to avoid triggering + // things that fire off when a mounted is hit } else if (!mounted.isHit()) { mounted.setHit(true); } @@ -11669,7 +11671,7 @@ public void destroyLocation(int loc, boolean blownOff) { // dependent locations destroyed, unless they are already destroyed if ((getDependentLocation(loc) != Entity.LOC_NONE) - && !(getInternal(getDependentLocation(loc)) < 0)) { + && !(getInternal(getDependentLocation(loc)) < 0)) { destroyLocation(getDependentLocation(loc), true); } } @@ -11687,8 +11689,8 @@ public void clearDestroyedNarcPods() { private boolean locationCanHoldNarcPod(final int location) { return (getInternal(location) > 0) - && !isLocationBlownOff(location) - && !isLocationBlownOffThisPhase(location); + && !isLocationBlownOff(location) + && !isLocationBlownOffThisPhase(location); } /** @@ -11712,9 +11714,9 @@ public PilotingRollData checkSideSlip(EntityMovementType moveType, && (prevHex != null) && (distance > 1) && ((overallMoveType == EntityMovementType.MOVE_RUN) - || (overallMoveType == EntityMovementType.MOVE_VTOL_RUN) - || (overallMoveType == EntityMovementType.MOVE_SPRINT) - || (overallMoveType == EntityMovementType.MOVE_VTOL_SPRINT)) + || (overallMoveType == EntityMovementType.MOVE_VTOL_RUN) + || (overallMoveType == EntityMovementType.MOVE_SPRINT) + || (overallMoveType == EntityMovementType.MOVE_VTOL_SPRINT)) && (prevFacing != curFacing) && !lastPos.equals(curPos) && !(this instanceof Infantry) && !(this instanceof Protomech)) { @@ -11752,9 +11754,9 @@ public boolean isAirborneVTOLorWIGE() { && (getPosition() != null) && (game.getBoard().getHex(getPosition()) != null) && ((game.getBoard().getHex(getPosition()) - .terrainLevel(Terrains.BLDG_ELEV) >= getElevation()) || (game - .getBoard().getHex(getPosition()) - .terrainLevel(Terrains.BRIDGE_ELEV) >= getElevation()))) { + .terrainLevel(Terrains.BLDG_ELEV) >= getElevation()) || (game + .getBoard().getHex(getPosition()) + .terrainLevel(Terrains.BRIDGE_ELEV) >= getElevation()))) { return false; } return getElevation() > 0; @@ -11781,10 +11783,10 @@ public boolean isCommander() { public boolean hasLinkedMGA(WeaponMounted mounted) { for (WeaponMounted m : getWeaponList()) { if ((m.getLocation() == mounted.getLocation()) - && m.getType().hasFlag(WeaponType.F_MGA) - && !(m.isDestroyed() || m.isBreached()) - && m.getBayWeapons().contains(mounted) - && m.hasModes() && m.curMode().equals("Linked")) { + && m.getType().hasFlag(WeaponType.F_MGA) + && !(m.isDestroyed() || m.isBreached()) + && m.getBayWeapons().contains(mounted) + && m.hasModes() && m.curMode().equals("Linked")) { return true; } } @@ -11811,13 +11813,13 @@ public boolean isCapitalFighter(boolean lounge) { // If we're using the unofficial option for single fighters staying // standard scale & we're not a member of a squadron... then false. if (!lounge && isFighter() - && game.getOptions().booleanOption(OptionsConstants.ADVAERORULES_SINGLE_NO_CAP) - && !isPartOfFighterSquadron()) { + && game.getOptions().booleanOption(OptionsConstants.ADVAERORULES_SINGLE_NO_CAP) + && !isPartOfFighterSquadron()) { return false; } return game.getOptions().booleanOption(OptionsConstants.ADVAERORULES_STRATOPS_CAPITAL_FIGHTER) - && isFighter(); + && isFighter(); } /** @return True when this unit has capital-scale armor. */ @@ -11877,8 +11879,8 @@ public WeaponMounted getFirstBay(WeaponType wtype, int loc, boolean rearMount) { BayWeapon bay = (BayWeapon) m.getType(); int damage = bay.getRoundShortAV() + weapDamage; if ((bay.getAtClass() == wtype.getAtClass()) - && (m.getLocation() == loc) - && (m.isRearMounted() == rearMount) && (damage <= 700)) { + && (m.getLocation() == loc) + && (m.isRearMounted() == rearMount) && (damage <= 700)) { return m; } @@ -11897,7 +11899,7 @@ public int getHeatInArc(int location, boolean rearMount) { } if ((mounted.getLocation() == location) - && (mounted.isRearMounted() == rearMount)) { + && (mounted.isRearMounted() == rearMount)) { arcHeat += mounted.getCurrentHeat(); } } @@ -11957,7 +11959,7 @@ public int chooseSide(Coords attackPos, boolean usePrior) { int newside = sideTable(attackPos, usePrior, dir); // choose the best if ((newside == ToHitData.SIDE_LEFT) - || (newside == ToHitData.SIDE_RIGHT)) { + || (newside == ToHitData.SIDE_RIGHT)) { newside = side; } // that should be the only case, because it can't shift you from @@ -12157,8 +12159,8 @@ public void setRapidFire() { public void extendBlade(int loc) { for (MiscMounted m : getMisc()) { if ((m.getLocation() == loc) && !m.isDestroyed() && !m.isBreached() - && m.getType().hasFlag(MiscType.F_CLUB) - && m.getType().hasSubType(MiscType.S_RETRACTABLE_BLADE)) { + && m.getType().hasFlag(MiscType.F_CLUB) + && m.getType().hasSubType(MiscType.S_RETRACTABLE_BLADE)) { m.setMode("extended"); return; } @@ -12174,14 +12176,14 @@ public void destroyRetractableBlade(int loc) { CriticalSlot slot = getCritical(loc, i); // ignore empty & system slots if ((slot == null) - || (slot.getType() != CriticalSlot.TYPE_EQUIPMENT)) { + || (slot.getType() != CriticalSlot.TYPE_EQUIPMENT)) { continue; } Mounted m = slot.getMount(); if ((m.getLocation() == loc) && !m.isHit() && !m.isBreached() - && (m.getType() instanceof MiscType) - && m.getType().hasFlag(MiscType.F_CLUB) - && m.getType().hasSubType(MiscType.S_RETRACTABLE_BLADE)) { + && (m.getType() instanceof MiscType) + && m.getType().hasFlag(MiscType.F_CLUB) + && m.getType().hasSubType(MiscType.S_RETRACTABLE_BLADE)) { slot.setHit(true); m.setHit(true); return; @@ -12229,7 +12231,7 @@ public void setGameOptions() { // FIXME : This is a really hacky way to do it that results in small craft having ECM when // FIXME : the rule is not in effect and in non-space maps if ((this instanceof SmallCraft) && !(this instanceof Dropship) - && !hasActiveECM() && isMilitary()) { + && !hasActiveECM() && isMilitary()) { try { String prefix = isClan() ? "CL" : "IS"; this.addEquipment( @@ -12267,7 +12269,7 @@ public void setGameOptions() { modes.add("ECM & ECCM"); } } else if (gameOpts.booleanOption(OptionsConstants.ADVAERORULES_STRATOPS_ECM) - && (this instanceof Aero || this instanceof LandAirMech)) { + && (this instanceof Aero || this instanceof LandAirMech)) { modes.add("ECCM"); if (misc.getType().hasFlag(MiscType.F_ANGEL_ECM)) { modes.add("ECM & ECCM"); @@ -12361,9 +12363,9 @@ public void setTurnInterrupted(boolean interrupted) { public boolean turnWasInterrupted() { return turnWasInterrupted; } - + public boolean endOfTurnCargoInteraction() { - return endOfTurnCargoInteraction; + return endOfTurnCargoInteraction; } public Vector getSensors() { @@ -12389,14 +12391,14 @@ public int getSensorCheck() { /** * @param attacksList of know or possible WAAs that might need TAG assistance this turn. */ - public void setIncomingGuidedAttacks(ArrayList attacksList){ + public void setIncomingGuidedAttacks(ArrayList attacksList) { incomingGuidedAttacks = (ArrayList) attacksList.clone(); } /** * @return the vector of possible WAAs that may need this entity's TAG support. */ - public ArrayList getIncomingGuidedAttacks(){ + public ArrayList getIncomingGuidedAttacks() { return incomingGuidedAttacks; } @@ -12431,11 +12433,11 @@ public int getDamageReductionFromModularArmor(HitData hit, int damage, Vector 0)) { + || (ecmComparator.compare(newInfo, bestInfo) > 0)) { bestInfo = newInfo; } } @@ -12622,7 +12624,7 @@ public ECMInfo getECMInfo() { public ECMInfo getECCMInfo() { // If we don't have a position, ECM doesn't have an effect if ((getPosition() == null) || isShutDown() || isStealthOn() - || (getTransportId() != Entity.NONE)) { + || (getTransportId() != Entity.NONE)) { return null; } // E(C)CM operates differently in space (SO pg 110) @@ -12655,7 +12657,7 @@ public ECMInfo getECCMInfo() { for (MiscMounted m : getMisc()) { ECMInfo newInfo = null; if (m.getType().hasFlag(MiscType.F_COMMUNICATIONS) - && m.curMode().equals("ECCM")) { + && m.curMode().equals("ECCM")) { if ((getTotalCommGearTons() > 3)) { newInfo = new ECMInfo(6, 0.5, this); } @@ -12669,7 +12671,7 @@ public ECMInfo getECCMInfo() { newInfo = new ECMInfo(6, 0, this); newInfo.setAngelECCMStrength(1); } else if (m.curMode().equals("ECM & ECCM") - || m.curMode().equals("ECCM & Ghost Targets")) { + || m.curMode().equals("ECCM & Ghost Targets")) { newInfo = new ECMInfo(6, 1, this); // Doesn't count as Angel } @@ -12679,13 +12681,13 @@ public ECMInfo getECCMInfo() { } // Anything that's not Angel ECM } else if (m.getType().hasFlag(MiscType.F_ECM) - && m.curMode().equals("ECCM")) { + && m.curMode().equals("ECCM")) { int range = 6; if (m.getType().hasFlag(MiscType.F_SINGLE_HEX_ECM)) { range = 0; } else if (m.getType().hasFlag(MiscType.F_EW_EQUIPMENT) - || m.getType().hasFlag(MiscType.F_NOVA) - || m.getType().hasFlag(MiscType.F_WATCHDOG)) { + || m.getType().hasFlag(MiscType.F_NOVA) + || m.getType().hasFlag(MiscType.F_WATCHDOG)) { range = 3; } newInfo = new ECMInfo(range, 0, this); @@ -12694,7 +12696,7 @@ public ECMInfo getECCMInfo() { // In some type of ECCM mode... if (newInfo != null) { if ((bestInfo == null) - || (ecmComparator.compare(newInfo, bestInfo) > 0)) { + || (ecmComparator.compare(newInfo, bestInfo) > 0)) { bestInfo = newInfo; } } @@ -12712,12 +12714,12 @@ public double getECMStrength() { if (m.curMode().equals("ECM")) { strength = 2; } else if ((strength < 1) - && (m.curMode().equals("ECM & ECCM") || m.curMode() - .equals("ECM & Ghost Targets"))) { + && (m.curMode().equals("ECM & ECCM") || m.curMode() + .equals("ECM & Ghost Targets"))) { strength = 1; } } else if (m.getType().hasFlag(MiscType.F_ECM) - && m.curMode().equals("ECM") && (strength < 1)) { + && m.curMode().equals("ECM") && (strength < 1)) { strength = 1; } } @@ -12742,12 +12744,12 @@ public double getECCMStrength() { if (m.curMode().equals("ECM")) { strength = 2; } else if ((strength < 1) - && (m.curMode().equals("ECM & ECCM") || m.curMode() - .equals("ECCM & Ghost Targets"))) { + && (m.curMode().equals("ECM & ECCM") || m.curMode() + .equals("ECCM & Ghost Targets"))) { strength = 1; } } else if (m.getType().hasFlag(MiscType.F_ECM) - && m.curMode().equals("ECCM") && (strength < 1)) { + && m.curMode().equals("ECCM") && (strength < 1)) { strength = 1; } } @@ -12766,7 +12768,7 @@ public int getHQIniBonus() { int bonus = 0; for (MiscMounted misc : getMisc()) { if (misc.getType().hasFlag(MiscType.F_COMMUNICATIONS) - && misc.curMode().equals("Default") && !misc.isInoperable()) { + && misc.curMode().equals("Default") && !misc.isInoperable()) { if (getTotalCommGearTons() >= 3) { bonus += 1; } @@ -12797,10 +12799,10 @@ public int getHQIniBonus() { public int getQuirkIniBonus() { // command battlemech and and battle computer are not cumulative if (hasQuirk(OptionsConstants.QUIRK_POS_BATTLE_COMP) && !getCrew().isDead() - && !getCrew().isUnconscious()) { + && !getCrew().isUnconscious()) { return 2; } else if (hasQuirk(OptionsConstants.QUIRK_POS_COMMAND_MECH) && !getCrew().isDead() - && !getCrew().isUnconscious()) { + && !getCrew().isUnconscious()) { return 1; } return 0; @@ -12996,14 +12998,16 @@ public boolean hasBARArmor(int loc) { * Sets the barrier armor rating for support vehicles. Has no effect on other unit types. * @param rating The BAR */ - public void setBARRating(int rating) {} + public void setBARRating(int rating) { + } /** * Sets the barrier armor rating in a specific location for support vehicles. Has no effect on other unit types. * @param rating The BAR * @param loc The location index */ - public void setBARRating(int rating, int loc) {} + public void setBARRating(int rating, int loc) { + } /** * does this entity have an armored chassis? @@ -13190,7 +13194,7 @@ public int countPartialRepairs() { */ public int countQuirks(String grpKey) { if ((null == game) - || !game.getOptions().booleanOption(OptionsConstants.ADVANCED_STRATOPS_QUIRKS)) { + || !game.getOptions().booleanOption(OptionsConstants.ADVANCED_STRATOPS_QUIRKS)) { return 0; } @@ -13203,7 +13207,7 @@ public int countQuirks(String grpKey) { */ public String getQuirkList(String sep) { if ((null == game) - || !game.getOptions().booleanOption(OptionsConstants.ADVANCED_STRATOPS_QUIRKS)) { + || !game.getOptions().booleanOption(OptionsConstants.ADVANCED_STRATOPS_QUIRKS)) { return ""; } @@ -13227,9 +13231,9 @@ public int getRearArc() { @Override public boolean isAirborne() { return (!isDestroyed()) - && (getAltitude() > 0) - || (getMovementMode() == EntityMovementMode.AERODYNE) - || (getMovementMode() == EntityMovementMode.SPHEROID); + && (getAltitude() > 0) + || (getMovementMode() == EntityMovementMode.AERODYNE) + || (getMovementMode() == EntityMovementMode.SPHEROID); } public boolean isSpaceborne() { @@ -13327,7 +13331,7 @@ public int getInitialBV() { * @param bv The initial BV of a unit. */ public void setInitialBV(int bv) { - initialBV = bv; + initialBV = bv; } /** @@ -13471,7 +13475,7 @@ public int getExtraC3BV(int baseBV) { // also, each 'has' loops through all equipment. inefficient to do it 3 times int xbv = 0; if ((game != null) - && ((hasC3MM() && (calculateFreeC3MNodes() < 2)) + && ((hasC3MM() && (calculateFreeC3MNodes() < 2)) || (hasC3M() && (calculateFreeC3Nodes() < 3)) || (hasC3S() && (c3Master > NONE)) || ((hasC3i() || hasNavalC3()) && (calculateFreeC3Nodes() < 5)))) { int totalForceBV = 0; @@ -13493,7 +13497,7 @@ public int getExtraC3BV(int baseBV) { public boolean hasUnloadedUnitsFromBays() { for (Transporter next : transports) { if ((next instanceof Bay) - && (((Bay) next).getNumberUnloadedThisTurn() > 0)) { + && (((Bay) next).getNumberUnloadedThisTurn() > 0)) { return true; } } @@ -13814,7 +13818,7 @@ private boolean doMASCOrSuperchargerFailureCheckFor(MiscMounted masc, VectorEntity is required to make PSRs to avoid falling. + * @return Whether the Entity is required to make PSRs to avoid falling. */ public boolean canFall(boolean gyroLegDamage) { return false; @@ -14553,7 +14557,7 @@ public void setTargetBay(int tb) { * Convenience method that checks whether a bit is set in the entity type field. * * @param flag An ETYPE_* value - * @return true if getEntityType() has the flag set + * @return true if getEntityType() has the flag set */ public boolean hasETypeFlag(long flag) { return (getEntityType() & flag) == flag; @@ -14671,7 +14675,7 @@ public int damageSystem(int type, int slot, int loc, int hits) { m = getEquipment(slot); } if (((type == CriticalSlot.TYPE_SYSTEM) && (cs.getIndex() == slot)) - || ((type == CriticalSlot.TYPE_EQUIPMENT) + || ((type == CriticalSlot.TYPE_EQUIPMENT) && (m.equals(cs.getMount()) || m.equals(cs.getMount2())))) { if (nhits < hits) { cs.setHit(true); @@ -14747,8 +14751,8 @@ public int getMaxWeaponRange(boolean targetIsAirborne) { range = WeaponType.AIRBORNE_WEAPON_RANGES[type.getMaxRange(weapon)] * rangeMultiplier; } else { range = (game.getOptions().booleanOption( - OptionsConstants.ADVCOMBAT_TACOPS_RANGE) ? type.getExtremeRange() - : type.getLongRange()); + OptionsConstants.ADVCOMBAT_TACOPS_RANGE) ? type.getExtremeRange() + : type.getLongRange()); } if (range > maxRange) { @@ -14813,7 +14817,7 @@ public int getASEWAffected() { public boolean hasActivatedRadicalHS() { for (MiscMounted m : getMisc()) { if (m.getType().hasFlag(MiscType.F_RADICAL_HEATSINK) - && m.curMode().equals("On")) { + && m.curMode().equals("On")) { return true; } } @@ -15523,10 +15527,10 @@ public boolean isWeaponBlockedByTowing(int loc, int secondaryFacing, boolean isR return true; } else if (!hitch.getRearMounted() && (loc == Tank.LOC_FRONT || ((loc == Tank.LOC_TURRET - || loc == Tank.LOC_TURRET_2 - || loc == SuperHeavyTank.LOC_TURRET - || loc == SuperHeavyTank.LOC_TURRET_2) - && (secondaryFacing == getFacing())))) { + || loc == Tank.LOC_TURRET_2 + || loc == SuperHeavyTank.LOC_TURRET + || loc == SuperHeavyTank.LOC_TURRET_2) + && (secondaryFacing == getFacing())))) { return true; } } @@ -15571,6 +15575,7 @@ public int modifyPhysicalDamageForMeleeSpecialist() { } // Getters and setters for sensor contacts and firing solutions. Currently, only used in space combat + /** * Retrieves the IDs of all entities that this entity has detected with sensors * @return the contents of this entity's sensorContacts set @@ -15887,9 +15892,9 @@ public MPBoosters getMPBoosters(boolean onlyArmed) { boolean hasMASC = false; boolean hasSupercharger = false; for (MiscMounted m : getMisc()) { - if (!m.isInoperable() && m.getType().hasFlag(MiscType.F_MASC) ) { + if (!m.isInoperable() && m.getType().hasFlag(MiscType.F_MASC)) { // Supercharger is a subtype of MASC in MiscType - if ( m.getType().hasSubType(MiscType.S_SUPERCHARGER)) { + if (m.getType().hasSubType(MiscType.S_SUPERCHARGER)) { hasSupercharger = !onlyArmed || m.curMode().equals("Armed"); } else { hasMASC = !onlyArmed || m.curMode().equals("Armed"); @@ -15941,7 +15946,8 @@ public boolean hasMulId() { * other CASE types are already present on a location. *

This method does nothing by default and must be overridden for unit types that get Clan CASE. */ - public void addClanCase() { } + public void addClanCase() { + } /** @return True for unit types that have an automatic external searchlight (Meks and Tanks). */ public boolean getsAutoExternalSearchlight() { @@ -16053,9 +16059,9 @@ public boolean countForStrengthSum() { /** @return True if the unit should use Edge based on the current options and assigned Edge points */ public boolean shouldUseEdge(String option) { - return (game.getOptions().booleanOption(OptionsConstants.EDGE) - && getCrew() != null - && getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption(option)); + return (game.getOptions().booleanOption(OptionsConstants.EDGE) + && getCrew() != null + && getCrew().hasEdgeRemaining() + && getCrew().getOptions().booleanOption(option)); } } \ No newline at end of file diff --git a/megamek/src/megamek/common/pathfinder/AbstractPathFinder.java b/megamek/src/megamek/common/pathfinder/AbstractPathFinder.java index 4058d022762..de9078b3320 100644 --- a/megamek/src/megamek/common/pathfinder/AbstractPathFinder.java +++ b/megamek/src/megamek/common/pathfinder/AbstractPathFinder.java @@ -26,7 +26,7 @@ /** * This class provides a skeletal implementation of pathfinder algorithm in a * given directed graph. - * + * * It uses a generalisation of Dijkstra algorithm. User must provide methods * that allow traversing the graph and evaluating paths. All needed methods have * been encapsulated and separated in classes: @@ -40,9 +40,9 @@ *

  • StopCondition - responsible for halting if user does not want to * traverse whole graph.
  • * - * + * * @author Saginatio - * + * * @param the type of nodes in the graph. * @param the type of computed lowest cost for a node. If needed this type * can contain information for recreating the path. @@ -55,7 +55,7 @@ public class AbstractPathFinder { /** * Factory for retrieving neighbouring edges. - * + * * @param the type of directed edges used by the graph. */ public interface AdjacencyMap { @@ -68,14 +68,14 @@ public interface AdjacencyMap { /** * Represents a function for retrieving destination node of an edge. - * + * * @param the type of nodes in the graph * @param the type of directed edges used by the graph */ public interface DestinationMap { /** * Returns a destination node of a given edge. - * + * * @param e a directed edge * @return the destination node of the given edge */ @@ -84,14 +84,14 @@ public interface DestinationMap { /** * Represents a function that relaxes an edge. - * + * * @param the type of computed lowest cost for a node * @param the type of directed edges used by the graph */ public interface EdgeRelaxer { /** * Relaxes an edge. - * + * * @param v best value till now. Might be null. * @param e candidate for the new best value * @param comparator edge comparator @@ -107,7 +107,7 @@ public static abstract class Filter { /** * Returns filtered collection by removing those objects that fail * {@link #shouldStay} test. - * + * * @param collection collection to be filtered * @return filtered collection */ @@ -123,7 +123,7 @@ public Collection doFilter(Collection collection) { /** * Tests if the object should stay in the collection. - * + * * @param object tested object * @return true if the object should stay in the collection */ @@ -132,7 +132,7 @@ public Collection doFilter(Collection collection) { /** * The stop condition that is processed after every successful relaxation. - * + * * @param the type of directed edges used by the graph */ public interface StopCondition { @@ -245,7 +245,7 @@ public AbstractPathFinder(DestinationMap edgeDestinationMap, EdgeRelaxer edgeFilter) { @@ -265,7 +265,7 @@ public void addStopCondition(StopCondition stopCondition) { /** * Computes shortest paths to nodes in the graph. - * + * * @param startingEdges a collection of possible starting edges. */ public void run(Collection startingEdges) { @@ -299,6 +299,8 @@ public void run(Collection startingEdges) { } } catch (OutOfMemoryError ex) { LogManager.getLogger().error("Not enough memory to analyse all options. Try setting time limit to lower value, or increase java memory limit.", ex); + } catch (IllegalArgumentException ex) { + LogManager.getLogger().debug("Lost sight of a unit while plotting predicted paths", ex); } catch (Exception ex) { // Do something, don't just swallow the exception, good lord LogManager.getLogger().error("", ex); @@ -307,7 +309,7 @@ public void run(Collection startingEdges) { /** * Computes shortest paths to nodes in the graph. - * + * * @param start a starting edge. */ public void run(E start) { @@ -332,7 +334,7 @@ protected C getCostOf(N node) { /** * Returns the cost map. Important: Neither the returned map, nor its * elements, should be modified. - * + * * @return map Node to LowestCost */ protected Map getPathCostMap() { @@ -345,14 +347,14 @@ protected Map getPathCostMap() { public void setAdjacencyMap(AdjacencyMap edgeNeighborsFactory) { this.adjacencyMap = Objects.requireNonNull(edgeNeighborsFactory); } - + public AdjacencyMap getAdjacencyMap() { return adjacencyMap; } /** * Sets comparator. - * + * * @param comparator implementation of path comparator. Each path is * uniquely defined by its last edge. (path:= an edge * concatenated with the best path to the source of the edge)