From 3a7c3087aefd78f0ae03fcf4186b29d97a31803f Mon Sep 17 00:00:00 2001 From: Richard J Hancock Date: Mon, 9 Sep 2024 13:55:50 -0500 Subject: [PATCH] Removed Unused Imports --- .../client/ui/swing/EditBotsDialog.java | 1 - .../megamek/client/ui/swing/HelpDialog.java | 10 +- .../megamek/client/ui/swing/IClientGUI.java | 10 +- .../ui/swing/OffBoardTargetOverlay.java | 2 - .../ui/swing/RandomMapPanelAdvanced.java | 615 +++++++++--------- .../swing/dialog/MultiIntSelectorDialog.java | 39 +- .../src/megamek/common/ArtilleryTracker.java | 2 - megamek/src/megamek/common/ConvFighter.java | 12 +- .../src/megamek/common/FixedWingSupport.java | 1 - megamek/src/megamek/common/GameReports.java | 8 +- megamek/src/megamek/common/IGame.java | 1 - .../src/megamek/common/SpecialHexDisplay.java | 19 +- .../common/actions/AbstractEntityAction.java | 4 +- .../actions/TeleMissileAttackAction.java | 47 +- .../alphaStrike/cardDrawer/ASAeroCard.java | 23 +- .../cardDrawer/ASProtoMekCard.java | 1 - .../ClientServerCommandLineParser.java | 14 +- .../jacksonadapters/SBFUnitDeserializer.java | 22 +- .../megamek/common/net/packets/Packet.java | 7 +- .../IlluminationLevel.java | 25 +- .../SBFReportEntry.java | 53 +- .../SBFRollReportEntry.java | 2 - .../SBFUnitReportEntry.java | 1 - .../weapons/capitalweapons/AR10Weapon.java | 1 - .../common/weapons/lasers/ISERLaserLarge.java | 4 - .../server/commands/CheckBVTeamCommand.java | 4 +- .../server/sbf/SBFGameManagerHelper.java | 2 - .../server/sbf/SBFPhaseEndManager.java | 218 ++++--- .../megamek/common/ComputeArtilleryTest.java | 12 +- .../megamek/common/WeaponTypeTest.java | 36 +- .../megamek/common/verifier/TestAeroTest.java | 8 +- 31 files changed, 607 insertions(+), 597 deletions(-) diff --git a/megamek/src/megamek/client/ui/swing/EditBotsDialog.java b/megamek/src/megamek/client/ui/swing/EditBotsDialog.java index f1218c7164b..2830a3ecc62 100644 --- a/megamek/src/megamek/client/ui/swing/EditBotsDialog.java +++ b/megamek/src/megamek/client/ui/swing/EditBotsDialog.java @@ -19,7 +19,6 @@ package megamek.client.ui.swing; import megamek.client.AbstractClient; -import megamek.client.Client; import megamek.client.bot.princess.BehaviorSettings; import megamek.client.bot.princess.Princess; import megamek.client.bot.princess.PrincessException; diff --git a/megamek/src/megamek/client/ui/swing/HelpDialog.java b/megamek/src/megamek/client/ui/swing/HelpDialog.java index 536a71ebbfe..e3a0a03bf26 100644 --- a/megamek/src/megamek/client/ui/swing/HelpDialog.java +++ b/megamek/src/megamek/client/ui/swing/HelpDialog.java @@ -24,13 +24,13 @@ import javax.swing.*; import javax.swing.border.EmptyBorder; import javax.swing.event.HyperlinkEvent; -import java.awt.*; -import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; import java.net.URL; /** - * This is a basic help dialog that can display HTML pages and also reacts to hyperlink clicks. + * This is a basic help dialog that can display HTML pages and also reacts to + * hyperlink clicks. + * * @author Deric "Netzilla" Page (deric dot page at usa dot net) * @author Simon (Juliez) */ @@ -53,7 +53,7 @@ public HelpDialog(String title, URL helpURL, JFrame parent) { JOptionPane.showMessageDialog(this, ex.getMessage(), "ERROR", JOptionPane.ERROR_MESSAGE); } - //Listen for the user clicking on hyperlinks. + // Listen for the user clicking on hyperlinks. mainView.addHyperlinkListener(e -> { try { if (HyperlinkEvent.EventType.ACTIVATED == e.getEventType()) { @@ -81,4 +81,4 @@ public HelpDialog(String title, URL helpURL, JFrame parent) { setSize(WIDTH, HEIGHT); setLocationRelativeTo(null); } -} \ No newline at end of file +} diff --git a/megamek/src/megamek/client/ui/swing/IClientGUI.java b/megamek/src/megamek/client/ui/swing/IClientGUI.java index 1d1e4e1e976..5bed4701443 100644 --- a/megamek/src/megamek/client/ui/swing/IClientGUI.java +++ b/megamek/src/megamek/client/ui/swing/IClientGUI.java @@ -19,7 +19,6 @@ package megamek.client.ui.swing; import megamek.client.IClient; -import megamek.common.InGameObject; import javax.swing.*; @@ -31,8 +30,10 @@ public interface IClientGUI { JFrame getFrame(); /** - * Returns true if a dialog is visible on top of the ClientGUI. For example, the MegaMekController - * should ignore hotkeys if there is a dialog, like the CommonSettingsDialog, open. + * Returns true if a dialog is visible on top of the ClientGUI. For example, the + * MegaMekController + * should ignore hotkeys if there is a dialog, like the CommonSettingsDialog, + * open. * * @return True when hotkey events should not be forwarded to this ClientGUI */ @@ -45,7 +46,8 @@ public interface IClientGUI { void initialize(); /** - * Performs shut down for threads and sockets and other things that can be disposed. + * Performs shut down for threads and sockets and other things that can be + * disposed. */ void die(); diff --git a/megamek/src/megamek/client/ui/swing/OffBoardTargetOverlay.java b/megamek/src/megamek/client/ui/swing/OffBoardTargetOverlay.java index 2b5dbad70a4..ca9e4aa2761 100644 --- a/megamek/src/megamek/client/ui/swing/OffBoardTargetOverlay.java +++ b/megamek/src/megamek/client/ui/swing/OffBoardTargetOverlay.java @@ -15,7 +15,6 @@ import megamek.client.ui.IDisplayable; import megamek.client.ui.Messages; -import megamek.client.ui.SharedUtility; import megamek.common.*; import megamek.common.actions.ArtilleryAttackAction; import megamek.common.actions.WeaponAttackAction; @@ -23,7 +22,6 @@ import megamek.common.util.fileUtils.MegaMekFile; import megamek.common.weapons.bayweapons.BayWeapon; -import javax.swing.*; import java.awt.*; import java.util.ArrayList; import java.util.HashMap; diff --git a/megamek/src/megamek/client/ui/swing/RandomMapPanelAdvanced.java b/megamek/src/megamek/client/ui/swing/RandomMapPanelAdvanced.java index 1e8054d03b6..2cd922ea62d 100644 --- a/megamek/src/megamek/client/ui/swing/RandomMapPanelAdvanced.java +++ b/megamek/src/megamek/client/ui/swing/RandomMapPanelAdvanced.java @@ -27,8 +27,6 @@ import javax.swing.border.LineBorder; import javax.swing.border.TitledBorder; import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; /** * @author Deric "Netzilla" Page (deric dot page at usa dot net) @@ -43,7 +41,7 @@ public class RandomMapPanelAdvanced extends JPanel { private static final String CT_GRID = "GRID"; private static final String CT_METRO = "METRO"; private static final String CT_TOWN = "TOWN"; - private static final String[] CT_CHOICES = new String[]{CT_NONE, CT_GRID, CT_HUB, CT_METRO, CT_TOWN}; + private static final String[] CT_CHOICES = new String[] { CT_NONE, CT_GRID, CT_HUB, CT_METRO, CT_TOWN }; // Using tabs to keep the data organized. private final JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP, JTabbedPane.WRAP_TAB_LAYOUT); @@ -52,215 +50,214 @@ public class RandomMapPanelAdvanced extends JPanel { private MapSettings mapSettings; // Elevation - private final VerifiableTextField elevationAlgorithmField = - new VerifiableTextField(4, true, true, new VerifyInRange(0, BoardUtilities.getAmountElevationGenerators() - 1, true)); - private final VerifiableTextField hillinessField = - new VerifiableTextField(4, true, true, new VerifyInRange(0, 99, true)); - private final VerifiableTextField elevationRangeField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField elevationCliffsField = - new VerifiableTextField(4, true, true, new VerifyInRange(0, 100, true)); - private final VerifiableTextField elevationInversionField = - new VerifiableTextField(4, true, true, new VerifyInRange(0, 99, true)); + private final VerifiableTextField elevationAlgorithmField = new VerifiableTextField(4, true, true, + new VerifyInRange(0, BoardUtilities.getAmountElevationGenerators() - 1, true)); + private final VerifiableTextField hillinessField = new VerifiableTextField(4, true, true, + new VerifyInRange(0, 99, true)); + private final VerifiableTextField elevationRangeField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField elevationCliffsField = new VerifiableTextField(4, true, true, + new VerifyInRange(0, 100, true)); + private final VerifiableTextField elevationInversionField = new VerifiableTextField(4, true, true, + new VerifyInRange(0, 99, true)); private final JCheckBox invertNegativeCheck = new JCheckBox(); - private final VerifiableTextField elevationPeaksField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); + private final VerifiableTextField elevationPeaksField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); private final JComboBox mountainStyleCombo = new JComboBox<>(MountainStyle.getStyleDescriptions()); - private final VerifiableTextField mountainHeightMinField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField mountainHeightMaxField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField mountainWidthMinField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField mountainWidthMaxField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField craterChanceField = - new VerifiableTextField(4, true, true, new VerifyInRange(0, 100, true)); - private final VerifiableTextField craterAmountMinField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField craterAmountMaxField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField craterSizeMinField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField craterSizeMaxField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); + private final VerifiableTextField mountainHeightMinField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField mountainHeightMaxField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField mountainWidthMinField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField mountainWidthMaxField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField craterChanceField = new VerifiableTextField(4, true, true, + new VerifyInRange(0, 100, true)); + private final VerifiableTextField craterAmountMinField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField craterAmountMaxField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField craterSizeMinField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField craterSizeMaxField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); // Natural Features - private final VerifiableTextField roughsMinField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField roughsMaxField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField roughsMinSizeField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField roughsMaxSizeField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - - private final VerifiableTextField roughsUltraChanceField = - new VerifiableTextField(4, true, true, new VerifyInRange(0, 100, true)); - - private final VerifiableTextField sandsMinField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField sandsMaxField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField sandsSizeMinField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField sandsSizeMaxField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField swampsMinField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField swampsMaxField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField swampsMinSizeField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField swampsMaxSizeField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField woodsMinField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField woodsMaxField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField woodsMinSizeField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField woodsMaxSizeField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField woodsHeavyChanceField = - new VerifiableTextField(4, true, true, new VerifyInRange(0, 100, true)); - private final VerifiableTextField woodsUltraChanceField = - new VerifiableTextField(4, true, true, new VerifyInRange(0, 100, true)); - - - private final VerifiableTextField jungleMinField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField jungleMaxField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField jungleMinSizeField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField jungleMaxSizeField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField jungleHeavyChanceField = - new VerifiableTextField(4, true, true, new VerifyInRange(0, 100, true)); - private final VerifiableTextField jungleUltraChanceField = - new VerifiableTextField(4, true, true, new VerifyInRange(0, 100, true)); - - private final VerifiableTextField foliageMinField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField foliageMaxField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField foliageMinSizeField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField foliageMaxSizeField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField foliageHeavyChanceField = - new VerifiableTextField(4, true, true, new VerifyInRange(0, 100, true)); - - private final VerifiableTextField snowMinField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField snowMaxField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField snowSizeMinField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField snowSizeMaxField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - - private final VerifiableTextField tundraMinField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField tundraMaxField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField tundraSizeMinField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField tundraSizeMaxField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); + private final VerifiableTextField roughsMinField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField roughsMaxField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField roughsMinSizeField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField roughsMaxSizeField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + + private final VerifiableTextField roughsUltraChanceField = new VerifiableTextField(4, true, true, + new VerifyInRange(0, 100, true)); + + private final VerifiableTextField sandsMinField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField sandsMaxField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField sandsSizeMinField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField sandsSizeMaxField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField swampsMinField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField swampsMaxField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField swampsMinSizeField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField swampsMaxSizeField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField woodsMinField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField woodsMaxField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField woodsMinSizeField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField woodsMaxSizeField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField woodsHeavyChanceField = new VerifiableTextField(4, true, true, + new VerifyInRange(0, 100, true)); + private final VerifiableTextField woodsUltraChanceField = new VerifiableTextField(4, true, true, + new VerifyInRange(0, 100, true)); + + private final VerifiableTextField jungleMinField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField jungleMaxField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField jungleMinSizeField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField jungleMaxSizeField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField jungleHeavyChanceField = new VerifiableTextField(4, true, true, + new VerifyInRange(0, 100, true)); + private final VerifiableTextField jungleUltraChanceField = new VerifiableTextField(4, true, true, + new VerifyInRange(0, 100, true)); + + private final VerifiableTextField foliageMinField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField foliageMaxField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField foliageMinSizeField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField foliageMaxSizeField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField foliageHeavyChanceField = new VerifiableTextField(4, true, true, + new VerifyInRange(0, 100, true)); + + private final VerifiableTextField snowMinField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField snowMaxField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField snowSizeMinField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField snowSizeMaxField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + + private final VerifiableTextField tundraMinField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField tundraMaxField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField tundraSizeMinField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField tundraSizeMaxField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); // Civilized Features. - private final VerifiableTextField fieldsMinField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField fieldsMaxField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField fieldSizeMinField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField fieldSizeMaxField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField fortifiedMinField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField fortifiedMaxField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField fortifiedSizeMinField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField fortifiedSizeMaxField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField pavementMinField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField pavementMaxField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField pavementSizeMinField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField pavementSizeMaxField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField roadChanceField = - new VerifiableTextField(4, true, true, new VerifyInRange(0, 100, true)); - private final VerifiableTextField rubbleMinField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField rubbleMaxField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField rubbleSizeMinField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField rubbleSizeMaxField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - - private final VerifiableTextField rubbleUltraChanceField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); + private final VerifiableTextField fieldsMinField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField fieldsMaxField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField fieldSizeMinField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField fieldSizeMaxField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField fortifiedMinField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField fortifiedMaxField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField fortifiedSizeMinField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField fortifiedSizeMaxField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField pavementMinField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField pavementMaxField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField pavementSizeMinField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField pavementSizeMaxField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField roadChanceField = new VerifiableTextField(4, true, true, + new VerifyInRange(0, 100, true)); + private final VerifiableTextField rubbleMinField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField rubbleMaxField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField rubbleSizeMinField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField rubbleSizeMaxField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + + private final VerifiableTextField rubbleUltraChanceField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); private final JComboBox cityTypeCombo = new JComboBox<>(CT_CHOICES); - private final VerifiableTextField cityBlocks = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField cityCFMinField = - new VerifiableTextField(4, true, true, new VerifyInRange(1, 150, true)); - private final VerifiableTextField cityCFMaxField = - new VerifiableTextField(4, true, true, new VerifyInRange(1, 150, true)); - private final VerifiableTextField cityFloorsMinField = - new VerifiableTextField(4, true, true, new VerifyInRange(1, 100, true)); - private final VerifiableTextField cityFloorsMaxField = - new VerifiableTextField(4, true, true, new VerifyInRange(1, 100, true)); - private final VerifiableTextField cityDensityField = - new VerifiableTextField(4, true, true, new VerifyInRange(1, 100, true)); - private final VerifiableTextField townSizeField = - new VerifiableTextField(4, true, true, new VerifyInRange(1, 100, true)); + private final VerifiableTextField cityBlocks = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField cityCFMinField = new VerifiableTextField(4, true, true, + new VerifyInRange(1, 150, true)); + private final VerifiableTextField cityCFMaxField = new VerifiableTextField(4, true, true, + new VerifyInRange(1, 150, true)); + private final VerifiableTextField cityFloorsMinField = new VerifiableTextField(4, true, true, + new VerifyInRange(1, 100, true)); + private final VerifiableTextField cityFloorsMaxField = new VerifiableTextField(4, true, true, + new VerifyInRange(1, 100, true)); + private final VerifiableTextField cityDensityField = new VerifiableTextField(4, true, true, + new VerifyInRange(1, 100, true)); + private final VerifiableTextField townSizeField = new VerifiableTextField(4, true, true, + new VerifyInRange(1, 100, true)); // Water - private final VerifiableTextField lakesMinField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField lakesMaxField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField lakeSizeMinField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField lakeSizeMaxField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField deepChanceField = - new VerifiableTextField(4, true, true, new VerifyInRange(0, 100, true)); - private final VerifiableTextField riverChanceField = - new VerifiableTextField(4, true, true, new VerifyInRange(0, 100, true)); - private final VerifiableTextField iceMinField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField iceMaxField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField iceSizeMinField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField iceSizeMaxField = - new VerifiableTextField(4, true, true, new VerifyIsPositiveInteger()); - private final VerifiableTextField freezeChanceField = - new VerifiableTextField(4, true, true, new VerifyInRange(0, 100, true)); + private final VerifiableTextField lakesMinField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField lakesMaxField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField lakeSizeMinField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField lakeSizeMaxField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField deepChanceField = new VerifiableTextField(4, true, true, + new VerifyInRange(0, 100, true)); + private final VerifiableTextField riverChanceField = new VerifiableTextField(4, true, true, + new VerifyInRange(0, 100, true)); + private final VerifiableTextField iceMinField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField iceMaxField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField iceSizeMinField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField iceSizeMaxField = new VerifiableTextField(4, true, true, + new VerifyIsPositiveInteger()); + private final VerifiableTextField freezeChanceField = new VerifiableTextField(4, true, true, + new VerifyInRange(0, 100, true)); // Special effects - private final VerifiableTextField droughtChanceField = - new VerifiableTextField(4, true, true, new VerifyInRange(0, 100, true)); - private final VerifiableTextField floodChanceField = - new VerifiableTextField(4, true, true, new VerifyInRange(0, 100, true)); - private final VerifiableTextField fireChanceField = - new VerifiableTextField(4, true, true, new VerifyInRange(0, 100, true)); - private final VerifiableTextField specialFxField = - new VerifiableTextField(4, true, true, new VerifyIsInteger()); + private final VerifiableTextField droughtChanceField = new VerifiableTextField(4, true, true, + new VerifyInRange(0, 100, true)); + private final VerifiableTextField floodChanceField = new VerifiableTextField(4, true, true, + new VerifyInRange(0, 100, true)); + private final VerifiableTextField fireChanceField = new VerifiableTextField(4, true, true, + new VerifyInRange(0, 100, true)); + private final VerifiableTextField specialFxField = new VerifiableTextField(4, true, true, new VerifyIsInteger()); /** - * Constructor for the advanced map settings panel. This gives more detailed control over how the map will be + * Constructor for the advanced map settings panel. This gives more detailed + * control over how the map will be * generated. * * @param mapSettings The settings for the map to be generated. @@ -286,7 +283,8 @@ public void setMapSettings(MapSettings mapSettings) { } /** - * Update the panel controls with the values from the {@link MapSettings} object. + * Update the panel controls with the values from the {@link MapSettings} + * object. */ private void loadMapSettings() { riverChanceField.setText(String.valueOf(mapSettings.getProbRiver())); @@ -429,14 +427,14 @@ private JScrollPane setupWaterPanel() { private JPanel setupRiverPanel() { JPanel panel = new FeaturePanel(new SpringLayout()); - + JLabel riverChanceLabel = new JLabel(Messages.getString("RandomMapDialog.labProbRiver")); panel.add(riverChanceLabel); riverChanceField.setToolTipText(Messages.getString("RandomMapDialog.riverChanceField.toolTip")); panel.add(riverChanceField); panel.setBorder(new TitledBorder(new LineBorder(Color.black, 1), - Messages.getString("RandomMapDialog.borderRiver"))); + Messages.getString("RandomMapDialog.borderRiver"))); RandomMapPanelBasic.makeCompactGrid(panel, 1, 2, 6, 6, 6, 6); return panel; } @@ -472,7 +470,7 @@ private JPanel setupIcePanel() { panel.add(new JLabel()); panel.setBorder(new TitledBorder(new LineBorder(Color.black, 1), - Messages.getString("RandomMapDialog.borderIce"))); + Messages.getString("RandomMapDialog.borderIce"))); RandomMapPanelBasic.makeCompactGrid(panel, 3, 4, 6, 6, 6, 6); return panel; @@ -507,7 +505,7 @@ private JPanel setupLakesPanel() { panel.add(new JLabel()); panel.setBorder(new TitledBorder(new LineBorder(Color.black, 1), - Messages.getString("RandomMapDialog.borderLakes"))); + Messages.getString("RandomMapDialog.borderLakes"))); RandomMapPanelBasic.makeCompactGrid(panel, 3, 4, 6, 6, 6, 6); return panel; @@ -549,7 +547,7 @@ private JPanel setupFieldsPanel() { panel.add(fieldSizeMaxField); panel.setBorder(new TitledBorder(new LineBorder(Color.black, 2), - Messages.getString("RandomMapDialog.borderFields"))); + Messages.getString("RandomMapDialog.borderFields"))); RandomMapPanelBasic.makeCompactGrid(panel, 2, 4, 6, 6, 6, 6); return panel; @@ -584,7 +582,7 @@ private JPanel setupRubblePanel() { panel.add(new JLabel()); panel.setBorder(new TitledBorder(new LineBorder(Color.black, 2), - Messages.getString("RandomMapDialog.borderRubble"))); + Messages.getString("RandomMapDialog.borderRubble"))); RandomMapPanelBasic.makeCompactGrid(panel, 3, 4, 6, 6, 6, 6); return panel; @@ -599,7 +597,7 @@ private JPanel setupRoadPanel() { panel.add(roadChanceField); panel.setBorder(new TitledBorder(new LineBorder(Color.black, 2), - Messages.getString("RandomMapDialog.borderRoad"))); + Messages.getString("RandomMapDialog.borderRoad"))); RandomMapPanelBasic.makeCompactGrid(panel, 1, 2, 6, 6, 6, 6); return panel; } @@ -626,7 +624,7 @@ private JPanel setupPavementPanel() { panel.add(pavementSizeMaxField); panel.setBorder(new TitledBorder(new LineBorder(Color.black, 2), - Messages.getString("RandomMapDialog.borderPavement"))); + Messages.getString("RandomMapDialog.borderPavement"))); RandomMapPanelBasic.makeCompactGrid(panel, 2, 4, 6, 6, 6, 6); return panel; @@ -654,7 +652,7 @@ private JPanel setupFortifiedPanel() { panel.add(fortifiedSizeMaxField); panel.setBorder(new TitledBorder(new LineBorder(Color.black, 2), - Messages.getString("RandomMapDialog.borderFortified"))); + Messages.getString("RandomMapDialog.borderFortified"))); RandomMapPanelBasic.makeCompactGrid(panel, 2, 4, 6, 6, 6, 6); return panel; @@ -718,7 +716,7 @@ private JPanel setupCityPanel() { panel.add(new JLabel()); panel.setBorder(new TitledBorder(new LineBorder(Color.black, 1), - Messages.getString("RandomMapDialog.borderCity"))); + Messages.getString("RandomMapDialog.borderCity"))); RandomMapPanelBasic.makeCompactGrid(panel, 6, 4, 6, 6, 6, 6); setCityPanelState(); @@ -747,17 +745,17 @@ private JScrollPane setupEffectsPanel() { panel.add(droughtLabel); droughtChanceField.setToolTipText(Messages.getString("RandomMapDialog.droughtChanceField.toolTip")); panel.add(droughtChanceField); - + JLabel fireLabel = new JLabel(Messages.getString("RandomMapDialog.labProbFire")); panel.add(fireLabel); fireChanceField.setToolTipText(Messages.getString("RandomMapDialog.fireChanceField.toolTip")); panel.add(fireChanceField); - + JLabel floodLabel = new JLabel(Messages.getString("RandomMapDialog.labProbFlood")); panel.add(floodLabel); floodChanceField.setToolTipText(Messages.getString("RandomMapDialog.floodChanceField.toolTip")); panel.add(floodChanceField); - + JLabel fxLabel = new JLabel(Messages.getString("RandomMapDialog.labFxMod")); panel.add(fxLabel); specialFxField.setToolTipText(Messages.getString("RandomMapDialog.specialFxField.toolTip")); @@ -785,7 +783,7 @@ private JScrollPane setupNaturalFeaturesPanel() { private JPanel setupWoodsPanel() { JPanel panel = new FeaturePanel(new SpringLayout()); - + JLabel numberWoodsLabel = new JLabel(Messages.getString("RandomMapDialog.labForestSpots")); panel.add(numberWoodsLabel); woodsMinField.setToolTipText(Messages.getString("RandomMapDialog.woodsMinField.toolTip")); @@ -819,7 +817,7 @@ private JPanel setupWoodsPanel() { panel.add(new JLabel()); panel.setBorder(new TitledBorder(new LineBorder(Color.black, 1), - Messages.getString("RandomMapDialog.borderWoods"))); + Messages.getString("RandomMapDialog.borderWoods"))); RandomMapPanelBasic.makeCompactGrid(panel, 4, 4, 6, 6, 6, 6); return panel; } @@ -864,26 +862,26 @@ private JPanel setupJunglePanel() { RandomMapPanelBasic.makeCompactGrid(panel, 4, 4, 6, 6, 6, 6); return panel; } - + private class FeaturePanel extends JPanel { private static final long serialVersionUID = 2064014325837995657L; public FeaturePanel(LayoutManager layout) { super(layout); } - + @Override public Dimension getMaximumSize() { // Make this Panel not stretch vertically Dimension size = getPreferredSize(); Dimension maxSize = super.getMaximumSize(); return new Dimension(maxSize.width, size.height); - } + } } - + private JPanel setupFoliagePanel() { JPanel panel = new FeaturePanel(new SpringLayout()); - + JLabel numberWoodsLabel = new JLabel(Messages.getString("RandomMapDialog.labFoliageSpots")); panel.add(numberWoodsLabel); foliageMinField.setToolTipText(Messages.getString("RandomMapDialog.foliageMinField.toolTip")); @@ -908,7 +906,7 @@ private JPanel setupFoliagePanel() { panel.add(new JLabel()); panel.setBorder(new TitledBorder(new LineBorder(Color.black, 1), - Messages.getString("RandomMapDialog.borderFoliage"))); + Messages.getString("RandomMapDialog.borderFoliage"))); RandomMapPanelBasic.makeCompactGrid(panel, 3, 4, 6, 6, 6, 6); return panel; @@ -916,7 +914,7 @@ private JPanel setupFoliagePanel() { private JPanel setupSwampsPanel() { JPanel panel = new FeaturePanel(new SpringLayout()); - + JLabel numberSwampsLabel = new JLabel(Messages.getString("RandomMapDialog.labSwampSpots")); panel.add(numberSwampsLabel); swampsMinField.setToolTipText(Messages.getString("RandomMapDialog.swampsMinField.toolTip")); @@ -938,8 +936,8 @@ private JPanel setupSwampsPanel() { panel.add(swampsMaxSizeField); panel.setBorder(new TitledBorder(new LineBorder(Color.black, 1), - Messages.getString("RandomMapDialog.borderSwamp"))); - + Messages.getString("RandomMapDialog.borderSwamp"))); + RandomMapPanelBasic.makeCompactGrid(panel, 2, 4, 6, 6, 6, 6); return panel; } @@ -966,7 +964,7 @@ private JPanel setupSandsPanel() { panel.add(sandsSizeMaxField); panel.setBorder(new TitledBorder(new LineBorder(Color.black, 1), - Messages.getString("RandomMapDialog.borderSand"))); + Messages.getString("RandomMapDialog.borderSand"))); RandomMapPanelBasic.makeCompactGrid(panel, 2, 4, 6, 6, 6, 6); return panel; @@ -1057,7 +1055,7 @@ private JPanel setupRoughsPanel() { panel.add(new JLabel()); panel.setBorder(new TitledBorder(new LineBorder(Color.black, 1), - Messages.getString("RandomMapDialog.borderRough"))); + Messages.getString("RandomMapDialog.borderRough"))); RandomMapPanelBasic.makeCompactGrid(panel, 3, 4, 6, 6, 6, 6); return panel; @@ -1076,7 +1074,7 @@ private JScrollPane setupElevationPanel() { private JPanel setupCratersPanel() { JPanel panel = new FeaturePanel(new SpringLayout()); - + final JLabel craterChanceLabel = new JLabel(Messages.getString("RandomMapDialog.labProbCrater")); panel.add(craterChanceLabel); craterChanceField.setToolTipText(Messages.getString("RandomMapDialog.craterChanceField.toolTip")); @@ -1105,7 +1103,7 @@ private JPanel setupCratersPanel() { panel.add(craterSizeMaxField); panel.setBorder(new TitledBorder(new LineBorder(Color.black, 1), - Messages.getString("RandomMapDialog.borderCrater"))); + Messages.getString("RandomMapDialog.borderCrater"))); RandomMapPanelBasic.makeCompactGrid(panel, 3, 4, 6, 6, 6, 6); return panel; } @@ -1146,7 +1144,7 @@ private JPanel setupMountainsPanel() { panel.add(mountainWidthMaxField); panel.setBorder(new TitledBorder(new LineBorder(Color.black, 1), - Messages.getString("RandomMapDialog.borderMountain"))); + Messages.getString("RandomMapDialog.borderMountain"))); RandomMapPanelBasic.makeCompactGrid(panel, 4, 4, 6, 6, 6, 6); return panel; @@ -1187,7 +1185,7 @@ private JPanel setupElevationGeneralPanel() { panel.add(invertNegativeCheck); panel.setBorder(new TitledBorder(new LineBorder(Color.black, 1), - Messages.getString("RandomMapDialog.borderGeneral"))); + Messages.getString("RandomMapDialog.borderGeneral"))); RandomMapPanelBasic.makeCompactGrid(panel, 6, 2, 6, 6, 6, 6); return panel; @@ -1261,7 +1259,8 @@ private boolean isFieldVerified(VerifiableTextField field) { return (result == null); } - // Takes in a min and max field, makes sure the data is generally valid in each then compares them to make sure + // Takes in a min and max field, makes sure the data is generally valid in each + // then compares them to make sure // the minimum value does not exceed the maximum. private boolean isMinMaxVerified(VerifiableTextField min, VerifiableTextField max) { if (!isFieldVerified(min) || !isFieldVerified(max)) { @@ -1409,7 +1408,7 @@ private boolean areMapSettingsVerified() { if (!isFieldVerified(jungleUltraChanceField)) { return false; } - + if (!isMinMaxVerified(foliageMinField, foliageMaxField)) { return false; } @@ -1530,10 +1529,12 @@ private boolean areMapSettingsVerified() { } /** - * Returns a {@link MapSettings} object reflecting the values set on this panel after verifying that all the fields - * are valid. If they are not, a NULL will be returned. + * Returns a {@link MapSettings} object reflecting the values set on this panel + * after verifying that all the fields + * are valid. If they are not, a NULL will be returned. * - * @return The new {@link MapSettings} object or NULL if there are any invalid settings on the panel. + * @return The new {@link MapSettings} object or NULL if there are any invalid + * settings on the panel. */ public MapSettings getMapSettings() { if (!areMapSettingsVerified()) { @@ -1546,103 +1547,103 @@ public MapSettings getMapSettings() { // Update the settings with the values from the fields. newMapSettings.setAlgorithmToUse(elevationAlgorithmField.getAsInt()); newMapSettings.setElevationParams(hillinessField.getAsInt(), - elevationRangeField.getAsInt(), - elevationInversionField.getAsInt()); + elevationRangeField.getAsInt(), + elevationInversionField.getAsInt()); newMapSettings.setCliffParam(elevationCliffsField.getAsInt()); // No idea why this is an int instead of a boolean. newMapSettings.setInvertNegativeTerrain(invertNegativeCheck.isSelected() ? 1 : 0); newMapSettings.setMountainParams(elevationPeaksField.getAsInt(), - mountainWidthMinField.getAsInt(), - mountainWidthMaxField.getAsInt(), - mountainHeightMinField.getAsInt(), - mountainHeightMaxField.getAsInt(), - MountainStyle.getMountainStyle((String) mountainStyleCombo.getSelectedItem()) - .getCode()); + mountainWidthMinField.getAsInt(), + mountainWidthMaxField.getAsInt(), + mountainHeightMinField.getAsInt(), + mountainHeightMaxField.getAsInt(), + MountainStyle.getMountainStyle((String) mountainStyleCombo.getSelectedItem()) + .getCode()); newMapSettings.setCraterParam(craterChanceField.getAsInt(), - craterAmountMinField.getAsInt(), - craterAmountMaxField.getAsInt(), - craterSizeMinField.getAsInt(), - craterSizeMaxField.getAsInt()); + craterAmountMinField.getAsInt(), + craterAmountMaxField.getAsInt(), + craterSizeMinField.getAsInt(), + craterSizeMaxField.getAsInt()); newMapSettings.setRoughParams(roughsMinField.getAsInt(), - roughsMaxField.getAsInt(), - roughsMinSizeField.getAsInt(), - roughsMaxSizeField.getAsInt(), - roughsUltraChanceField.getAsInt()); + roughsMaxField.getAsInt(), + roughsMinSizeField.getAsInt(), + roughsMaxSizeField.getAsInt(), + roughsUltraChanceField.getAsInt()); newMapSettings.setSandParams(sandsMinField.getAsInt(), - sandsMaxField.getAsInt(), - sandsSizeMinField.getAsInt(), - sandsSizeMaxField.getAsInt()); + sandsMaxField.getAsInt(), + sandsSizeMinField.getAsInt(), + sandsSizeMaxField.getAsInt()); newMapSettings.setSnowParams(snowMinField.getAsInt(), - snowMaxField.getAsInt(), - snowSizeMinField.getAsInt(), - snowSizeMaxField.getAsInt()); + snowMaxField.getAsInt(), + snowSizeMinField.getAsInt(), + snowSizeMaxField.getAsInt()); newMapSettings.setTundraParams(tundraMinField.getAsInt(), - tundraMaxField.getAsInt(), - tundraSizeMinField.getAsInt(), - tundraSizeMaxField.getAsInt()); + tundraMaxField.getAsInt(), + tundraSizeMinField.getAsInt(), + tundraSizeMaxField.getAsInt()); newMapSettings.setSwampParams(swampsMinField.getAsInt(), - swampsMaxField.getAsInt(), - swampsMinSizeField.getAsInt(), - swampsMaxSizeField.getAsInt()); + swampsMaxField.getAsInt(), + swampsMinSizeField.getAsInt(), + swampsMaxSizeField.getAsInt()); newMapSettings.setForestParams(woodsMinField.getAsInt(), - woodsMaxField.getAsInt(), - woodsMinSizeField.getAsInt(), - woodsMaxSizeField.getAsInt(), - woodsHeavyChanceField.getAsInt(), - woodsUltraChanceField.getAsInt()); + woodsMaxField.getAsInt(), + woodsMinSizeField.getAsInt(), + woodsMaxSizeField.getAsInt(), + woodsHeavyChanceField.getAsInt(), + woodsUltraChanceField.getAsInt()); newMapSettings.setJungleParams(jungleMinField.getAsInt(), - jungleMaxField.getAsInt(), - jungleMinSizeField.getAsInt(), - jungleMaxSizeField.getAsInt(), - jungleHeavyChanceField.getAsInt(), - jungleUltraChanceField.getAsInt()); + jungleMaxField.getAsInt(), + jungleMinSizeField.getAsInt(), + jungleMaxSizeField.getAsInt(), + jungleHeavyChanceField.getAsInt(), + jungleUltraChanceField.getAsInt()); newMapSettings.setFoliageParams(foliageMinField.getAsInt(), - foliageMaxField.getAsInt(), - foliageMinSizeField.getAsInt(), - foliageMaxSizeField.getAsInt(), - foliageHeavyChanceField.getAsInt()); + foliageMaxField.getAsInt(), + foliageMinSizeField.getAsInt(), + foliageMaxSizeField.getAsInt(), + foliageHeavyChanceField.getAsInt()); newMapSettings.setPlantedFieldParams(fieldsMinField.getAsInt(), - fieldsMaxField.getAsInt(), - fieldSizeMinField.getAsInt(), - fieldSizeMaxField.getAsInt()); + fieldsMaxField.getAsInt(), + fieldSizeMinField.getAsInt(), + fieldSizeMaxField.getAsInt()); newMapSettings.setFortifiedParams(fortifiedMinField.getAsInt(), - fortifiedMaxField.getAsInt(), - fortifiedSizeMinField.getAsInt(), - fortifiedSizeMaxField.getAsInt()); + fortifiedMaxField.getAsInt(), + fortifiedSizeMinField.getAsInt(), + fortifiedSizeMaxField.getAsInt()); newMapSettings.setPavementParams(pavementMinField.getAsInt(), - pavementMaxField.getAsInt(), - pavementSizeMinField.getAsInt(), - pavementSizeMaxField.getAsInt()); + pavementMaxField.getAsInt(), + pavementSizeMinField.getAsInt(), + pavementSizeMaxField.getAsInt()); newMapSettings.setRubbleParams(rubbleMinField.getAsInt(), - rubbleMaxField.getAsInt(), - rubbleSizeMinField.getAsInt(), - rubbleSizeMaxField.getAsInt(), - rubbleUltraChanceField.getAsInt()); + rubbleMaxField.getAsInt(), + rubbleSizeMinField.getAsInt(), + rubbleSizeMaxField.getAsInt(), + rubbleUltraChanceField.getAsInt()); newMapSettings.setRoadParam(roadChanceField.getAsInt()); newMapSettings.setCityParams(cityBlocks.getAsInt(), - (String) cityTypeCombo.getSelectedItem(), - cityCFMinField.getAsInt(), - cityCFMaxField.getAsInt(), - cityFloorsMinField.getAsInt(), - cityFloorsMaxField.getAsInt(), - cityDensityField.getAsInt(), - townSizeField.getAsInt()); + (String) cityTypeCombo.getSelectedItem(), + cityCFMinField.getAsInt(), + cityCFMaxField.getAsInt(), + cityFloorsMinField.getAsInt(), + cityFloorsMaxField.getAsInt(), + cityDensityField.getAsInt(), + townSizeField.getAsInt()); newMapSettings.setWaterParams(lakesMinField.getAsInt(), - lakesMaxField.getAsInt(), - lakeSizeMinField.getAsInt(), - lakeSizeMaxField.getAsInt(), - deepChanceField.getAsInt()); + lakesMaxField.getAsInt(), + lakeSizeMinField.getAsInt(), + lakeSizeMaxField.getAsInt(), + deepChanceField.getAsInt()); newMapSettings.setRiverParam(riverChanceField.getAsInt()); newMapSettings.setIceParams(iceMinField.getAsInt(), - iceMaxField.getAsInt(), - iceSizeMinField.getAsInt(), - iceSizeMaxField.getAsInt()); + iceMaxField.getAsInt(), + iceSizeMinField.getAsInt(), + iceSizeMaxField.getAsInt()); newMapSettings.setSpecialFX(specialFxField.getAsInt(), - fireChanceField.getAsInt(), - freezeChanceField.getAsInt(), - floodChanceField.getAsInt(), - droughtChanceField.getAsInt()); + fireChanceField.getAsInt(), + freezeChanceField.getAsInt(), + floodChanceField.getAsInt(), + droughtChanceField.getAsInt()); return newMapSettings; } diff --git a/megamek/src/megamek/client/ui/swing/dialog/MultiIntSelectorDialog.java b/megamek/src/megamek/client/ui/swing/dialog/MultiIntSelectorDialog.java index de87a1fc815..a53e35b0c8d 100644 --- a/megamek/src/megamek/client/ui/swing/dialog/MultiIntSelectorDialog.java +++ b/megamek/src/megamek/client/ui/swing/dialog/MultiIntSelectorDialog.java @@ -37,8 +37,6 @@ import javax.swing.SwingConstants; import javax.swing.border.EmptyBorder; -import org.apache.commons.lang3.ArrayUtils; - import megamek.client.ui.baseComponents.AbstractButtonDialog; import megamek.client.ui.swing.util.UIUtil.FixedYPanel; @@ -48,29 +46,34 @@ public class MultiIntSelectorDialog extends AbstractButtonDialog { private String description; private JList list; - + /** Constructs a modal dialog with frame as parent. */ - public MultiIntSelectorDialog(JFrame frame, String nameResourceID, String titleResourceID, + public MultiIntSelectorDialog(JFrame frame, String nameResourceID, String titleResourceID, String descriptionResourceID, int maxValue, List selectedItems) { super(frame, nameResourceID, titleResourceID); this.setResizable(false); - + description = getString(descriptionResourceID); ListModel listData = new AbstractListModel() { - public int getSize() { return maxValue; } - public Integer getElementAt(int index) { return index; } + public int getSize() { + return maxValue; + } + + public Integer getElementAt(int index) { + return index; + } }; - + list = new JList<>(listData); list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - + int[] selectedItemArray = new int[selectedItems.size()]; for (int x = 0; x < selectedItems.size(); x++) { selectedItemArray[x] = selectedItems.get(x); } - + list.setSelectedIndices(selectedItemArray); - + initialize(); } @@ -82,21 +85,23 @@ protected Container createCenterPane() { JPanel listFieldPanel = new FixedYPanel(); listFieldPanel.add(list); - - JLabel labInfo = new JLabel(scaleStringForGUI("
" + description), + + JLabel labInfo = new JLabel(scaleStringForGUI("
" + description), SwingConstants.CENTER); labInfo.setAlignmentX(CENTER_ALIGNMENT); - + result.add(Box.createVerticalGlue()); result.add(labInfo); result.add(Box.createVerticalStrut(5)); result.add(listFieldPanel); result.add(Box.createVerticalGlue()); - + return result; } - - /** Returns the level change entered by the user or 0, if it cannot be parsed. */ + + /** + * Returns the level change entered by the user or 0, if it cannot be parsed. + */ public List getSelectedItems() { return list.getSelectedValuesList(); } diff --git a/megamek/src/megamek/common/ArtilleryTracker.java b/megamek/src/megamek/common/ArtilleryTracker.java index f13db961b9d..92e211d5cb0 100644 --- a/megamek/src/megamek/common/ArtilleryTracker.java +++ b/megamek/src/megamek/common/ArtilleryTracker.java @@ -15,8 +15,6 @@ */ package megamek.common; -import megamek.common.weapons.Weapon; - import java.io.Serializable; import java.util.HashMap; import java.util.Map; diff --git a/megamek/src/megamek/common/ConvFighter.java b/megamek/src/megamek/common/ConvFighter.java index a316d65c71b..0650ec6cf78 100644 --- a/megamek/src/megamek/common/ConvFighter.java +++ b/megamek/src/megamek/common/ConvFighter.java @@ -14,7 +14,6 @@ import megamek.client.ui.swing.calculationReport.CalculationReport; import megamek.common.cost.ConvFighterCostCalculator; -import megamek.common.options.GameOptions; import megamek.common.options.OptionsConstants; /** @@ -81,9 +80,9 @@ public int getFuelUsed(int thrust) { } protected static final TechAdvancement TA_CONV_FIGHTER = new TechAdvancement(TECH_BASE_ALL) - .setAdvancement(DATE_NONE, 2470, 2490).setProductionFactions(F_TH) - .setTechRating(RATING_D).setAvailability(RATING_C, RATING_D, RATING_C, RATING_B) - .setStaticTechLevel(SimpleTechLevel.STANDARD); + .setAdvancement(DATE_NONE, 2470, 2490).setProductionFactions(F_TH) + .setTechRating(RATING_D).setAvailability(RATING_C, RATING_D, RATING_C, RATING_B) + .setStaticTechLevel(SimpleTechLevel.STANDARD); @Override public TechAdvancement getConstructionTechAdvancement() { @@ -103,7 +102,8 @@ public double getCost(CalculationReport calcReport, boolean ignoreAmmo) { @Override public double getPriceMultiplier() { double priceMultiplier = 1.0; - // omni multiplier (leaving this in for now even though conventional fighters don't make for legal omnis) + // omni multiplier (leaving this in for now even though conventional fighters + // don't make for legal omnis) if (isOmni()) { priceMultiplier *= 1.25f; } @@ -134,6 +134,6 @@ public long getEntityType() { @Override public int getGenericBattleValue() { - return (int) Math.round(Math.exp(2.943 + 0.795*Math.log(getWeight()))); + return (int) Math.round(Math.exp(2.943 + 0.795 * Math.log(getWeight()))); } } diff --git a/megamek/src/megamek/common/FixedWingSupport.java b/megamek/src/megamek/common/FixedWingSupport.java index 3c864c23df9..34252249067 100644 --- a/megamek/src/megamek/common/FixedWingSupport.java +++ b/megamek/src/megamek/common/FixedWingSupport.java @@ -14,7 +14,6 @@ import megamek.client.ui.swing.calculationReport.CalculationReport; import megamek.common.cost.FixedWingSupportCostCalculator; import megamek.common.equipment.ArmorType; -import megamek.common.options.OptionsConstants; /** * @author Jason Tighe diff --git a/megamek/src/megamek/common/GameReports.java b/megamek/src/megamek/common/GameReports.java index 37db07005d1..c39240c4757 100644 --- a/megamek/src/megamek/common/GameReports.java +++ b/megamek/src/megamek/common/GameReports.java @@ -13,8 +13,6 @@ */ package megamek.common; -import org.apache.logging.log4j.LogManager; - import java.util.ArrayList; import java.util.List; import java.util.Vector; @@ -64,14 +62,16 @@ public List get(int round) { } /** - * Returns the full set of reports. Note that the lists are fully modifiable and no copies. + * Returns the full set of reports. Note that the lists are fully modifiable and + * no copies. */ public List> get() { return reports; } /** - * Replaces the entire contents of this FullGameReport with the given List of report lists. + * Replaces the entire contents of this FullGameReport with the given List of + * report lists. * * @param v The new contents */ diff --git a/megamek/src/megamek/common/IGame.java b/megamek/src/megamek/common/IGame.java index d11a2770c53..694e285786e 100644 --- a/megamek/src/megamek/common/IGame.java +++ b/megamek/src/megamek/common/IGame.java @@ -24,7 +24,6 @@ import megamek.common.event.GameListener; import megamek.common.force.Forces; import megamek.common.options.BasicGameOptions; -import megamek.server.scriptedevent.TriggeredActiveEvent; import megamek.server.scriptedevent.TriggeredEvent; import java.util.*; diff --git a/megamek/src/megamek/common/SpecialHexDisplay.java b/megamek/src/megamek/common/SpecialHexDisplay.java index d3be9f2388f..170966e71dd 100644 --- a/megamek/src/megamek/common/SpecialHexDisplay.java +++ b/megamek/src/megamek/common/SpecialHexDisplay.java @@ -18,7 +18,6 @@ import java.io.Serializable; import java.util.Objects; -import megamek.MegaMek; import megamek.client.ui.swing.GUIPreferences; import megamek.common.enums.GamePhase; import megamek.common.util.ImageUtil; @@ -244,7 +243,8 @@ public int getObscuredLevel() { } /** - * Determines whether this special hex should be obscured from the given Player. + * Determines whether this special hex should be obscured from the given + * Player. * * @param other * @return @@ -268,8 +268,11 @@ public void setObscured(int obscured) { /** * Determine whether the current SpecialHexDisplay should be displayed - * Note Artillery Hits and Bomb Hits (direct hits on their targets) will always display - * in the appropriate phase. Other bomb- or artillery-related graphics are optional. + * Note Artillery Hits and Bomb Hits (direct hits on their targets) will always + * display + * in the appropriate phase. Other bomb- or artillery-related graphics are + * optional. + * * @param phase * @param curRound * @param playerChecking @@ -289,7 +292,7 @@ public boolean drawNow(GamePhase phase, int curRound, Player playerChecking, GUI } // Arty icons for the owner are drawn in BoardView1.drawArtillery - // and shouldn't be drawn twice + // and shouldn't be drawn twice if (isOwner(playerChecking) && (type == Type.ARTILLERY_AUTOHIT || type == Type.ARTILLERY_ADJUSTED @@ -304,10 +307,12 @@ public boolean drawNow(GamePhase phase, int curRound, Player playerChecking, GUI } // Hide icons the player doesn't want to see - // Check user settings and Hide some "hits" because they are actually drifts that did damage + // Check user settings and Hide some "hits" because they are actually drifts + // that did damage if (guiPref != null) { switch (type) { - case ARTILLERY_HIT -> shouldDisplay &= !this.info.contains(Messages.getString("ArtilleryMessage.drifted")); + case ARTILLERY_HIT -> + shouldDisplay &= !this.info.contains(Messages.getString("ArtilleryMessage.drifted")); case ARTILLERY_MISS -> shouldDisplay &= guiPref.getBoolean(GUIPreferences.SHOW_ARTILLERY_MISSES); case ARTILLERY_DRIFT -> shouldDisplay &= guiPref.getBoolean(GUIPreferences.SHOW_ARTILLERY_DRIFTS); case BOMB_MISS -> shouldDisplay &= guiPref.getBoolean(GUIPreferences.SHOW_BOMB_MISSES); diff --git a/megamek/src/megamek/common/actions/AbstractEntityAction.java b/megamek/src/megamek/common/actions/AbstractEntityAction.java index e40ef0001d9..f8ec0593f6e 100644 --- a/megamek/src/megamek/common/actions/AbstractEntityAction.java +++ b/megamek/src/megamek/common/actions/AbstractEntityAction.java @@ -19,8 +19,6 @@ */ package megamek.common.actions; -import megamek.common.Game; - import java.io.Serializable; /** @@ -44,4 +42,4 @@ public int getEntityId() { public String toString() { return "[" + getClass().getSimpleName() + "]: Unit ID " + entityId; } -} \ No newline at end of file +} diff --git a/megamek/src/megamek/common/actions/TeleMissileAttackAction.java b/megamek/src/megamek/common/actions/TeleMissileAttackAction.java index 857459571be..f3b15000737 100644 --- a/megamek/src/megamek/common/actions/TeleMissileAttackAction.java +++ b/megamek/src/megamek/common/actions/TeleMissileAttackAction.java @@ -20,7 +20,6 @@ package megamek.common.actions; import java.util.ArrayList; -import java.util.Collections; import java.util.Enumeration; import java.util.List; @@ -42,7 +41,8 @@ public class TeleMissileAttackAction extends AbstractAttackAction { // Large Craft Point Defense/AMS Bay Stuff public int CounterAVInt = 0; - private boolean pdOverheated = false; // true if counterfire + offensive weapon attacks made this round cause the defending unit to overheat. Used for reporting. + private boolean pdOverheated = false; // true if counterfire + offensive weapon attacks made this round cause the + // defending unit to overheat. Used for reporting. private boolean advancedPD = false; // true if advanced StratOps game rule is on public TeleMissileAttackAction(Entity attacker, Targetable target) { @@ -83,8 +83,10 @@ public void addCounterEquipment(WeaponMounted m) { } /** - * Checks to see if the basic conditions needed for point defenses to work are in place - * Since this normally only applies to weaponhandlers, we must recreate it to deal with telemissile + * Checks to see if the basic conditions needed for point defenses to work are + * in place + * Since this normally only applies to weaponhandlers, we must recreate it to + * deal with telemissile * entities */ private boolean checkPDConditions(Game game, Targetable target) { @@ -98,11 +100,14 @@ private boolean checkPDConditions(Game game, Targetable target) { } /** - * Returns the heat generated by a large craft's weapons fire declarations during the round + * Returns the heat generated by a large craft's weapons fire declarations + * during the round * Used to determine whether point defenses can engage. + * * @param e the entity you wish to get heat data from - * Since this normally only applies to weaponhandlers, we must recreate it to deal with telemissile - * entities + * Since this normally only applies to weaponhandlers, we must recreate + * it to deal with telemissile + * entities */ protected int getLargeCraftHeat(Entity e) { int totalheat = 0; @@ -134,14 +139,16 @@ protected int getLargeCraftHeat(Entity e) { /** * Checks to see if this point defense/AMS bay can engage a capital missile - * This should return true. Only when handling capital missile attacks can this be false. + * This should return true. Only when handling capital missile attacks can this + * be false. */ protected boolean canEngageCapitalMissile(WeaponMounted counter) { return counter.getBayWeapons().size() >= 2; } /** - * Calculates the attack value of point defense weapons used against a missile bay attack + * Calculates the attack value of point defense weapons used against a missile + * bay attack * This is the main large craft point defense method */ public int calcCounterAV(Game game, Targetable target) { @@ -154,25 +161,28 @@ public int calcCounterAV(Game game, Targetable target) { Entity entityTarget = (Entity) target; // any AMS bay attacks by the target? List lCounters = getCounterEquipment(); - // We need to know how much heat has been assigned to offensive weapons fire by the defender this round + // We need to know how much heat has been assigned to offensive weapons fire by + // the defender this round int weaponHeat = getLargeCraftHeat(entityTarget) + entityTarget.heatBuildup; if (null != lCounters) { for (WeaponMounted counter : lCounters) { // Point defenses only fire vs attacks against the arc they protect Entity pdEnt = counter.getEntity(); - // We already checked arc when AMS was assigned. No need to worry about fleet missile defense here: + // We already checked arc when AMS was assigned. No need to worry about fleet + // missile defense here: // Telemissiles are entities. Other craft can just shoot at them. // Point defenses can't fire if they're not ready for any other reason if (counter.getType() == null - || !counter.isReady() || counter.isMissing() - // shutdown means no Point defenses - || pdEnt.isShutDown()) { - continue; + || !counter.isReady() || counter.isMissing() + // shutdown means no Point defenses + || pdEnt.isShutDown()) { + continue; } - // Point defense/AMS bays with less than 2 weapons cannot engage capital missiles + // Point defense/AMS bays with less than 2 weapons cannot engage capital + // missiles if (!canEngageCapitalMissile(counter)) { continue; } @@ -224,7 +234,7 @@ public int calcCounterAV(Game game, Targetable target) { } // decrement the ammo bayWAmmo.setShotsLeft(Math.max(0, - bayWAmmo.getBaseShotsLeft() - 1)); + bayWAmmo.getBaseShotsLeft() - 1)); } if (isAMSBay) { // get the attack value @@ -276,7 +286,8 @@ public ToHitData toHit(Game game, Targetable target) { || ((((Entity) target).getOwner().getTeam() != Player.TEAM_NONE) && (ae.getOwner().getTeam() != Player.TEAM_NONE) && (ae.getOwner().getTeam() == ((Entity) target).getOwner().getTeam())))) { - return new ToHitData(TargetRoll.IMPOSSIBLE, "A friendly unit can never be the target of a direct attack."); + return new ToHitData(TargetRoll.IMPOSSIBLE, + "A friendly unit can never be the target of a direct attack."); } } diff --git a/megamek/src/megamek/common/alphaStrike/cardDrawer/ASAeroCard.java b/megamek/src/megamek/common/alphaStrike/cardDrawer/ASAeroCard.java index 093a41e2870..aea841336bb 100644 --- a/megamek/src/megamek/common/alphaStrike/cardDrawer/ASAeroCard.java +++ b/megamek/src/megamek/common/alphaStrike/cardDrawer/ASAeroCard.java @@ -27,8 +27,6 @@ import java.awt.geom.Arc2D; import java.awt.geom.Path2D; -import static java.awt.Color.WHITE; - public class ASAeroCard extends ASHeatTrackingCard { public ASAeroCard(ASCardDisplayable element) { @@ -50,13 +48,15 @@ protected void paintBaseInfo(Graphics2D g) { int lowerY = 170 + baseInfoBoxHeight / 2 + 20; new StringDrawer("TP: ").at(44, upperY).centerY().maxWidth(55).font(headerFont).draw(g); - new StringDrawer(element.getASUnitType().toString()).at(107, upperY).useConfig(valueConfig).maxWidth(64).draw(g); + new StringDrawer(element.getASUnitType().toString()).at(107, upperY).useConfig(valueConfig).maxWidth(64) + .draw(g); new StringDrawer("SZ: ").at(182, upperY).centerY().font(headerFont).maxWidth(56).draw(g); new StringDrawer(element.getSize() + "").at(244, upperY).useConfig(valueConfig).maxWidth(33).draw(g); new StringDrawer("THR: ").at(281, upperY).centerY().font(headerFont).maxWidth(94).draw(g); - new StringDrawer(AlphaStrikeHelper.getMovementAsString(element)).at(380, upperY).useConfig(valueConfig).maxWidth(44).draw(g); + new StringDrawer(AlphaStrikeHelper.getMovementAsString(element)).at(380, upperY).useConfig(valueConfig) + .maxWidth(44).draw(g); new StringDrawer("ROLE: ").at(44, lowerY).centerY().font(headerFont).maxWidth(85).draw(g); new StringDrawer(element.getRole().toString()).at(138, lowerY).useConfig(valueConfig).maxWidth(250).draw(g); @@ -116,7 +116,8 @@ protected void paintArmor(Graphics2D g) { if (element != null) { int lowerY = armorBoxY + armorBoxHeight / 2 + 18; - new StringDrawer(element.getThreshold() + "").at(606, lowerY).useConfig(valueConfig).center().maxWidth(52).draw(g); + new StringDrawer(element.getThreshold() + "").at(606, lowerY).useConfig(valueConfig).center().maxWidth(52) + .draw(g); } } @@ -138,9 +139,13 @@ protected void paintDamage(Graphics2D g) { new StringDrawer("L (+4)").at(posS + 2 * delta, upperY).center().maxWidth(110).draw(g); new StringDrawer("E (+6)").at(posS + 3 * delta, upperY).center().maxWidth(110).draw(g); g.setFont(valueFont); - new StringDrawer(damage.S.toStringWithZero()).at(posS, lowerY).useConfig(valueConfig).center().maxWidth(110).draw(g); - new StringDrawer(damage.M.toStringWithZero()).at(posS + delta, lowerY).useConfig(valueConfig).center().maxWidth(110).draw(g); - new StringDrawer(damage.L.toStringWithZero()).at(posS + 2 * delta, lowerY).useConfig(valueConfig).center().maxWidth(110).draw(g); - new StringDrawer(damage.E.toStringWithZero()).at(posS + 3 * delta, lowerY).useConfig(valueConfig).center().maxWidth(110).draw(g); + new StringDrawer(damage.S.toStringWithZero()).at(posS, lowerY).useConfig(valueConfig).center().maxWidth(110) + .draw(g); + new StringDrawer(damage.M.toStringWithZero()).at(posS + delta, lowerY).useConfig(valueConfig).center() + .maxWidth(110).draw(g); + new StringDrawer(damage.L.toStringWithZero()).at(posS + 2 * delta, lowerY).useConfig(valueConfig).center() + .maxWidth(110).draw(g); + new StringDrawer(damage.E.toStringWithZero()).at(posS + 3 * delta, lowerY).useConfig(valueConfig).center() + .maxWidth(110).draw(g); } } diff --git a/megamek/src/megamek/common/alphaStrike/cardDrawer/ASProtoMekCard.java b/megamek/src/megamek/common/alphaStrike/cardDrawer/ASProtoMekCard.java index 88bc5346ca1..3b27d5c4bd0 100644 --- a/megamek/src/megamek/common/alphaStrike/cardDrawer/ASProtoMekCard.java +++ b/megamek/src/megamek/common/alphaStrike/cardDrawer/ASProtoMekCard.java @@ -20,7 +20,6 @@ import megamek.client.ui.swing.util.StringDrawer; import megamek.common.alphaStrike.ASCardDisplayable; -import megamek.common.alphaStrike.AlphaStrikeElement; import java.awt.*; diff --git a/megamek/src/megamek/common/commandline/ClientServerCommandLineParser.java b/megamek/src/megamek/common/commandline/ClientServerCommandLineParser.java index 03b36148982..2c59f5884a8 100644 --- a/megamek/src/megamek/common/commandline/ClientServerCommandLineParser.java +++ b/megamek/src/megamek/common/commandline/ClientServerCommandLineParser.java @@ -21,7 +21,6 @@ import org.apache.logging.log4j.LogManager; import java.io.File; -import java.net.URI; public class ClientServerCommandLineParser extends AbstractCommandLineParser { @@ -89,6 +88,7 @@ public String getServerAddress() { public boolean getUseDefaults() { return useDefaults; } + /** * @return the game file name option value or null if it wasn't set */ @@ -252,7 +252,7 @@ private void processDataDir() throws ParseException { } public Resolver getResolver(String defaultPassword, int defaultPort, - String defaultServerAddress, String defaultPlayerName) { + String defaultServerAddress, String defaultPlayerName) { return new Resolver(this, defaultPassword, defaultPort, defaultServerAddress, defaultPlayerName); } @@ -263,8 +263,7 @@ public class Resolver { protected final String saveGameFileName; public Resolver(ClientServerCommandLineParser parser, String defaultPassword, int defaultPort, - String defaultServerAddress, String defaultPlayerName) - { + String defaultServerAddress, String defaultPlayerName) { try { parser.parse(); } catch (AbstractCommandLineParser.ParseException e) { @@ -330,6 +329,7 @@ public Resolver(ClientServerCommandLineParser parser, String defaultPassword, in * path resolves the saveGameFileName arg if it was provided. * If it is an absolute path, uses that, otherwise looks first in * current working directory and then in ./savegame/ + * * @return File object if valid file, null if not */ public File getSaveGameFile() { @@ -344,16 +344,16 @@ public File getSaveGameFile() { LogManager.getLogger().error("Unable to read savegame file: " + gameFile.getAbsolutePath()); return null; } else { - String searched = '"'+ gameFile.getAbsolutePath()+'"'; + String searched = '"' + gameFile.getAbsolutePath() + '"'; gameFile = new File("./savegames", saveGameFileName); if (gameFile.canRead()) { return gameFile; } else { - searched += " or \"" + gameFile.getAbsolutePath()+'"'; + searched += " or \"" + gameFile.getAbsolutePath() + '"'; LogManager.getLogger().error("Unable to read savegame file at " + searched); return null; } } } } -} \ No newline at end of file +} diff --git a/megamek/src/megamek/common/jacksonadapters/SBFUnitDeserializer.java b/megamek/src/megamek/common/jacksonadapters/SBFUnitDeserializer.java index 2c491ef7e24..b0e7892b922 100644 --- a/megamek/src/megamek/common/jacksonadapters/SBFUnitDeserializer.java +++ b/megamek/src/megamek/common/jacksonadapters/SBFUnitDeserializer.java @@ -23,7 +23,6 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.deser.std.StdDeserializer; import megamek.client.ui.swing.calculationReport.DummyCalculationReport; -import megamek.common.BTObject; import megamek.common.alphaStrike.ASDamageVector; import megamek.common.alphaStrike.AlphaStrikeElement; import megamek.common.alphaStrike.BattleForceSUA; @@ -37,9 +36,12 @@ import static megamek.common.jacksonadapters.SBFUnitSerializer.*; /** - * This Jackson deserializer reads an SBF Unit (part of a formation) from an MMU file. When the MMU file - * lists the elements, these will be taken and converted to the SBFUnit (and any transients like damage - * applied). When the MMU file doesnt list the elements, it must have the stats; then the SBFUnit will + * This Jackson deserializer reads an SBF Unit (part of a formation) from an MMU + * file. When the MMU file + * lists the elements, these will be taken and converted to the SBFUnit (and any + * transients like damage + * applied). When the MMU file doesnt list the elements, it must have the stats; + * then the SBFUnit will * be constructed without the elements. */ public class SBFUnitDeserializer extends StdDeserializer { @@ -70,15 +72,15 @@ public SBFUnit deserialize(JsonParser jp, DeserializationContext ctxt) throws IO unit.setName(node.get(GENERAL_NAME).textValue()); unit.setSkill(node.has(SKILL) ? node.get("skill").intValue() : 4); -// if (node.has(FORCE)) { -// unit.setForceString(node.get(FORCE).textValue()); -// } + // if (node.has(FORCE)) { + // unit.setForceString(node.get(FORCE).textValue()); + // } if (node.has(ELEMENTS)) { // When the elements are given, read them and convert List elementsO = new MMUReader().read(node.get(ELEMENTS)); if (elementsO.stream().anyMatch(o -> !(o instanceof AlphaStrikeElement))) { - //ERROR - how? + // ERROR - how? throw new IllegalArgumentException("SBFUnits may only contain Alpha Strike Elements!"); } List elements = new ArrayList<>(); @@ -86,7 +88,7 @@ public SBFUnit deserialize(JsonParser jp, DeserializationContext ctxt) throws IO .map(o -> (AlphaStrikeElement) o) .forEach(elements::add); - //TODO: elements without skill? + // TODO: elements without skill? unit = new SBFUnitConverter(elements, node.get(GENERAL_NAME).textValue(), elements, new DummyCalculationReport()).createSbfUnit(); } else { @@ -152,4 +154,4 @@ private void parseStatus(SBFUnit unit, String statusString) { throw new IllegalArgumentException("Unknown status " + statusString); } } -} \ No newline at end of file +} diff --git a/megamek/src/megamek/common/net/packets/Packet.java b/megamek/src/megamek/common/net/packets/Packet.java index ae01bb416de..4662d76f5c5 100644 --- a/megamek/src/megamek/common/net/packets/Packet.java +++ b/megamek/src/megamek/common/net/packets/Packet.java @@ -19,10 +19,9 @@ import java.io.Serializable; import java.util.Arrays; -import static org.apache.commons.text.WordUtils.abbreviate; - /** - * Application layer data packet used to exchange information between client and server. + * Application layer data packet used to exchange information between client and + * server. */ public class Packet implements Serializable { private PacketCommand command; @@ -88,4 +87,4 @@ public boolean getBooleanValue(int index) { public String toString() { return "Packet [" + command + "] - " + Arrays.toString(data); } -} \ No newline at end of file +} diff --git a/megamek/src/megamek/common/planetaryconditions/IlluminationLevel.java b/megamek/src/megamek/common/planetaryconditions/IlluminationLevel.java index 725cde7f7ab..17176cf3263 100644 --- a/megamek/src/megamek/common/planetaryconditions/IlluminationLevel.java +++ b/megamek/src/megamek/common/planetaryconditions/IlluminationLevel.java @@ -18,7 +18,6 @@ */ package megamek.common.planetaryconditions; -import megamek.client.ui.swing.GUIPreferences; import megamek.common.Coords; import megamek.common.Game; import megamek.common.Hex; @@ -26,15 +25,13 @@ import java.util.Objects; -import static megamek.client.ui.swing.util.UIUtil.*; - public enum IlluminationLevel { - //region Enum Declarations + // region Enum Declarations NONE(""), FIRE("\uD83D\uDD25"), FLARE("\uD83C\uDF86"), SEARCHLIGHT("\uD83D\uDD26"); - //endregion Enum Declarations + // endregion Enum Declarations private final String indicator; @@ -42,7 +39,7 @@ public enum IlluminationLevel { this.indicator = indicator; } - //region Boolean Comparison Methods + // region Boolean Comparison Methods public boolean isNone() { return this == NONE; } @@ -58,18 +55,22 @@ public boolean isFlare() { public boolean isSearchlight() { return this == SEARCHLIGHT; } - //endregion Boolean Comparison Methods + // endregion Boolean Comparison Methods public String getIndicator() { return indicator; } /** - * @return the level of illumination for a given coords. Different light sources affect how much - * the nighttime penalties are reduced. - * Note: this method should be used for determining if a Coords/Hex is illuminated, not - * Game::getIlluminatedPositions, as that just returns the hexes that are effected by - * searchlights, whereas this one considers searchlights as well as other light sources. + * @return the level of illumination for a given coords. Different light sources + * affect how much + * the nighttime penalties are reduced. + * Note: this method should be used for determining if a Coords/Hex is + * illuminated, not + * Game::getIlluminatedPositions, as that just returns the hexes that + * are effected by + * searchlights, whereas this one considers searchlights as well as + * other light sources. */ public static IlluminationLevel determineIlluminationLevel(final Game game, final Coords coords) { // fix for NPE when recovering spacecraft while in visual range of enemy diff --git a/megamek/src/megamek/common/strategicBattleSystems/SBFReportEntry.java b/megamek/src/megamek/common/strategicBattleSystems/SBFReportEntry.java index 8abff1c771c..62528013534 100644 --- a/megamek/src/megamek/common/strategicBattleSystems/SBFReportEntry.java +++ b/megamek/src/megamek/common/strategicBattleSystems/SBFReportEntry.java @@ -27,7 +27,6 @@ import javax.swing.*; import javax.swing.text.html.HTMLEditorKit; import javax.swing.text.html.StyleSheet; -import java.awt.*; import java.io.Serializable; import java.util.ArrayList; import java.util.List; @@ -36,7 +35,8 @@ public class SBFReportEntry implements ReportEntry { - record DataEntry(String data, boolean isObscured) implements Serializable { } + record DataEntry(String data, boolean isObscured) implements Serializable { + } protected static final String CSS_HEADER = "header"; @@ -72,25 +72,32 @@ public static void setupStylesheet(StyleSheet styleSheet) { styleSheet.addRule("span.info { color: " + hexColor(GUIP.getReportInfoColor()) + " }"); } -// public static String styles() { -// float base = UIUtil.scaleForGUI(UIUtil.FONT_SCALE1); -// int labelSize = (int) (0.8 * base); -// int valueSize = (int) (1.1 * base); -// int nameSize = (int) (1.3 * base); -// -// return ".value { font-family:Exo; font-size:20; }" + -// ".label { font-family:Noto Sans; font-size:" + labelSize + "; color:gray; }" + -// ".idnum { font-family:Exo; font-size:" + labelSize + "; color:gray; text-align:right; }" + -// ".valuecell { padding-right:10; font-family:Exo; font-size:" + valueSize + "; text-align: center; }" + -// ".armornodmg { font-family:Exo; font-size:" + valueSize + "; text-align: center; }" + -// ".valuedmg { font-family:Exo; font-size:" + valueSize + "; text-align: center; color: #FAA; }" + -// ".valuedeemph { font-family:Exo; font-size:" + labelSize + "; color:gray; }" + -// ".pvcell { font-family:Exo; font-size:" + nameSize + "; text-align: right; }" + -// ".speccell { font-family:Exo; font-size:" + labelSize + "; }" + -// ".fullwidth { width:100%; }" + -// ".formation { font-family:Noto Sans; font-size:" + nameSize + "; }" + -// "th, td { padding:0 2; }"; -// } + // public static String styles() { + // float base = UIUtil.scaleForGUI(UIUtil.FONT_SCALE1); + // int labelSize = (int) (0.8 * base); + // int valueSize = (int) (1.1 * base); + // int nameSize = (int) (1.3 * base); + // + // return ".value { font-family:Exo; font-size:20; }" + + // ".label { font-family:Noto Sans; font-size:" + labelSize + "; color:gray; }" + // + + // ".idnum { font-family:Exo; font-size:" + labelSize + "; color:gray; + // text-align:right; }" + + // ".valuecell { padding-right:10; font-family:Exo; font-size:" + valueSize + "; + // text-align: center; }" + + // ".armornodmg { font-family:Exo; font-size:" + valueSize + "; text-align: + // center; }" + + // ".valuedmg { font-family:Exo; font-size:" + valueSize + "; text-align: + // center; color: #FAA; }" + + // ".valuedeemph { font-family:Exo; font-size:" + labelSize + "; color:gray; }" + // + + // ".pvcell { font-family:Exo; font-size:" + nameSize + "; text-align: right; }" + // + + // ".speccell { font-family:Exo; font-size:" + labelSize + "; }" + + // ".fullwidth { width:100%; }" + + // ".formation { font-family:Noto Sans; font-size:" + nameSize + "; }" + + // "th, td { padding:0 2; }"; + // } /** * Add the given int to the list of data that will be substituted for the @@ -158,7 +165,9 @@ public ReportEntry addRoll(Roll roll) { } /** - * Indent the report. Equivalent to calling {@link #indent(int)} with a parameter of 1. + * Indent the report. Equivalent to calling {@link #indent(int)} with a + * parameter of 1. + * * @return This Report to allow chaining */ public SBFReportEntry indent() { diff --git a/megamek/src/megamek/common/strategicBattleSystems/SBFRollReportEntry.java b/megamek/src/megamek/common/strategicBattleSystems/SBFRollReportEntry.java index 38769f6fec7..792bd1fb238 100644 --- a/megamek/src/megamek/common/strategicBattleSystems/SBFRollReportEntry.java +++ b/megamek/src/megamek/common/strategicBattleSystems/SBFRollReportEntry.java @@ -20,7 +20,6 @@ package megamek.common.strategicBattleSystems; import megamek.client.ui.swing.util.UIUtil; -import megamek.common.InitiativeRoll; import megamek.common.Roll; import java.util.List; @@ -38,7 +37,6 @@ public class SBFRollReportEntry extends SBFReportEntry { private final String rollText; - public SBFRollReportEntry(Roll roll) { super(0); rollText = roll.toString(); diff --git a/megamek/src/megamek/common/strategicBattleSystems/SBFUnitReportEntry.java b/megamek/src/megamek/common/strategicBattleSystems/SBFUnitReportEntry.java index 9025d724f43..a780418b458 100644 --- a/megamek/src/megamek/common/strategicBattleSystems/SBFUnitReportEntry.java +++ b/megamek/src/megamek/common/strategicBattleSystems/SBFUnitReportEntry.java @@ -18,7 +18,6 @@ */ package megamek.common.strategicBattleSystems; -import megamek.client.ui.swing.util.PlayerColour; import megamek.client.ui.swing.util.UIUtil; import java.awt.*; diff --git a/megamek/src/megamek/common/weapons/capitalweapons/AR10Weapon.java b/megamek/src/megamek/common/weapons/capitalweapons/AR10Weapon.java index 84d3e8b0ba7..0cc6c602954 100644 --- a/megamek/src/megamek/common/weapons/capitalweapons/AR10Weapon.java +++ b/megamek/src/megamek/common/weapons/capitalweapons/AR10Weapon.java @@ -14,7 +14,6 @@ import megamek.common.AmmoType; import megamek.common.Mounted; -import megamek.common.alphaStrike.AlphaStrikeElement; /** * @author Jay Lawson diff --git a/megamek/src/megamek/common/weapons/lasers/ISERLaserLarge.java b/megamek/src/megamek/common/weapons/lasers/ISERLaserLarge.java index 0dadd72e94a..6044184109d 100644 --- a/megamek/src/megamek/common/weapons/lasers/ISERLaserLarge.java +++ b/megamek/src/megamek/common/weapons/lasers/ISERLaserLarge.java @@ -13,10 +13,6 @@ */ package megamek.common.weapons.lasers; -import megamek.common.options.GameOptions; -import megamek.common.options.OptionsConstants; -import megamek.server.Server; - /** * @author Andrew Hunter * @since Sep 12, 2004 diff --git a/megamek/src/megamek/server/commands/CheckBVTeamCommand.java b/megamek/src/megamek/server/commands/CheckBVTeamCommand.java index 8dda814bbe7..6eb1cbcf1c3 100644 --- a/megamek/src/megamek/server/commands/CheckBVTeamCommand.java +++ b/megamek/src/megamek/server/commands/CheckBVTeamCommand.java @@ -19,8 +19,6 @@ import megamek.common.options.OptionsConstants; import megamek.server.Server; -import java.util.Enumeration; - public class CheckBVTeamCommand extends ServerCommand { public CheckBVTeamCommand(Server server) { @@ -35,7 +33,7 @@ public void run(int connId, String[] args) { && server.getGame().getOptions().booleanOption(OptionsConstants.ADVANCED_DOUBLE_BLIND); // Connection Ids match player Ids Player requestingPlayer = server.getGame().getPlayer(connId); - + server.sendServerChat(connId, "Remaining BV:"); for (Team team : server.getGame().getTeams()) { int initialTeamBV = 0; diff --git a/megamek/src/megamek/server/sbf/SBFGameManagerHelper.java b/megamek/src/megamek/server/sbf/SBFGameManagerHelper.java index 6b15485ce25..c440f993174 100644 --- a/megamek/src/megamek/server/sbf/SBFGameManagerHelper.java +++ b/megamek/src/megamek/server/sbf/SBFGameManagerHelper.java @@ -18,11 +18,9 @@ */ package megamek.server.sbf; -import megamek.common.ReportEntry; import megamek.common.net.packets.Packet; import megamek.common.strategicBattleSystems.SBFGame; import megamek.common.strategicBattleSystems.SBFReportEntry; -import megamek.common.strategicBattleSystems.SBFReportMessages; import megamek.server.GameManagerPacketHelper; public interface SBFGameManagerHelper { diff --git a/megamek/src/megamek/server/sbf/SBFPhaseEndManager.java b/megamek/src/megamek/server/sbf/SBFPhaseEndManager.java index b1c144f47d8..04e0689fbb5 100644 --- a/megamek/src/megamek/server/sbf/SBFPhaseEndManager.java +++ b/megamek/src/megamek/server/sbf/SBFPhaseEndManager.java @@ -19,7 +19,6 @@ package megamek.server.sbf; import megamek.common.Player; -import megamek.common.Report; import megamek.common.enums.GamePhase; import megamek.common.strategicBattleSystems.SBFReportEntry; @@ -35,13 +34,15 @@ void managePhase() { case STARTING_SCENARIO: gameManager.addPendingReportsToGame(); // IO BF p.103: Arty auto is a thing in SBF -// gameManager.changePhase(GamePhase.SET_ARTILLERY_AUTOHIT_HEXES); - gameManager.changePhase(GamePhase.INITIATIVE); //FIXME <- only for testing to get past arty auto and minefields + // gameManager.changePhase(GamePhase.SET_ARTILLERY_AUTOHIT_HEXES); + gameManager.changePhase(GamePhase.INITIATIVE); // FIXME <- only for testing to get past arty auto and + // minefields break; case SET_ARTILLERY_AUTOHIT_HEXES: -// sendSpecialHexDisplayPackets(); + // sendSpecialHexDisplayPackets(); gameManager.addPendingReportsToGame(); - boolean hasMinesToDeploy = gameManager.getGame().getPlayersList().stream().anyMatch(Player::hasMinefields); + boolean hasMinesToDeploy = gameManager.getGame().getPlayersList().stream() + .anyMatch(Player::hasMinefields); if (hasMinesToDeploy) { gameManager.changePhase(GamePhase.DEPLOY_MINEFIELDS); } else { @@ -56,24 +57,26 @@ void managePhase() { if (gameManager.getGame().getCurrentRound() == 0) { gameManager.changePhase(GamePhase.INITIATIVE); } else { - //FIXME there appears to be no separate artillery targeting phase in SBF + // FIXME there appears to be no separate artillery targeting phase in SBF gameManager.changePhase(GamePhase.TARGETING); } break; case INITIATIVE: -// resolveWhatPlayersCanSeeWhatUnits(); -// detectSpacecraft(); + // resolveWhatPlayersCanSeeWhatUnits(); + // detectSpacecraft(); gameManager.addPendingReportsToGame(); gameManager.changePhase(GamePhase.INITIATIVE_REPORT); break; case INITIATIVE_REPORT: gameManager.getGame().setupDeployment(); if (gameManager.getGame().shouldDeployThisRound()) { - //TODO: could be handled in SBFGame.isCurrentPhasePlayable + // TODO: could be handled in SBFGame.isCurrentPhasePlayable gameManager.changePhase(GamePhase.DEPLOYMENT); } else if (gameManager.usesDoubleBlind()) { - //TODO: Problem: phase "execution" always works with turns. Phases without turns - // are skipped and must do their thing in prep or end. Means they must be skipped here explciitly + // TODO: Problem: phase "execution" always works with turns. Phases without + // turns + // are skipped and must do their thing in prep or end. Means they must be + // skipped here explciitly gameManager.changePhase(GamePhase.SBF_DETECTION); } else { gameManager.changePhase(GamePhase.TARGETING); @@ -87,14 +90,14 @@ void managePhase() { gameManager.changePhase(GamePhase.MOVEMENT); break; case MOVEMENT: -// detectHiddenUnits(); -// ServerHelper.detectMinefields(game, vPhaseReport, this); -// updateSpacecraftDetection(); -// detectSpacecraft(); -// applyBuildingDamage(); -// checkForFlamingDamage(); -// checkForTeleMissileAttacks(); -// resolveCallSupport(); + // detectHiddenUnits(); + // ServerHelper.detectMinefields(game, vPhaseReport, this); + // updateSpacecraftDetection(); + // detectSpacecraft(); + // applyBuildingDamage(); + // checkForFlamingDamage(); + // checkForTeleMissileAttacks(); + // resolveCallSupport(); goToDependingOnReport(GamePhase.MOVEMENT_REPORT, GamePhase.OFFBOARD); break; case MOVEMENT_REPORT: @@ -105,60 +108,62 @@ void managePhase() { break; case FIRING: addReport(new SBFReportEntry(3000)); -// addReport(Report.publicReport(3000)); -// resolveAllButWeaponAttacks(); -// resolveSelfDestructions(); -// reportGhostTargetRolls(); -// reportLargeCraftECCMRolls(); -// resolveOnlyWeaponAttacks(); -// assignAMS(); + // addReport(Report.publicReport(3000)); + // resolveAllButWeaponAttacks(); + // resolveSelfDestructions(); + // reportGhostTargetRolls(); + // reportLargeCraftECCMRolls(); + // resolveOnlyWeaponAttacks(); + // assignAMS(); gameManager.actionsProcessor.handleActions(); -// resolveScheduledNukes(); -// applyBuildingDamage(); -// cleanupDestroyedNarcPods(); + // resolveScheduledNukes(); + // applyBuildingDamage(); + // cleanupDestroyedNarcPods(); goToDependingOnReport(GamePhase.FIRING_REPORT, GamePhase.END); break; case FIRING_REPORT: gameManager.changePhase(GamePhase.END); break; case TARGETING: -// vPhaseReport.addElement(new Report(1035, Report.PUBLIC)); -// resolveAllButWeaponAttacks(); -// resolveOnlyWeaponAttacks(); -// handleAttacks(); + // vPhaseReport.addElement(new Report(1035, Report.PUBLIC)); + // resolveAllButWeaponAttacks(); + // resolveOnlyWeaponAttacks(); + // handleAttacks(); goToDependingOnReport(GamePhase.TARGETING_REPORT, GamePhase.PREMOVEMENT); -// -// sendSpecialHexDisplayPackets(); -// for (Enumeration i = gameManager.getGame().getPlayers(); i.hasMoreElements(); ) { -// Player player = i.nextElement(); -// int connId = player.getId(); -// send(connId, createArtilleryPacket(player)); -// } -// + // + // sendSpecialHexDisplayPackets(); + // for (Enumeration i = gameManager.getGame().getPlayers(); + // i.hasMoreElements(); ) { + // Player player = i.nextElement(); + // int connId = player.getId(); + // send(connId, createArtilleryPacket(player)); + // } + // gameManager.changePhase(GamePhase.PREMOVEMENT); break; case OFFBOARD: -// // write Offboard Attack Phase header -// addReport(new Report(1100, Report.PUBLIC)); -// resolveAllButWeaponAttacks(); // torso twist or flip arms -// // possible -// resolveOnlyWeaponAttacks(); // should only be TAG at this point -// handleAttacks(); -// for (Enumeration i = gameManager.getGame().getPlayers(); i.hasMoreElements(); ) { -// Player player = i.nextElement(); -// int connId = player.getId(); -// send(connId, createArtilleryPacket(player)); -// } -// applyBuildingDamage(); -// checkForPSRFromDamage(); -// addReport(resolvePilotingRolls()); -// -// cleanupDestroyedNarcPods(); -// checkForFlawedCooling(); -// -// sendSpecialHexDisplayPackets(); -// sendTagInfoUpdates(); -// + // // write Offboard Attack Phase header + // addReport(new Report(1100, Report.PUBLIC)); + // resolveAllButWeaponAttacks(); // torso twist or flip arms + // // possible + // resolveOnlyWeaponAttacks(); // should only be TAG at this point + // handleAttacks(); + // for (Enumeration i = gameManager.getGame().getPlayers(); + // i.hasMoreElements(); ) { + // Player player = i.nextElement(); + // int connId = player.getId(); + // send(connId, createArtilleryPacket(player)); + // } + // applyBuildingDamage(); + // checkForPSRFromDamage(); + // addReport(resolvePilotingRolls()); + // + // cleanupDestroyedNarcPods(); + // checkForFlawedCooling(); + // + // sendSpecialHexDisplayPackets(); + // sendTagInfoUpdates(); + // // check reports if (gameManager.getPendingReports().size() > 1) { gameManager.getGame().addReports(gameManager.getPendingReports()); @@ -166,62 +171,63 @@ void managePhase() { } else { // just the header, so we'll add the label gameManager.addReport(new SBFReportEntry(1205)); -// gameManager.addReport(new Report(1205, Report.PUBLIC)); + // gameManager.addReport(new Report(1205, Report.PUBLIC)); gameManager.getGame().addReports(gameManager.getPendingReports()); gameManager.sendReport(); gameManager.changePhase(GamePhase.PREFIRING); } break; case OFFBOARD_REPORT: -// sendSpecialHexDisplayPackets(); + // sendSpecialHexDisplayPackets(); gameManager.changePhase(GamePhase.PREFIRING); break; case TARGETING_REPORT: gameManager.changePhase(GamePhase.PREMOVEMENT); break; case END: -// // remove any entities that died in the heat/end phase before -// // checking for victory -// resetEntityPhase(GamePhase.END); -// boolean victory = victory(); // note this may add reports -// // check phase report -// // HACK: hardcoded message ID check -// if ((vPhaseReport.size() > 3) || ((vPhaseReport.size() > 1) -// && (vPhaseReport.elementAt(1).messageId != 1205))) { -// gameManager.getGame().addReports(vPhaseReport); -// gameManager.changePhase(GamePhase.END_REPORT); -// } else { -// // just the heat and end headers, so we'll add -// // the label -// addReport(new Report(1205, Report.PUBLIC)); -// gameManager.getGame().addReports(vPhaseReport); -// sendReport(); -// if (victory) { -// gameManager.changePhase(GamePhase.VICTORY); -// } else { - //TODO: remove this and test that after firing, no more selection in firingdisplay, no more firing + // // remove any entities that died in the heat/end phase before + // // checking for victory + // resetEntityPhase(GamePhase.END); + // boolean victory = victory(); // note this may add reports + // // check phase report + // // HACK: hardcoded message ID check + // if ((vPhaseReport.size() > 3) || ((vPhaseReport.size() > 1) + // && (vPhaseReport.elementAt(1).messageId != 1205))) { + // gameManager.getGame().addReports(vPhaseReport); + // gameManager.changePhase(GamePhase.END_REPORT); + // } else { + // // just the heat and end headers, so we'll add + // // the label + // addReport(new Report(1205, Report.PUBLIC)); + // gameManager.getGame().addReports(vPhaseReport); + // sendReport(); + // if (victory) { + // gameManager.changePhase(GamePhase.VICTORY); + // } else { + // TODO: remove this and test that after firing, no more selection in + // firingdisplay, no more firing gameManager.changePhase(GamePhase.INITIATIVE); -// } -// } -// // Decrement the ASEWAffected counter -// decrementASEWTurns(); + // } + // } + // // Decrement the ASEWAffected counter + // decrementASEWTurns(); break; case END_REPORT: -// if (changePlayersTeam) { -// processTeamChangeRequest(); -// } -// if (victory()) { -// gameManager.changePhase(GamePhase.VICTORY); -// } else { -// gameManager.changePhase(GamePhase.INITIATIVE); -// } + // if (changePlayersTeam) { + // processTeamChangeRequest(); + // } + // if (victory()) { + // gameManager.changePhase(GamePhase.VICTORY); + // } else { + // gameManager.changePhase(GamePhase.INITIATIVE); + // } break; case VICTORY: -// GameVictoryEvent gve = new GameVictoryEvent(this, game); -// gameManager.getGame().processGameEvent(gve); -// transmitGameVictoryEventToAll(); -// resetGame(); + // GameVictoryEvent gve = new GameVictoryEvent(this, game); + // gameManager.getGame().processGameEvent(gve); + // transmitGameVictoryEventToAll(); + // resetGame(); break; default: break; @@ -229,11 +235,11 @@ void managePhase() { // Any hidden units that activated this phase, should clear their // activating phase -// for (Entity ent : gameManager.getGame().getEntitiesVector()) { -// if (ent.getHiddenActivationPhase() == gameManager.getGame().getPhase()) { -// ent.setHiddenActivationPhase(GamePhase.UNKNOWN); -// } -// } + // for (Entity ent : gameManager.getGame().getEntitiesVector()) { + // if (ent.getHiddenActivationPhase() == gameManager.getGame().getPhase()) { + // ent.setHiddenActivationPhase(GamePhase.UNKNOWN); + // } + // } } private void goToDependingOnReport(GamePhase reportPhase, GamePhase afterReportPhase) { @@ -243,7 +249,7 @@ private void goToDependingOnReport(GamePhase reportPhase, GamePhase afterReportP } else { // just the header, so we'll add the label gameManager.addReport(new SBFReportEntry(1205)); -// gameManager.addReport(new Report(1205, Report.PUBLIC)); + // gameManager.addReport(new Report(1205, Report.PUBLIC)); gameManager.getGame().addReports(gameManager.getPendingReports()); gameManager.sendReport(); gameManager.changePhase(afterReportPhase); diff --git a/megamek/unittests/megamek/common/ComputeArtilleryTest.java b/megamek/unittests/megamek/common/ComputeArtilleryTest.java index d93a1de5df1..310cb22fee0 100644 --- a/megamek/unittests/megamek/common/ComputeArtilleryTest.java +++ b/megamek/unittests/megamek/common/ComputeArtilleryTest.java @@ -19,18 +19,10 @@ */ package megamek.common; -import megamek.common.options.GameOptions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestTemplate; - -import java.io.File; -import java.util.ArrayList; -import java.util.Vector; import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -85,6 +77,7 @@ private void setupTarget(Entity target, Coords targetPos, Coords oldTargetPos) { when(target.getPriorPosition()).thenReturn(oldTargetPos); } + @Test public void testComplexCalculateLead() { // Mock the board @@ -115,7 +108,8 @@ public void testComplexCalculateLead() { assertEquals(15, leadPos.getX()); assertEquals(13, leadPos.getY()); - // Mobile target 1 map sheet away to the S (3) direction, speed 4, homing, should be closer to shooter + // Mobile target 1 map sheet away to the S (3) direction, speed 4, homing, + // should be closer to shooter // for better chance to catch mobile unit in TAG-able area setupTarget(target, new Coords(15, 25), new Coords(15, 29)); leadPos = Compute.calculateArtilleryLead(mockGame, shooter, target, true); diff --git a/megamek/unittests/megamek/common/WeaponTypeTest.java b/megamek/unittests/megamek/common/WeaponTypeTest.java index bd03b8419a1..ac7a1e481fe 100644 --- a/megamek/unittests/megamek/common/WeaponTypeTest.java +++ b/megamek/unittests/megamek/common/WeaponTypeTest.java @@ -19,16 +19,10 @@ package megamek.common; import megamek.common.equipment.WeaponMounted; -import megamek.common.weapons.Weapon; -import megamek.common.weapons.bayweapons.BayWeapon; -import megamek.common.weapons.bayweapons.PPCBayWeapon; -import megamek.common.weapons.ppc.ISERPPC; -import megamek.common.weapons.ppc.PPCWeapon; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import java.util.Enumeration; -import java.util.Vector; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.anyInt; @@ -40,32 +34,32 @@ public class WeaponTypeTest { private Entity mockEntity = mock(Entity.class); @BeforeAll - static void before(){ + static void before() { EquipmentType.initializeTypes(); } @Test public void testArtemisCompatibleFlag() { - for (Enumeration e = EquipmentType.getAllTypes(); e.hasMoreElements(); ) { + for (Enumeration e = EquipmentType.getAllTypes(); e.hasMoreElements();) { EquipmentType etype = e.nextElement(); if (etype instanceof WeaponType) { int atype = ((WeaponType) etype).getAmmoType(); assertEquals(etype.hasFlag(WeaponType.F_ARTEMIS_COMPATIBLE), (atype == AmmoType.T_LRM) - || (atype == AmmoType.T_LRM_IMP) - || (atype == AmmoType.T_MML) - || (atype == AmmoType.T_SRM) - || (atype == AmmoType.T_SRM_IMP) - || (atype == AmmoType.T_NLRM) - || (atype == AmmoType.T_LRM_TORPEDO) - || (atype == AmmoType.T_SRM_TORPEDO) - || (atype == AmmoType.T_LRM_TORPEDO_COMBO)); + || (atype == AmmoType.T_LRM_IMP) + || (atype == AmmoType.T_MML) + || (atype == AmmoType.T_SRM) + || (atype == AmmoType.T_SRM_IMP) + || (atype == AmmoType.T_NLRM) + || (atype == AmmoType.T_LRM_TORPEDO) + || (atype == AmmoType.T_SRM_TORPEDO) + || (atype == AmmoType.T_LRM_TORPEDO_COMBO)); } } } - private WeaponMounted setupBayWeapon(String name){ + private WeaponMounted setupBayWeapon(String name) { EquipmentType etype = EquipmentType.get(name); WeaponMounted weapon = new WeaponMounted(mockEntity, (WeaponType) etype); WeaponMounted bWeapon = new WeaponMounted(mockEntity, (WeaponType) weapon.getType().getBayType()); @@ -83,7 +77,7 @@ public void testWeaponBaysGetCorrectMaxRanges() { WeaponMounted erplasbay = setupBayWeapon("CLERLargePulseLaser"); wtype = erplasbay.getType(); - assertEquals(RangeType.RANGE_LONG, wtype.getMaxRange(erplasbay )); + assertEquals(RangeType.RANGE_LONG, wtype.getMaxRange(erplasbay)); WeaponMounted islplasbay = setupBayWeapon("ISLargePulseLaser"); wtype = islplasbay.getType(); @@ -94,7 +88,7 @@ public void testWeaponBaysGetCorrectMaxRanges() { assertEquals(RangeType.RANGE_SHORT, wtype.getMaxRange(ersmlasbay)); WeaponMounted islgaussbay = setupBayWeapon("ISLightGaussRifle"); - wtype = islgaussbay .getType(); - assertEquals(RangeType.RANGE_EXTREME, wtype.getMaxRange(islgaussbay )); + wtype = islgaussbay.getType(); + assertEquals(RangeType.RANGE_EXTREME, wtype.getMaxRange(islgaussbay)); } -} \ No newline at end of file +} diff --git a/megamek/unittests/megamek/common/verifier/TestAeroTest.java b/megamek/unittests/megamek/common/verifier/TestAeroTest.java index e4b4370664c..0fd3588f40f 100644 --- a/megamek/unittests/megamek/common/verifier/TestAeroTest.java +++ b/megamek/unittests/megamek/common/verifier/TestAeroTest.java @@ -1,15 +1,12 @@ package megamek.common.verifier; import megamek.common.AeroSpaceFighter; -import megamek.common.Entity; import megamek.common.EquipmentType; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; class TestAeroTest { @@ -33,7 +30,8 @@ void testCalculateEngineRatingForAeroSpaceFighter() { rating = TestAero.calculateEngineRating(aero, 25, 2); assertEquals(0, rating); - // 25-ton ASF desiring Safe Thrust of 5 should be 75 (tons * (desiredSafeThrust -2)) + // 25-ton ASF desiring Safe Thrust of 5 should be 75 (tons * (desiredSafeThrust + // -2)) rating = TestAero.calculateEngineRating(aero, 25, 5); assertEquals(75, rating); @@ -45,4 +43,4 @@ void testCalculateEngineRatingForAeroSpaceFighter() { rating = TestAero.calculateEngineRating(aero, 100, 6); assertEquals(400, rating); } -} \ No newline at end of file +}