diff --git a/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java b/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java index ae77658b6b..1db907a069 100644 --- a/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java +++ b/megamek/src/megamek/client/ui/swing/CommonSettingsDialog.java @@ -20,37 +20,7 @@ */ package megamek.client.ui.swing; -import static java.util.stream.Collectors.toList; - -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.*; -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.*; -import java.util.stream.Stream; - -import javax.swing.*; -import javax.swing.UIManager.LookAndFeelInfo; -import javax.swing.border.EmptyBorder; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import javax.swing.event.MouseInputAdapter; - import com.formdev.flatlaf.icons.FlatHelpButtonIcon; - import megamek.MMConstants; import megamek.client.ui.Messages; import megamek.client.ui.baseComponents.AbstractButtonDialog; @@ -70,6 +40,24 @@ import megamek.common.preference.PreferenceManager; import megamek.logging.MMLogger; +import javax.swing.*; +import javax.swing.UIManager.LookAndFeelInfo; +import javax.swing.border.EmptyBorder; +import javax.swing.event.*; +import java.awt.*; +import java.awt.event.*; +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; +import java.util.*; +import java.util.stream.Stream; + +import static java.util.stream.Collectors.toList; + /** * The Client Settings Dialog offering GUI options concerning tooltips, map * display, keybinds etc. @@ -470,7 +458,7 @@ private void moveElement(DefaultListModel srcModel, int srcIndex, int trg private ClientGUI clientgui = null; private static final GUIPreferences GUIP = GUIPreferences.getInstance(); - private static final ClientPreferences CP = PreferenceManager.getClientPreferences(); + private static final ClientPreferences CLIENT_PREFERENCES = PreferenceManager.getClientPreferences(); private static final UnitDisplayOrderPreferences UDOP = UnitDisplayOrderPreferences.getInstance(); private static final ButtonOrderPreferences BOP = ButtonOrderPreferences.getInstance(); @@ -1942,7 +1930,7 @@ public void setVisible(boolean visible) { // Select the correct char set (give a nice default to start). unitStartChar.setSelectedIndex(0); for (int loop = 0; loop < unitStartChar.getItemCount(); loop++) { - if (unitStartChar.getItemAt(loop).charAt(0) == CP.getUnitStartChar()) { + if (unitStartChar.getItemAt(loop).charAt(0) == CLIENT_PREFERENCES.getUnitStartChar()) { unitStartChar.setSelectedIndex(loop); break; } @@ -1956,31 +1944,31 @@ public void setVisible(boolean visible) { tfSoundMuteMyTurnFileName.setText(GUIP.getSoundBingFilenameMyTurn()); tfSoundMuteOthersFileName.setText(GUIP.getSoundBingFilenameOthersTurn()); - maxPathfinderTime.setText(Integer.toString(CP.getMaxPathfinderTime())); + maxPathfinderTime.setText(Integer.toString(CLIENT_PREFERENCES.getMaxPathfinderTime())); - keepGameLog.setSelected(CP.keepGameLog()); + keepGameLog.setSelected(CLIENT_PREFERENCES.keepGameLog()); gameLogFilename.setEnabled(keepGameLog.isSelected()); - gameLogFilename.setText(CP.getGameLogFilename()); - userDir.setText(CP.getUserDir()); - mmlPath.setText(CP.getMmlPath()); - stampFilenames.setSelected(CP.stampFilenames()); + gameLogFilename.setText(CLIENT_PREFERENCES.getGameLogFilename()); + userDir.setText(CLIENT_PREFERENCES.getUserDir()); + mmlPath.setText(CLIENT_PREFERENCES.getMmlPath()); + stampFilenames.setSelected(CLIENT_PREFERENCES.stampFilenames()); stampFormat.setEnabled(stampFilenames.isSelected()); - stampFormat.setText(CP.getStampFormat()); - reportKeywordsTextPane.setText(CP.getReportKeywords()); - showIPAddressesInChat.setSelected(CP.getShowIPAddressesInChat()); - startSearchlightsOn.setSelected(CP.getStartSearchlightsOn()); + stampFormat.setText(CLIENT_PREFERENCES.getStampFormat()); + reportKeywordsTextPane.setText(CLIENT_PREFERENCES.getReportKeywords()); + showIPAddressesInChat.setSelected(CLIENT_PREFERENCES.getShowIPAddressesInChat()); + startSearchlightsOn.setSelected(CLIENT_PREFERENCES.getStartSearchlightsOn()); - defaultAutoejectDisabled.setSelected(CP.defaultAutoejectDisabled()); - useAverageSkills.setSelected(CP.useAverageSkills()); - useGPinUnitSelection.setSelected(CP.useGPinUnitSelection()); - generateNames.setSelected(CP.generateNames()); - showUnitId.setSelected(CP.getShowUnitId()); + defaultAutoejectDisabled.setSelected(CLIENT_PREFERENCES.defaultAutoejectDisabled()); + useAverageSkills.setSelected(CLIENT_PREFERENCES.useAverageSkills()); + useGPinUnitSelection.setSelected(CLIENT_PREFERENCES.useGPinUnitSelection()); + generateNames.setSelected(CLIENT_PREFERENCES.generateNames()); + showUnitId.setSelected(CLIENT_PREFERENCES.getShowUnitId()); int index = 0; - if (CP.getLocaleString().startsWith("de")) { + if (CLIENT_PREFERENCES.getLocaleString().startsWith("de")) { index = 1; } - if (CP.getLocaleString().startsWith("ru")) { + if (CLIENT_PREFERENCES.getLocaleString().startsWith("ru")) { index = 2; } displayLocale.setSelectedIndex(index); @@ -2008,7 +1996,7 @@ public void setVisible(boolean visible) { for (int i = 0; i < tileSets.size(); i++) { String name = tileSets.get(i); tileSetChoice.addItem(name.substring(0, name.length() - 8)); - if (name.equals(CP.getMapTileset())) { + if (name.equals(CLIENT_PREFERENCES.getMapTileset())) { tileSetChoice.setSelectedIndex(i); } } @@ -2413,7 +2401,7 @@ protected void okAction() { logger.error(ex, "okAction"); } GUIP.setValue(GUIPreferences.GUI_SCALE, (float) (guiScale.getValue()) / 10); - CP.setUnitStartChar(((String) unitStartChar.getSelectedItem()).charAt(0)); + CLIENT_PREFERENCES.setUnitStartChar(((String) unitStartChar.getSelectedItem()).charAt(0)); GUIP.setMouseWheelZoom(mouseWheelZoom.isSelected()); GUIP.setMouseWheelZoomFlip(mouseWheelZoomFlip.isSelected()); @@ -2430,33 +2418,33 @@ protected void okAction() { GUIP.setSoundBingFilenameOthersTurn(tfSoundMuteOthersFileName.getText()); try { - CP.setMaxPathfinderTime(Integer.parseInt(maxPathfinderTime.getText())); + CLIENT_PREFERENCES.setMaxPathfinderTime(Integer.parseInt(maxPathfinderTime.getText())); } catch (Exception ex) { logger.error(ex, "okAction"); } GUIP.setGetFocus(getFocus.isSelected()); - CP.setKeepGameLog(keepGameLog.isSelected()); - CP.setGameLogFilename(gameLogFilename.getText()); - CP.setUserDir(userDir.getText()); - CP.setMmlPath(mmlPath.getText()); - CP.setStampFilenames(stampFilenames.isSelected()); - CP.setStampFormat(stampFormat.getText()); - CP.setReportKeywords(reportKeywordsTextPane.getText()); - CP.setShowIPAddressesInChat(showIPAddressesInChat.isSelected()); - CP.setStartSearchlightsOn(startSearchlightsOn.isSelected()); - - CP.setDefaultAutoejectDisabled(defaultAutoejectDisabled.isSelected()); - CP.setUseAverageSkills(useAverageSkills.isSelected()); - CP.setUseGpInUnitSelection(useGPinUnitSelection.isSelected()); - CP.setGenerateNames(generateNames.isSelected()); - CP.setShowUnitId(showUnitId.isSelected()); + CLIENT_PREFERENCES.setKeepGameLog(keepGameLog.isSelected()); + CLIENT_PREFERENCES.setGameLogFilename(gameLogFilename.getText()); + CLIENT_PREFERENCES.setUserDir(userDir.getText()); + CLIENT_PREFERENCES.setMmlPath(mmlPath.getText()); + CLIENT_PREFERENCES.setStampFilenames(stampFilenames.isSelected()); + CLIENT_PREFERENCES.setStampFormat(stampFormat.getText()); + CLIENT_PREFERENCES.setReportKeywords(reportKeywordsTextPane.getText()); + CLIENT_PREFERENCES.setShowIPAddressesInChat(showIPAddressesInChat.isSelected()); + CLIENT_PREFERENCES.setStartSearchlightsOn(startSearchlightsOn.isSelected()); + + CLIENT_PREFERENCES.setDefaultAutoejectDisabled(defaultAutoejectDisabled.isSelected()); + CLIENT_PREFERENCES.setUseAverageSkills(useAverageSkills.isSelected()); + CLIENT_PREFERENCES.setUseGpInUnitSelection(useGPinUnitSelection.isSelected()); + CLIENT_PREFERENCES.setGenerateNames(generateNames.isSelected()); + CLIENT_PREFERENCES.setShowUnitId(showUnitId.isSelected()); if ((clientgui != null) && (clientgui.getBoardView() != null)) { clientgui.getBoardView().updateEntityLabels(); } - CP.setLocale(CommonSettingsDialog.LOCALE_CHOICES[displayLocale.getSelectedIndex()]); + CLIENT_PREFERENCES.setLocale(CommonSettingsDialog.LOCALE_CHOICES[displayLocale.getSelectedIndex()]); GUIP.setShowMapsheets(showMapsheets.isSelected()); GUIP.setAOHexShadows(aOHexShadows.isSelected()); @@ -2493,11 +2481,11 @@ protected void okAction() { if (tileSetChoice.getSelectedIndex() >= 0) { String tileSetFileName = tileSets.get(tileSetChoice.getSelectedIndex()); - if (!CP.getMapTileset().equals(tileSetFileName) && + if (!CLIENT_PREFERENCES.getMapTileset().equals(tileSetFileName) && (clientgui != null) && (clientgui.getBoardView() != null)) { clientgui.getBoardView().clearShadowMap(); } - CP.setMapTileset(tileSetFileName); + CLIENT_PREFERENCES.setMapTileset(tileSetFileName); } ToolTipManager.sharedInstance().setInitialDelay(GUIP.getTooltipDelay()); diff --git a/megamek/src/megamek/client/ui/swing/QuirksPanel.java b/megamek/src/megamek/client/ui/swing/QuirksPanel.java index 24631e94ec..7be4b03d68 100644 --- a/megamek/src/megamek/client/ui/swing/QuirksPanel.java +++ b/megamek/src/megamek/client/ui/swing/QuirksPanel.java @@ -98,7 +98,7 @@ public void refreshQuirks() { IOptionGroup group = i.nextElement(); for (Enumeration j = group.getSortedOptions(); j.hasMoreElements();) { IOption option = j.nextElement(); - if (!WeaponQuirks.isQuirkLegalFor(option, entity, m.getType())) { + if (WeaponQuirks.isQuirkLegalFor(option, entity, m.getType())) { continue; } addWeaponQuirk(key, option, editable); diff --git a/megamek/src/megamek/common/Roll.java b/megamek/src/megamek/common/Roll.java index f7bfb87f76..d321c4d748 100644 --- a/megamek/src/megamek/common/Roll.java +++ b/megamek/src/megamek/common/Roll.java @@ -133,6 +133,17 @@ public boolean isTargetRollSuccess(TargetRoll targetRoll) { return getIntValue() > 2 && getIntValue() >= targetRoll.getValue(); } + /** + * Determines if the roll is a success based on the target number + * A 2 is always a failure + * + * @param targetRoll the target roll to compare against + * @return true if the roll's value is greater than the target roll's value, false otherwise + */ + public boolean isTargetRollSuccess(int targetRoll) { + return getIntValue() > 2 && getIntValue() >= targetRoll; + } + /** * Determines if the roll is a success based on the target roll. * @@ -143,6 +154,17 @@ public boolean isTargetRollSuccessWithoutSimpleFailure(TargetRoll targetRoll) { return getIntValue() >= targetRoll.getValue(); } + /** + * Determines if the roll is a success based on the target number + * A 2 is always a failure + * + * @param targetRoll the target roll to compare against + * @return true if the roll's value is greater than the target roll's value, false otherwise + */ + public boolean isTargetRollSuccessWithoutSimpleFailure(int targetRoll) { + return getIntValue() >= targetRoll; + } + /** * Returns the margin of success/failure of the roll compared to the target roll. * @param targetRoll the target roll to compare against diff --git a/megamek/src/megamek/common/options/AbstractOptions.java b/megamek/src/megamek/common/options/AbstractOptions.java index 380ec4b4db..2e12f14402 100755 --- a/megamek/src/megamek/common/options/AbstractOptions.java +++ b/megamek/src/megamek/common/options/AbstractOptions.java @@ -1,6 +1,5 @@ /* * MegaMek - Copyright (C) 2000-2003 Ben Mazur (bmazur@sev.org) - * Copyright (c) 2024 - The MegaMek Team. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -14,22 +13,19 @@ */ package megamek.common.options; -import java.io.Serial; +import megamek.common.annotations.Nullable; + import java.io.Serializable; import java.util.*; /** * Parent class for options settings */ -public abstract class AbstractOptions implements Serializable, IGameOptions { - - @Serial +public abstract class AbstractOptions implements IGameOptions, Serializable { private static final long serialVersionUID = 6406883135074654379L; - - protected final Hashtable optionsHash; + private final Hashtable optionsHash = new Hashtable<>(); protected AbstractOptions() { - optionsHash = new Hashtable<>(512); initialize(); getOptionsInfoImp().finish(); } @@ -63,17 +59,8 @@ public int count(String groupKey) { } @Override - public IOptionsInfo getOptionsInfo() { - return getOptionsInfoImp(); - } - - protected IBasicOptionGroup addGroup(String groupName) { - return getOptionsInfoImp().addGroup(groupName); - } - - public Enumeration getGroups() { - return new AbstractOptions.GroupsEnumeration(); + return new GroupsEnumeration(); } /** @@ -86,6 +73,17 @@ public Enumeration getOptions() { return optionsHash.elements(); } + /** + * Returns a collection of all of the options in this options container, regardless of whether they're + * active/selected or not. Note that this Collection is unmodifiable, but the contained IOptions are not + * copied, so changing their state will affect this options object. + * + * @return A collection containing all IOptions of this options object + */ + public Collection getOptionsList() { + return Collections.unmodifiableCollection(optionsHash.values()); + } + /** * Returns the UI specific data to allow the user to set the option * @@ -97,50 +95,62 @@ public IOptionInfo getOptionInfo(String name) { return getOptionsInfo().getOptionInfo(name); } + @Override + public @Nullable IOption getOption(String name) { + return optionsHash.get(name); + } + /** - * Returns a collection of all of the options in this options container, regardless of whether they're - * active/selected or not. Note that this Collection is unmodifiable, but the contained IOptions are not - * copied, so changing their state will affect this options object. + * Returns the value of the desired option as the String * - * @return A collection containing all IOptions of this options object + * @param name option name + * @return the value of the desired option as the String */ - public Collection getOptionsList() { - return Collections.unmodifiableCollection(optionsHash.values()); + public String stringOption(String name) { + return getOption(name).stringValue(); } @Override - public IOption getOption(String name) { - return optionsHash.get(name); + public IOptionsInfo getOptionsInfo() { + return getOptionsInfoImp(); + } + + Map getOptionsHash() { + return optionsHash; } protected abstract AbstractOptionsInfo getOptionsInfoImp(); + protected IBasicOptionGroup addGroup(String groupName) { + return getOptionsInfoImp().addGroup(groupName); + } + protected IBasicOptionGroup addGroup(String groupName, String key) { return getOptionsInfoImp().addGroup(groupName, key); } protected void addOption(IBasicOptionGroup group, String name, - String defaultValue) { + String defaultValue) { addOption(group, name, IOption.STRING, defaultValue); } protected void addOption(IBasicOptionGroup group, String name, - boolean defaultValue) { + boolean defaultValue) { addOption(group, name, IOption.BOOLEAN, defaultValue); } protected void addOption(IBasicOptionGroup group, String name, - int defaultValue) { + int defaultValue) { addOption(group, name, IOption.INTEGER, defaultValue); } protected void addOption(IBasicOptionGroup group, String name, - float defaultValue) { + float defaultValue) { addOption(group, name, IOption.FLOAT, defaultValue); } protected void addOption(IBasicOptionGroup group, String name, Vector defaultValue) { - addOption(group, name, IOption.CHOICE, ""); // defaultValue is ignored and set as empty string + addOption(group, name, IOption.CHOICE, ""); } protected void addOption(IBasicOptionGroup group, String name, int type, Object defaultValue) { @@ -148,9 +158,11 @@ protected void addOption(IBasicOptionGroup group, String name, int type, Object getOptionsInfoImp().addOptionInfo(group, name); } + + protected class GroupsEnumeration implements Enumeration { - private final Enumeration groups; + private Enumeration groups; GroupsEnumeration() { groups = getOptionsInfo().getGroups(); @@ -178,7 +190,7 @@ public IOptionGroup nextElement() { protected class GroupProxy implements IOptionGroup { - private final IBasicOptionGroup group; + private IBasicOptionGroup group; GroupProxy(IBasicOptionGroup group) { this.group = group; @@ -197,7 +209,7 @@ public String getName() { @Override public String getDisplayableName() { return getOptionsInfoImp().getGroupDisplayableName( - group.getName()); + group.getName()); } @Override @@ -255,4 +267,5 @@ public void sortOptions() { } } + } diff --git a/megamek/src/megamek/common/options/BasicGameOptions.java b/megamek/src/megamek/common/options/BasicGameOptions.java index 0ca56d9627..178f454773 100644 --- a/megamek/src/megamek/common/options/BasicGameOptions.java +++ b/megamek/src/megamek/common/options/BasicGameOptions.java @@ -19,61 +19,44 @@ package megamek.common.options; import java.io.File; -import java.util.Hashtable; import java.util.Vector; public abstract class BasicGameOptions extends AbstractOptions { - - private static final Option.OptionValue[] baseOptions = { - Option.of(OptionsConstants.BASE_FRIENDLY_FIRE, false), - Option.of(OptionsConstants.BASE_SKIP_INELIGIBLE_MOVEMENT, false), - Option.of(OptionsConstants.BASE_SKIP_INELIGIBLE_FIRING, false), - Option.of(OptionsConstants.BASE_SKIP_INELIGIBLE_PHYSICAL, true), - Option.of(OptionsConstants.BASE_TEAM_INITIATIVE, true), - Option.of(OptionsConstants.BASE_AUTOSAVE_MSG, true), - Option.of(OptionsConstants.BASE_PARANOID_AUTOSAVE, false), - Option.of(OptionsConstants.BASE_MAX_NUMBER_ROUND_SAVES, 3), - Option.of(OptionsConstants.BASE_EXCLUSIVE_DB_DEPLOYMENT, true), - Option.of(OptionsConstants.BASE_BLIND_DROP, false), - Option.of(OptionsConstants.BASE_REAL_BLIND_DROP, false), - Option.of(OptionsConstants.BASE_SET_ARTY_PLAYER_HOMEEDGE, false), - Option.of(OptionsConstants.BASE_SET_DEFAULT_TEAM_1, false), - Option.of(OptionsConstants.BASE_SET_PLAYER_DEPLOYMENT_TO_PLAYER0, false), - Option.of(OptionsConstants.BASE_RESTRICT_GAME_COMMANDS, false), - Option.of(OptionsConstants.BASE_DISABLE_LOCAL_SAVE, false), - Option.of(OptionsConstants.BASE_BRIDGECF, 0), - Option.of(OptionsConstants.BASE_RNG_TYPE, 1), - Option.of(OptionsConstants.BASE_RNG_LOG, false), - Option.of(OptionsConstants.BASE_TURN_TIMER_TARGETING, 0), - Option.of(OptionsConstants.BASE_TURN_TIMER_MOVEMENT, 0), - Option.of(OptionsConstants.BASE_TURN_TIMER_FIRING, 0), - Option.of(OptionsConstants.BASE_TURN_TIMER_PHYSICAL, 0), - Option.of(OptionsConstants.BASE_TURN_TIMER_ALLOW_EXTENSION, true), - Option.of(OptionsConstants.BASE_SUPPRESS_UNIT_TOOLTIP_IN_REPORT_LOG, true), - Option.of(OptionsConstants.BASE_GM_CONTROLS_DONE_REPORT_PHASE, false), - Option.of(OptionsConstants.BASE_HIDE_UNOFFICIAL, false), - Option.of(OptionsConstants.BASE_HIDE_LEGACY, false) - }; - - private static final Option.OptionValue[] victoryOptions = { - Option.of(OptionsConstants.VICTORY_CHECK_VICTORY, true) - }; - - - private void addOptions(IBasicOptionGroup group, Option.OptionValue[] options) { - for (var entry : options) { - addOption(group, entry.getName(), entry.getType(), entry.getValue()); - } - } - @Override public synchronized void initialize() { IBasicOptionGroup base = addGroup("basic"); - addOptions(base, baseOptions); + addOption(base, OptionsConstants.BASE_FRIENDLY_FIRE, false); + addOption(base, OptionsConstants.BASE_SKIP_INELIGIBLE_MOVEMENT, false); + addOption(base, OptionsConstants.BASE_SKIP_INELIGIBLE_FIRING, false); + addOption(base, OptionsConstants.BASE_SKIP_INELIGIBLE_PHYSICAL, true); + addOption(base, OptionsConstants.BASE_TEAM_INITIATIVE, true); + addOption(base, OptionsConstants.BASE_AUTOSAVE_MSG, true); + addOption(base, OptionsConstants.BASE_PARANOID_AUTOSAVE, false); + addOption(base, OptionsConstants.BASE_MAX_NUMBER_ROUND_SAVES, 3); + addOption(base, OptionsConstants.BASE_EXCLUSIVE_DB_DEPLOYMENT, true); + addOption(base, OptionsConstants.BASE_BLIND_DROP, false); + addOption(base, OptionsConstants.BASE_REAL_BLIND_DROP, false); + addOption(base, OptionsConstants.BASE_SET_ARTY_PLAYER_HOMEEDGE, false); + addOption(base, OptionsConstants.BASE_SET_DEFAULT_TEAM_1, false); + addOption(base, OptionsConstants.BASE_SET_PLAYER_DEPLOYMENT_TO_PLAYER0, false); + addOption(base, OptionsConstants.BASE_RESTRICT_GAME_COMMANDS, false); + addOption(base, OptionsConstants.BASE_DISABLE_LOCAL_SAVE, false); + addOption(base, OptionsConstants.BASE_BRIDGECF, 0); + addOption(base, OptionsConstants.BASE_RNG_TYPE, 1); + addOption(base, OptionsConstants.BASE_RNG_LOG, false); + addOption(base, OptionsConstants.BASE_TURN_TIMER_TARGETING, 0); + addOption(base, OptionsConstants.BASE_TURN_TIMER_MOVEMENT, 0); + addOption(base, OptionsConstants.BASE_TURN_TIMER_FIRING, 0); + addOption(base, OptionsConstants.BASE_TURN_TIMER_PHYSICAL, 0); + addOption(base, OptionsConstants.BASE_TURN_TIMER_ALLOW_EXTENSION, true); + addOption(base, OptionsConstants.BASE_SUPPRESS_UNIT_TOOLTIP_IN_REPORT_LOG, true); + addOption(base, OptionsConstants.BASE_GM_CONTROLS_DONE_REPORT_PHASE, false); + addOption(base, OptionsConstants.BASE_HIDE_UNOFFICIAL, false); + addOption(base, OptionsConstants.BASE_HIDE_LEGACY, false); IBasicOptionGroup victory = addGroup("victory"); - addOptions(victory, victoryOptions); + addOption(victory, OptionsConstants.VICTORY_CHECK_VICTORY, true); } public abstract Vector loadOptions(); diff --git a/megamek/src/megamek/common/options/GameOptions.java b/megamek/src/megamek/common/options/GameOptions.java index feb071a269..904db186ac 100755 --- a/megamek/src/megamek/common/options/GameOptions.java +++ b/megamek/src/megamek/common/options/GameOptions.java @@ -13,14 +13,15 @@ */ package megamek.common.options; -import java.io.*; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.io.PrintWriter; import java.util.Enumeration; -import java.util.Map; import java.util.Vector; import javax.xml.namespace.QName; -import org.apache.commons.lang3.tuple.Pair; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -38,13 +39,12 @@ /** * Contains the options determining play in the current game. - * TODO: This class and every other "Options" need to be refactored, probably using enums? + * * @author Ben */ public class GameOptions extends BasicGameOptions { private static final MMLogger logger = MMLogger.create(GameOptions.class); - @Serial private static final long serialVersionUID = 4916321960852747706L; private static final String GAME_OPTIONS_FILE_NAME = "mmconf/gameoptions.xml"; @@ -52,302 +52,258 @@ public GameOptions() { super(); } - private static final Option.OptionValue[] BASE_OPTIONS = { - Option.of(OptionsConstants.BASE_PUSH_OFF_BOARD, true), - Option.of(OptionsConstants.BASE_DUMPING_FROM_ROUND, 1), - Option.of(OptionsConstants.BASE_LOBBY_AMMO_DUMP, false), - Option.of(OptionsConstants.BASE_SHOW_BAY_DETAIL, false), - Option.of(OptionsConstants.BASE_INDIRECT_FIRE, true), - Option.of(OptionsConstants.BASE_FLAMER_HEAT, false), - Option.of(OptionsConstants.BASE_INFANTRY_DAMAGE_HEAT, false), - Option.of(OptionsConstants.BASE_AUTO_AMS, true), - Option.of(OptionsConstants.BASE_RANDOM_BASEMENTS, true), - Option.of(OptionsConstants.BASE_BREEZE, false) - }; - - private static final Option.OptionValue[] VICTORY_OPTIONS = { - Option.of(OptionsConstants.VICTORY_SKIP_FORCED_VICTORY, false), - Option.of(OptionsConstants.VICTORY_ACHIEVE_CONDITIONS, 1), - Option.of(OptionsConstants.VICTORY_USE_BV_DESTROYED, false), - Option.of(OptionsConstants.VICTORY_BV_DESTROYED_PERCENT, 100), - Option.of(OptionsConstants.VICTORY_USE_BV_RATIO, false), - Option.of(OptionsConstants.VICTORY_BV_RATIO_PERCENT, 300), - Option.of(OptionsConstants.VICTORY_USE_GAME_TURN_LIMIT, false), - Option.of(OptionsConstants.VICTORY_GAME_TURN_LIMIT, 10), - Option.of(OptionsConstants.VICTORY_USE_KILL_COUNT, false), - Option.of(OptionsConstants.VICTORY_GAME_KILL_COUNT, 4), - Option.of(OptionsConstants.VICTORY_COMMANDER_KILLED, false) - }; - - private static final Option.OptionValue[] ALLOWED_OPTIONS = { - Option.of(OptionsConstants.ALLOWED_CANON_ONLY, false), - Option.of(OptionsConstants.ALLOWED_YEAR, 3150), - Option.of(OptionsConstants.ALLOWED_TECHLEVEL, TechConstants.T_SIMPLE_NAMES[TechConstants.T_SIMPLE_STANDARD]), - Option.of(OptionsConstants.ALLOWED_ERA_BASED, false), - Option.of(OptionsConstants.ALLOWED_ALLOW_ILLEGAL_UNITS, false), - Option.of(OptionsConstants.ALLOWED_SHOW_EXTINCT, true), - Option.of(OptionsConstants.ALLOWED_CLAN_IGNORE_EQ_LIMITS, false), - Option.of(OptionsConstants.ALLOWED_NO_CLAN_PHYSICAL, false), - Option.of(OptionsConstants.ALLOWED_ALLOW_NUKES, false), - Option.of(OptionsConstants.ALLOWED_REALLY_ALLOW_NUKES, false) - }; - - private static final Option.OptionValue[] ADVANCED_RULES_OPTIONS = { - Option.of(OptionsConstants.ADVANCED_MINEFIELDS, false), - Option.of(OptionsConstants.ADVANCED_HIDDEN_UNITS, true), - Option.of(OptionsConstants.ADVANCED_BLACK_ICE, false), - Option.of(OptionsConstants.ADVANCED_LIGHTNING_STORM_TARGETS_UNITS, false), - Option.of(OptionsConstants.ADVANCED_DOUBLE_BLIND, false), - Option.of(OptionsConstants.ADVANCED_TACOPS_SENSORS, false), - Option.of(OptionsConstants.ADVANCED_SUPRESS_ALL_DB_MESSAGES, false), - Option.of(OptionsConstants.ADVANCED_SUPPRESS_DB_BV, false), - Option.of(OptionsConstants.ADVANCED_TEAM_VISION, true), - Option.of(OptionsConstants.ADVANCED_TACOPS_BAP, false), - Option.of(OptionsConstants.ADVANCED_TACOPS_ECCM, false), - Option.of(OptionsConstants.ADVANCED_TACOPS_GHOST_TARGET, false), - Option.of(OptionsConstants.ADVANCED_GHOST_TARGET_MAX, 5), - Option.of(OptionsConstants.ADVANCED_TACOPS_DIG_IN, false), - Option.of(OptionsConstants.ADVANCED_TACOPS_BA_WEIGHT, false), - Option.of(OptionsConstants.ADVANCED_TACOPS_TAKE_COVER, false), - Option.of(OptionsConstants.ADVANCED_TACOPS_ANGEL_ECM, false), - Option.of(OptionsConstants.ADVANCED_TACOPS_BATTLE_WRECK, false), - Option.of(OptionsConstants.ADVANCED_TACOPS_SKIN_OF_THE_TEETH_EJECTION, false), - Option.of(OptionsConstants.ADVANCED_TACOPS_MOBILE_HQS, false), - Option.of(OptionsConstants.ADVANCED_TACOPS_FATIGUE, false), - Option.of(OptionsConstants.ADVANCED_TACOPS_FUMBLES, false), - Option.of(OptionsConstants.ADVANCED_TACOPS_SELF_DESTRUCT, false), - Option.of(OptionsConstants.ADVANCED_TACOPS_TANK_CREWS, false), - Option.of(OptionsConstants.ADVANCED_STRATOPS_QUIRKS, false), - Option.of(OptionsConstants.ADVANCED_STRATOPS_PARTIALREPAIRS, false), - Option.of(OptionsConstants.ADVANCED_ASSAULT_DROP, false), - Option.of(OptionsConstants.ADVANCED_PARATROOPERS, false), - Option.of(OptionsConstants.ADVANCED_INCLUSIVE_SENSOR_RANGE, false), - Option.of(OptionsConstants.ADVANCED_SENSORS_DETECT_ALL, false), - Option.of(OptionsConstants.ADVANCED_MAGSCAN_NOHILLS, false), - Option.of(OptionsConstants.ADVANCED_WOODS_BURN_DOWN, false), - Option.of(OptionsConstants.ADVANCED_WOODS_BURN_DOWN_AMOUNT, 5), - Option.of(OptionsConstants.ADVANCED_NO_IGNITE_CLEAR, false), - Option.of(OptionsConstants.ADVANCED_ALL_HAVE_EI_COCKPIT, false), - Option.of(OptionsConstants.ADVANCED_EXTREME_TEMPERATURE_SURVIVAL, false), - Option.of(OptionsConstants.ADVANCED_ARMED_MEKWARRIORS, false), - Option.of(OptionsConstants.ADVANCED_PILOTS_VISUAL_RANGE_ONE, false), - Option.of(OptionsConstants.ADVANCED_PILOTS_CANNOT_SPOT, false), - Option.of(OptionsConstants.ADVANCED_METAL_CONTENT, false), - Option.of(OptionsConstants.ADVANCED_BA_GRAB_BARS, false), - Option.of(OptionsConstants.ADVANCED_MAXTECH_MOVEMENT_MODS, false), - Option.of(OptionsConstants.ADVANCED_ALTERNATE_MASC, false), - Option.of(OptionsConstants.ADVANCED_ALTERNATE_MASC_ENHANCED, false), - Option.of(OptionsConstants.ADVANCED_SINGLE_BLIND_BOTS, false) - }; - - private static final Option.OptionValue[] ADVANCED_COMBAT_OPTIONS = { - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_AMS, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_MANUAL_AMS, false), - Option.of(OptionsConstants.ADVCOMBAT_FLOATING_CRITS, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_CRIT_ROLL, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_ENGINE_EXPLOSIONS, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_CALLED_SHOTS, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_PRONE_FIRE, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_START_FIRE, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_RANGE, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_LOS_RANGE, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_DEAD_ZONES, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_LOS1, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_ALTDMG, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_CLUSTERHITPEN, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_PPC_INHIBITORS, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_CHARGE_DAMAGE, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_GLANCING_BLOWS, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_DIRECT_BLOW, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_BURST, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_HEAT, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_PARTIAL_COVER, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_BA_CRITICALS, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_HOTLOAD, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_RAPID_AC, false), - Option.of(OptionsConstants.ADVCOMBAT_KIND_RAPID_AC, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_GRAPPLING, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_JUMP_JET_ATTACK, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_TRIP_ATTACK, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_ENERGY_WEAPONS, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_GAUSS_WEAPONS, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_RETRACTABLE_BLADES, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_AMMUNITION, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_WOODS_COVER, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_VEHICLE_EFFECTIVE, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_VEHICLE_ARCS, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_VTOL_ATTACKS, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_ADVANCED_MEK_HIT_LOCATIONS, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_COOLANT_FAILURE, false), - Option.of(OptionsConstants.ADVCOMBAT_TACOPS_BA_VS_BA, false), - Option.of(OptionsConstants.ADVCOMBAT_NO_TAC, false), - Option.of(OptionsConstants.ADVCOMBAT_VEHICLES_THRESHOLD, false), - Option.of(OptionsConstants.ADVCOMBAT_VEHICLES_THRESHOLD_VARIABLE, false), - Option.of(OptionsConstants.ADVCOMBAT_VEHICLES_THRESHOLD_DIVISOR, 10), - Option.of(OptionsConstants.ADVCOMBAT_VTOL_STRAFING, false), - Option.of(OptionsConstants.ADVCOMBAT_VEHICLES_SAFE_FROM_INFERNOS, false), - Option.of(OptionsConstants.ADVCOMBAT_PROTOS_SAFE_FROM_INFERNOS, false), - Option.of(OptionsConstants.ADVCOMBAT_INDIRECT_ALWAYS_POSSIBLE, false), - Option.of(OptionsConstants.ADVCOMBAT_INCREASED_AC_DMG, false), - Option.of(OptionsConstants.ADVCOMBAT_UNJAM_UAC, false), - Option.of(OptionsConstants.ADVCOMBAT_UAC_TWOROLLS, false), - Option.of(OptionsConstants.ADVCOMBAT_CLUBS_PUNCH, false), - Option.of(OptionsConstants.ADVCOMBAT_ON_MAP_PREDESIGNATE, false), - Option.of(OptionsConstants.ADVCOMBAT_NUM_HEXES_PREDESIGNATE, 5), - Option.of(OptionsConstants.ADVCOMBAT_MAP_AREA_PREDESIGNATE, 1088), - Option.of(OptionsConstants.ADVCOMBAT_MAX_EXTERNAL_HEAT, 15), - Option.of(OptionsConstants.ADVCOMBAT_CASE_PILOT_DAMAGE, false), - Option.of(OptionsConstants.ADVCOMBAT_NO_FORCED_PRIMARY_TARGETS, false), - Option.of(OptionsConstants.ADVCOMBAT_FULL_ROTOR_HITS, false), - Option.of(OptionsConstants.ADVCOMBAT_FOREST_FIRES_NO_SMOKE, false), - Option.of(OptionsConstants.ADVCOMBAT_HOTLOAD_IN_GAME, false), - Option.of(OptionsConstants.ADVCOMBAT_MULTI_USE_AMS, false) - }; - - private static final Option.OptionValue[] ADVANCED_GROUND_MOVEMENT_OPTIONS = { - Option.of(OptionsConstants.ADVGRNDMOV_TACOPS_SPRINT, false), - Option.of(OptionsConstants.ADVGRNDMOV_TACOPS_STANDING_STILL, false), - Option.of(OptionsConstants.ADVGRNDMOV_TACOPS_EVADE, false), - Option.of(OptionsConstants.ADVGRNDMOV_TACOPS_SKILLED_EVASION, false), - Option.of(OptionsConstants.ADVGRNDMOV_TACOPS_LEAPING, false), - Option.of(OptionsConstants.ADVGRNDMOV_TACOPS_PHYSICAL_PSR, false), - Option.of(OptionsConstants.ADVGRNDMOV_TACOPS_PHYSICAL_ATTACK_PSR, false), - Option.of(OptionsConstants.ADVGRNDMOV_TACOPS_TAKING_DAMAGE, false), - Option.of(OptionsConstants.ADVGRNDMOV_TACOPS_LEG_DAMAGE, false), - Option.of(OptionsConstants.ADVGRNDMOV_TACOPS_WALK_BACKWARDS, false), - Option.of(OptionsConstants.ADVGRNDMOV_TACOPS_FAST_INFANTRY_MOVE, false), - Option.of(OptionsConstants.ADVANCED_TACOPS_INF_PAVE_BONUS, false), - Option.of(OptionsConstants.ADVGRNDMOV_VEHICLE_LANCE_MOVEMENT, false), - Option.of(OptionsConstants.ADVGRNDMOV_VEHICLE_LANCE_MOVEMENT_NUMBER, 4), - Option.of(OptionsConstants.ADVGRNDMOV_VEHICLE_ACCELERATION, false), - Option.of(OptionsConstants.ADVGRNDMOV_REVERSE_GEAR, false), - Option.of(OptionsConstants.ADVGRNDMOV_TURN_MODE, false), - Option.of(OptionsConstants.ADVGRNDMOV_VEHICLE_ADVANCED_MANEUVERS, false), - Option.of(OptionsConstants.ADVGRNDMOV_TACOPS_HULL_DOWN, false), - Option.of(OptionsConstants.ADVGRNDMOV_TACOPS_FALLING_EXPANDED, false), - Option.of(OptionsConstants.ADVGRNDMOV_TACOPS_ATTEMPTING_STAND, false), - Option.of(OptionsConstants.ADVGRNDMOV_TACOPS_CAREFUL_STAND, false), - Option.of(OptionsConstants.ADVGRNDMOV_TACOPS_ZIPLINES, false), - Option.of(OptionsConstants.ADVGRNDMOV_MEK_LANCE_MOVEMENT, false), - Option.of(OptionsConstants.ADVGRNDMOV_MEK_LANCE_MOVEMENT_NUMBER, 4), - Option.of(OptionsConstants.ADVGRNDMOV_NO_IMMOBILE_VEHICLES, false), - Option.of(OptionsConstants.ADVGRNDMOV_VEHICLES_CAN_EJECT, false), - Option.of(OptionsConstants.ADVGRNDMOV_EJECTED_PILOTS_FLEE, false), - Option.of(OptionsConstants.ADVGRNDMOV_AUTO_ABANDON_UNIT, false), - Option.of(OptionsConstants.ADVGRNDMOV_NO_HOVER_CHARGE, false), - Option.of(OptionsConstants.ADVGRNDMOV_NO_PREMOVE_VIBRA, false), - Option.of(OptionsConstants.ADVGRNDMOV_FALLS_END_MOVEMENT, false), - Option.of(OptionsConstants.ADVGRNDMOV_PSR_JUMP_HEAVY_WOODS, false), - Option.of(OptionsConstants.ADVGRNDMOV_NO_NIGHT_MOVE_PEN, false) - }; - - private static final Option.OptionValue[] ADVANCED_AERO_RULES_OPTIONS = { - Option.of(OptionsConstants.ADVAERORULES_AERO_GROUND_MOVE, true), - Option.of(OptionsConstants.ADVAERORULES_STRATOPS_CAPITAL_FIGHTER, false), - Option.of(OptionsConstants.ADVAERORULES_FUEL_CONSUMPTION, false), - Option.of(OptionsConstants.ADVAERORULES_STRATOPS_CONV_FUSION_BONUS, false), - Option.of(OptionsConstants.ADVAERORULES_STRATOPS_HARJEL, false), - Option.of(OptionsConstants.ADVAERORULES_STRATOPS_GRAV_EFFECTS, false), - Option.of(OptionsConstants.ADVAERORULES_ADVANCED_MOVEMENT, false), - Option.of(OptionsConstants.ADVAERORULES_HEAT_BY_BAY, false), - Option.of(OptionsConstants.ADVAERORULES_ATMOSPHERIC_CONTROL, false), - Option.of(OptionsConstants.ADVAERORULES_STRATOPS_AMMO_EXPLOSIONS, false), - Option.of(OptionsConstants.ADVAERORULES_STRATOPS_AAA_LASER, false), - Option.of(OptionsConstants.ADVAERORULES_STRATOPS_ADV_POINTDEF, false), - Option.of(OptionsConstants.ADVAERORULES_STRATOPS_BRACKET_FIRE, false), - Option.of(OptionsConstants.ADVAERORULES_STRATOPS_ECM, false), - Option.of(OptionsConstants.ADVAERORULES_STRATOPS_SENSOR_SHADOW, false), - Option.of(OptionsConstants.ADVAERORULES_STRATOPS_OVER_PENETRATE, false), - Option.of(OptionsConstants.ADVAERORULES_STRATOPS_SPACE_BOMB, false), - Option.of(OptionsConstants.ADVAERORULES_STRATOPS_BEARINGS_ONLY_LAUNCH, false), - Option.of(OptionsConstants.ADVAERORULES_STRATOPS_BEARINGS_ONLY_VELOCITY, 50), - Option.of(OptionsConstants.ADVAERORULES_STRATOPS_WAYPOINT_LAUNCH, false), - Option.of(OptionsConstants.ADVAERORULES_STRATOPS_ADVANCED_SENSORS, false), - Option.of(OptionsConstants.ADVAERORULES_VARIABLE_DAMAGE_THRESH, false), - Option.of(OptionsConstants.ADVAERORULES_AT2_NUKES, false), - Option.of(OptionsConstants.ADVAERORULES_AERO_SANITY, false), - Option.of(OptionsConstants.ADVAERORULES_RETURN_FLYOVER, true), - Option.of(OptionsConstants.ADVAERORULES_STRATOPS_AA_FIRE, false), - Option.of(OptionsConstants.ADVAERORULES_AA_MOVE_MOD, false), - Option.of(OptionsConstants.ADVAERORULES_ALLOW_LARGE_SQUADRONS, false), - Option.of(OptionsConstants.ADVAERORULES_SINGLE_NO_CAP, false), - Option.of(OptionsConstants.ADVAERORULES_AERO_ARTILLERY_MUNITIONS, false), - Option.of(OptionsConstants.ADVAERORULES_CRASHED_DROPSHIPS_SURVIVE, false), - Option.of(OptionsConstants.ADVAERORULES_EXPANDED_KF_DRIVE_DAMAGE, false), - Option.of(OptionsConstants.UNOFF_ADV_ATMOSPHERIC_CONTROL, false) - }; - - private static final Option.OptionValue[] INITIATIVE_OPTIONS = { - Option.of(OptionsConstants.INIT_INF_MOVE_EVEN, false), - Option.of(OptionsConstants.INIT_INF_DEPLOY_EVEN, false), - Option.of(OptionsConstants.INIT_INF_MOVE_LATER, false), - Option.of(OptionsConstants.INIT_INF_MOVE_MULTI, false), - Option.of(OptionsConstants.INIT_PROTOS_MOVE_EVEN, false), - Option.of(OptionsConstants.INIT_PROTOS_MOVE_LATER, false), - Option.of(OptionsConstants.INIT_PROTOS_MOVE_MULTI, false), - Option.of(OptionsConstants.INIT_INF_PROTO_MOVE_MULTI, 3), - Option.of(OptionsConstants.INIT_SIMULTANEOUS_DEPLOYMENT, false), - Option.of(OptionsConstants.INIT_SIMULTANEOUS_TARGETING, false), - Option.of(OptionsConstants.INIT_SIMULTANEOUS_FIRING, false), - Option.of(OptionsConstants.INIT_SIMULTANEOUS_PHYSICAL, false), - Option.of(OptionsConstants.INIT_FRONT_LOAD_INITIATIVE, false), - Option.of(OptionsConstants.INIT_INITIATIVE_STREAK_COMPENSATION, false) - }; - - private static final Option.OptionValue[] RPG_OPTIONS = { - Option.of(OptionsConstants.RPG_PILOT_ADVANTAGES, false), - Option.of(OptionsConstants.EDGE, false), - Option.of(OptionsConstants.RPG_MANEI_DOMINI, false), - Option.of(OptionsConstants.RPG_INDIVIDUAL_INITIATIVE, false), - Option.of(OptionsConstants.RPG_COMMAND_INIT, false), - Option.of(OptionsConstants.RPG_RPG_GUNNERY, false), - Option.of(OptionsConstants.RPG_ARTILLERY_SKILL, false), - Option.of(OptionsConstants.RPG_TOUGHNESS, false), - Option.of(OptionsConstants.RPG_CONDITIONAL_EJECTION, false), - Option.of(OptionsConstants.RPG_BEGIN_SHUTDOWN, false) - }; - @Override public synchronized void initialize() { super.initialize(); - IBasicOptionGroup baseGroup = addGroup("basic"); - addOptions(baseGroup, BASE_OPTIONS); - - IBasicOptionGroup victoryGroup = addGroup("victory"); - addOptions(victoryGroup, VICTORY_OPTIONS); - - IBasicOptionGroup allowedGroup = addGroup("allowedUnits"); - addOptions(allowedGroup, ALLOWED_OPTIONS); - - IBasicOptionGroup advancedRulesGroup = addGroup("advancedRules"); - addOptions(advancedRulesGroup, ADVANCED_RULES_OPTIONS); - - IBasicOptionGroup advancedCombatGroup = addGroup("advancedCombat"); - addOptions(advancedCombatGroup, ADVANCED_COMBAT_OPTIONS); - - IBasicOptionGroup advancedGroundMovementGroup = addGroup("advancedGroundMovement"); - addOptions(advancedGroundMovementGroup, ADVANCED_GROUND_MOVEMENT_OPTIONS); - - IBasicOptionGroup advancedAeroRulesGroup = addGroup("advancedAeroRules"); - addOptions(advancedAeroRulesGroup, ADVANCED_AERO_RULES_OPTIONS); - - IBasicOptionGroup initiativeGroup = addGroup("initiative"); - addOptions(initiativeGroup, INITIATIVE_OPTIONS); - - IBasicOptionGroup rpgGroup = addGroup("rpg"); - addOptions(rpgGroup, RPG_OPTIONS); - } - - private void addOptions(IBasicOptionGroup group, Option.OptionValue[] options) { - for (var entry : options) { - int type = entry.getType(); - - if (type == IOption.STRING && OptionsConstants.ALLOWED_TECHLEVEL.equals(entry.getName())) { - type = IOption.CHOICE; - } - addOption(group, entry.getName(), type, entry.getValue()); - } + IBasicOptionGroup base = addGroup("basic"); + addOption(base, OptionsConstants.BASE_PUSH_OFF_BOARD, true); + addOption(base, OptionsConstants.BASE_DUMPING_FROM_ROUND, 1); + addOption(base, OptionsConstants.BASE_LOBBY_AMMO_DUMP, false); + addOption(base, OptionsConstants.BASE_SHOW_BAY_DETAIL, false); + addOption(base, OptionsConstants.BASE_INDIRECT_FIRE, true); + addOption(base, OptionsConstants.BASE_FLAMER_HEAT, false); + addOption(base, OptionsConstants.BASE_INFANTRY_DAMAGE_HEAT, false); + addOption(base, OptionsConstants.BASE_AUTO_AMS, true); + addOption(base, OptionsConstants.BASE_RANDOM_BASEMENTS, true); + addOption(base, OptionsConstants.BASE_BREEZE, false); + + IBasicOptionGroup victory = addGroup("victory"); + addOption(victory, OptionsConstants.VICTORY_SKIP_FORCED_VICTORY, false); + addOption(victory, OptionsConstants.VICTORY_ACHIEVE_CONDITIONS, 1); + addOption(victory, OptionsConstants.VICTORY_USE_BV_DESTROYED, false); + addOption(victory, OptionsConstants.VICTORY_BV_DESTROYED_PERCENT, 100); + addOption(victory, OptionsConstants.VICTORY_USE_BV_RATIO, false); + addOption(victory, OptionsConstants.VICTORY_BV_RATIO_PERCENT, 300); + addOption(victory, OptionsConstants.VICTORY_USE_GAME_TURN_LIMIT, false); + addOption(victory, OptionsConstants.VICTORY_GAME_TURN_LIMIT, 10); + addOption(victory, OptionsConstants.VICTORY_USE_KILL_COUNT, false); + addOption(victory, OptionsConstants.VICTORY_GAME_KILL_COUNT, 4); + addOption(victory, OptionsConstants.VICTORY_COMMANDER_KILLED, false); + + IBasicOptionGroup allowed = addGroup("allowedUnits"); + addOption(allowed, OptionsConstants.ALLOWED_CANON_ONLY, false); + addOption(allowed, OptionsConstants.ALLOWED_YEAR, 3150); + addOption(allowed, OptionsConstants.ALLOWED_TECHLEVEL, IOption.CHOICE, + TechConstants.T_SIMPLE_NAMES[TechConstants.T_SIMPLE_STANDARD]); + addOption(allowed, OptionsConstants.ALLOWED_ERA_BASED, false); + addOption(allowed, OptionsConstants.ALLOWED_ALLOW_ILLEGAL_UNITS, false); + addOption(allowed, OptionsConstants.ALLOWED_SHOW_EXTINCT, true); + addOption(allowed, OptionsConstants.ALLOWED_CLAN_IGNORE_EQ_LIMITS, false); + addOption(allowed, OptionsConstants.ALLOWED_NO_CLAN_PHYSICAL, false); + addOption(allowed, OptionsConstants.ALLOWED_ALLOW_NUKES, false); + addOption(allowed, OptionsConstants.ALLOWED_REALLY_ALLOW_NUKES, false); + + IBasicOptionGroup advancedRules = addGroup("advancedRules"); + addOption(advancedRules, OptionsConstants.ADVANCED_MINEFIELDS, false); + addOption(advancedRules, OptionsConstants.ADVANCED_HIDDEN_UNITS, true); + addOption(advancedRules, OptionsConstants.ADVANCED_BLACK_ICE, false); + addOption(advancedRules, OptionsConstants.ADVANCED_LIGHTNING_STORM_TARGETS_UNITS, false); + addOption(advancedRules, OptionsConstants.ADVANCED_DOUBLE_BLIND, false); + addOption(advancedRules, OptionsConstants.ADVANCED_TACOPS_SENSORS, false); + addOption(advancedRules, OptionsConstants.ADVANCED_SUPRESS_ALL_DB_MESSAGES, false); + addOption(advancedRules, OptionsConstants.ADVANCED_SUPPRESS_DB_BV, false); + addOption(advancedRules, OptionsConstants.ADVANCED_TEAM_VISION, true); + addOption(advancedRules, OptionsConstants.ADVANCED_TACOPS_BAP, false); + addOption(advancedRules, OptionsConstants.ADVANCED_TACOPS_ECCM, false); + addOption(advancedRules, OptionsConstants.ADVANCED_TACOPS_GHOST_TARGET, false); + addOption(advancedRules, OptionsConstants.ADVANCED_GHOST_TARGET_MAX, 5); + addOption(advancedRules, OptionsConstants.ADVANCED_TACOPS_DIG_IN, false); + addOption(advancedRules, OptionsConstants.ADVANCED_TACOPS_BA_WEIGHT, false); + addOption(advancedRules, OptionsConstants.ADVANCED_TACOPS_TAKE_COVER, false); + addOption(advancedRules, OptionsConstants.ADVANCED_TACOPS_ANGEL_ECM, false); + addOption(advancedRules, OptionsConstants.ADVANCED_TACOPS_BATTLE_WRECK, false); + addOption(advancedRules, OptionsConstants.ADVANCED_TACOPS_SKIN_OF_THE_TEETH_EJECTION, false); + addOption(advancedRules, OptionsConstants.ADVANCED_TACOPS_MOBILE_HQS, false); + addOption(advancedRules, OptionsConstants.ADVANCED_TACOPS_FATIGUE, false); + addOption(advancedRules, OptionsConstants.ADVANCED_TACOPS_FUMBLES, false); + addOption(advancedRules, OptionsConstants.ADVANCED_TACOPS_SELF_DESTRUCT, false); + addOption(advancedRules, OptionsConstants.ADVANCED_TACOPS_TANK_CREWS, false); + addOption(advancedRules, OptionsConstants.ADVANCED_STRATOPS_QUIRKS, false); + addOption(advancedRules, OptionsConstants.ADVANCED_STRATOPS_PARTIALREPAIRS, false); + addOption(advancedRules, OptionsConstants.ADVANCED_ASSAULT_DROP, false); + addOption(advancedRules, OptionsConstants.ADVANCED_PARATROOPERS, false); + addOption(advancedRules, OptionsConstants.ADVANCED_INCLUSIVE_SENSOR_RANGE, false); + addOption(advancedRules, OptionsConstants.ADVANCED_SENSORS_DETECT_ALL, false); + addOption(advancedRules, OptionsConstants.ADVANCED_MAGSCAN_NOHILLS, false); + addOption(advancedRules, OptionsConstants.ADVANCED_WOODS_BURN_DOWN, false); + addOption(advancedRules, OptionsConstants.ADVANCED_WOODS_BURN_DOWN_AMOUNT, 5); + addOption(advancedRules, OptionsConstants.ADVANCED_NO_IGNITE_CLEAR, false); + addOption(advancedRules, OptionsConstants.ADVANCED_ALL_HAVE_EI_COCKPIT, false); + addOption(advancedRules, OptionsConstants.ADVANCED_EXTREME_TEMPERATURE_SURVIVAL, false); + addOption(advancedRules, OptionsConstants.ADVANCED_ARMED_MEKWARRIORS, false); + addOption(advancedRules, OptionsConstants.ADVANCED_PILOTS_VISUAL_RANGE_ONE, false); + addOption(advancedRules, OptionsConstants.ADVANCED_PILOTS_CANNOT_SPOT, false); + addOption(advancedRules, OptionsConstants.ADVANCED_METAL_CONTENT, false); + addOption(advancedRules, OptionsConstants.ADVANCED_BA_GRAB_BARS, false); + addOption(advancedRules, OptionsConstants.ADVANCED_MAXTECH_MOVEMENT_MODS, false); + addOption(advancedRules, OptionsConstants.ADVANCED_ALTERNATE_MASC, false); + addOption(advancedRules, OptionsConstants.ADVANCED_ALTERNATE_MASC_ENHANCED, false); + addOption(advancedRules, OptionsConstants.ADVANCED_SINGLE_BLIND_BOTS, false); + + IBasicOptionGroup advancedCombat = addGroup("advancedCombat"); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_AMS, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_MANUAL_AMS, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_FLOATING_CRITS, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_CRIT_ROLL, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_ENGINE_EXPLOSIONS, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_CALLED_SHOTS, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_PRONE_FIRE, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_START_FIRE, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_RANGE, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_LOS_RANGE, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_DEAD_ZONES, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_LOS1, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_ALTDMG, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_CLUSTERHITPEN, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_PPC_INHIBITORS, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_CHARGE_DAMAGE, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_GLANCING_BLOWS, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_DIRECT_BLOW, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_BURST, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_HEAT, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_PARTIAL_COVER, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_BA_CRITICALS, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_HOTLOAD, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_RAPID_AC, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_KIND_RAPID_AC, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_GRAPPLING, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_JUMP_JET_ATTACK, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_TRIP_ATTACK, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_ENERGY_WEAPONS, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_GAUSS_WEAPONS, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_RETRACTABLE_BLADES, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_AMMUNITION, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_WOODS_COVER, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_VEHICLE_EFFECTIVE, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_VEHICLE_ARCS, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_VTOL_ATTACKS, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_ADVANCED_MEK_HIT_LOCATIONS, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_COOLANT_FAILURE, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_TACOPS_BA_VS_BA, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_NO_TAC, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_VEHICLES_THRESHOLD, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_VEHICLES_THRESHOLD_VARIABLE, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_VEHICLES_THRESHOLD_DIVISOR, 10); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_VTOL_STRAFING, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_VEHICLES_SAFE_FROM_INFERNOS, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_PROTOS_SAFE_FROM_INFERNOS, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_INDIRECT_ALWAYS_POSSIBLE, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_INCREASED_AC_DMG, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_UNJAM_UAC, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_UAC_TWOROLLS, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_CLUBS_PUNCH, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_ON_MAP_PREDESIGNATE, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_NUM_HEXES_PREDESIGNATE, 5); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_MAP_AREA_PREDESIGNATE, 1088); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_MAX_EXTERNAL_HEAT, 15); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_CASE_PILOT_DAMAGE, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_NO_FORCED_PRIMARY_TARGETS, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_FULL_ROTOR_HITS, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_FOREST_FIRES_NO_SMOKE, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_HOTLOAD_IN_GAME, false); + addOption(advancedCombat, OptionsConstants.ADVCOMBAT_MULTI_USE_AMS, false); + + IBasicOptionGroup advancedGroundMovement = addGroup("advancedGroundMovement"); + addOption(advancedGroundMovement, OptionsConstants.ADVGRNDMOV_TACOPS_SPRINT, false); + addOption(advancedGroundMovement, OptionsConstants.ADVGRNDMOV_TACOPS_STANDING_STILL, false); + addOption(advancedGroundMovement, OptionsConstants.ADVGRNDMOV_TACOPS_EVADE, false); + addOption(advancedGroundMovement, OptionsConstants.ADVGRNDMOV_TACOPS_SKILLED_EVASION, false); + addOption(advancedGroundMovement, OptionsConstants.ADVGRNDMOV_TACOPS_LEAPING, false); + addOption(advancedGroundMovement, OptionsConstants.ADVGRNDMOV_TACOPS_PHYSICAL_PSR, false); + addOption(advancedGroundMovement, OptionsConstants.ADVGRNDMOV_TACOPS_PHYSICAL_ATTACK_PSR, false); + addOption(advancedGroundMovement, OptionsConstants.ADVGRNDMOV_TACOPS_TAKING_DAMAGE, false); + addOption(advancedGroundMovement, OptionsConstants.ADVGRNDMOV_TACOPS_LEG_DAMAGE, false); + addOption(advancedGroundMovement, OptionsConstants.ADVGRNDMOV_TACOPS_WALK_BACKWARDS, false); + addOption(advancedGroundMovement, OptionsConstants.ADVGRNDMOV_TACOPS_FAST_INFANTRY_MOVE, false); + addOption(advancedGroundMovement, OptionsConstants.ADVANCED_TACOPS_INF_PAVE_BONUS, false); + addOption(advancedGroundMovement, OptionsConstants.ADVGRNDMOV_VEHICLE_LANCE_MOVEMENT, false); + addOption(advancedGroundMovement, OptionsConstants.ADVGRNDMOV_VEHICLE_LANCE_MOVEMENT_NUMBER, 4); + addOption(advancedGroundMovement, OptionsConstants.ADVGRNDMOV_VEHICLE_ACCELERATION, false); + addOption(advancedGroundMovement, OptionsConstants.ADVGRNDMOV_REVERSE_GEAR, false); + addOption(advancedGroundMovement, OptionsConstants.ADVGRNDMOV_TURN_MODE, false); + addOption(advancedGroundMovement, OptionsConstants.ADVGRNDMOV_VEHICLE_ADVANCED_MANEUVERS, false); + addOption(advancedGroundMovement, OptionsConstants.ADVGRNDMOV_TACOPS_HULL_DOWN, false); + addOption(advancedGroundMovement, OptionsConstants.ADVGRNDMOV_TACOPS_FALLING_EXPANDED, false); + addOption(advancedGroundMovement, OptionsConstants.ADVGRNDMOV_TACOPS_ATTEMPTING_STAND, false); + addOption(advancedGroundMovement, OptionsConstants.ADVGRNDMOV_TACOPS_CAREFUL_STAND, false); + addOption(advancedGroundMovement, OptionsConstants.ADVGRNDMOV_TACOPS_ZIPLINES, false); + addOption(advancedGroundMovement, OptionsConstants.ADVGRNDMOV_MEK_LANCE_MOVEMENT, false); + addOption(advancedGroundMovement, OptionsConstants.ADVGRNDMOV_MEK_LANCE_MOVEMENT_NUMBER, 4); + addOption(advancedGroundMovement, OptionsConstants.ADVGRNDMOV_NO_IMMOBILE_VEHICLES, false); + addOption(advancedGroundMovement, OptionsConstants.ADVGRNDMOV_VEHICLES_CAN_EJECT, false); + addOption(advancedGroundMovement, OptionsConstants.ADVGRNDMOV_EJECTED_PILOTS_FLEE, false); + addOption(advancedGroundMovement, OptionsConstants.ADVGRNDMOV_AUTO_ABANDON_UNIT, false); + addOption(advancedGroundMovement, OptionsConstants.ADVGRNDMOV_NO_HOVER_CHARGE, false); + addOption(advancedGroundMovement, OptionsConstants.ADVGRNDMOV_NO_PREMOVE_VIBRA, false); + addOption(advancedGroundMovement, OptionsConstants.ADVGRNDMOV_FALLS_END_MOVEMENT, false); + addOption(advancedGroundMovement, OptionsConstants.ADVGRNDMOV_PSR_JUMP_HEAVY_WOODS, false); + addOption(advancedGroundMovement, OptionsConstants.ADVGRNDMOV_NO_NIGHT_MOVE_PEN, false); + + IBasicOptionGroup advAeroRules = addGroup("advancedAeroRules"); + addOption(advAeroRules, OptionsConstants.ADVAERORULES_AERO_GROUND_MOVE, true); + addOption(advAeroRules, OptionsConstants.ADVAERORULES_STRATOPS_CAPITAL_FIGHTER, false); + addOption(advAeroRules, OptionsConstants.ADVAERORULES_FUEL_CONSUMPTION, false); + addOption(advAeroRules, OptionsConstants.ADVAERORULES_STRATOPS_CONV_FUSION_BONUS, false); + addOption(advAeroRules, OptionsConstants.ADVAERORULES_STRATOPS_HARJEL, false); + addOption(advAeroRules, OptionsConstants.ADVAERORULES_STRATOPS_GRAV_EFFECTS, false); + addOption(advAeroRules, OptionsConstants.ADVAERORULES_ADVANCED_MOVEMENT, false); + addOption(advAeroRules, OptionsConstants.ADVAERORULES_HEAT_BY_BAY, false); + addOption(advAeroRules, OptionsConstants.ADVAERORULES_ATMOSPHERIC_CONTROL, false); + addOption(advAeroRules, OptionsConstants.ADVAERORULES_STRATOPS_AMMO_EXPLOSIONS, false); + addOption(advAeroRules, OptionsConstants.ADVAERORULES_STRATOPS_AAA_LASER, false); + addOption(advAeroRules, OptionsConstants.ADVAERORULES_STRATOPS_ADV_POINTDEF, false); + addOption(advAeroRules, OptionsConstants.ADVAERORULES_STRATOPS_BRACKET_FIRE, false); + addOption(advAeroRules, OptionsConstants.ADVAERORULES_STRATOPS_ECM, false); + addOption(advAeroRules, OptionsConstants.ADVAERORULES_STRATOPS_SENSOR_SHADOW, false); + addOption(advAeroRules, OptionsConstants.ADVAERORULES_STRATOPS_OVER_PENETRATE, false); + addOption(advAeroRules, OptionsConstants.ADVAERORULES_STRATOPS_SPACE_BOMB, false); + addOption(advAeroRules, OptionsConstants.ADVAERORULES_STRATOPS_BEARINGS_ONLY_LAUNCH, false); + addOption(advAeroRules, OptionsConstants.ADVAERORULES_STRATOPS_BEARINGS_ONLY_VELOCITY, 50); + addOption(advAeroRules, OptionsConstants.ADVAERORULES_STRATOPS_WAYPOINT_LAUNCH, false); + addOption(advAeroRules, OptionsConstants.ADVAERORULES_STRATOPS_ADVANCED_SENSORS, false); + addOption(advAeroRules, OptionsConstants.ADVAERORULES_VARIABLE_DAMAGE_THRESH, false); + addOption(advAeroRules, OptionsConstants.ADVAERORULES_AT2_NUKES, false); + addOption(advAeroRules, OptionsConstants.ADVAERORULES_AERO_SANITY, false); + addOption(advAeroRules, OptionsConstants.ADVAERORULES_RETURN_FLYOVER, true); + addOption(advAeroRules, OptionsConstants.ADVAERORULES_STRATOPS_AA_FIRE, false); + addOption(advAeroRules, OptionsConstants.ADVAERORULES_AA_MOVE_MOD, false); + addOption(advAeroRules, OptionsConstants.ADVAERORULES_ALLOW_LARGE_SQUADRONS, false); + addOption(advAeroRules, OptionsConstants.ADVAERORULES_SINGLE_NO_CAP, false); + addOption(advAeroRules, OptionsConstants.ADVAERORULES_AERO_ARTILLERY_MUNITIONS, false); + addOption(advAeroRules, OptionsConstants.ADVAERORULES_CRASHED_DROPSHIPS_SURVIVE, false); + addOption(advAeroRules, OptionsConstants.ADVAERORULES_EXPANDED_KF_DRIVE_DAMAGE, false); + addOption(advAeroRules, OptionsConstants.UNOFF_ADV_ATMOSPHERIC_CONTROL, false); + + IBasicOptionGroup initiative = addGroup("initiative"); + addOption(initiative, OptionsConstants.INIT_INF_MOVE_EVEN, false); + addOption(initiative, OptionsConstants.INIT_INF_DEPLOY_EVEN, false); + addOption(initiative, OptionsConstants.INIT_INF_MOVE_LATER, false); + addOption(initiative, OptionsConstants.INIT_INF_MOVE_MULTI, false); + addOption(initiative, OptionsConstants.INIT_PROTOS_MOVE_EVEN, false); + addOption(initiative, OptionsConstants.INIT_PROTOS_MOVE_EVEN, false); + addOption(initiative, OptionsConstants.INIT_PROTOS_MOVE_LATER, false); + addOption(initiative, OptionsConstants.INIT_PROTOS_MOVE_MULTI, false); + addOption(initiative, OptionsConstants.INIT_INF_PROTO_MOVE_MULTI, 3); + addOption(initiative, OptionsConstants.INIT_SIMULTANEOUS_DEPLOYMENT, false); + //addOption(initiative, OptionsConstants.INIT_SIMULTANEOUS_MOVEMENT, false); + addOption(initiative, OptionsConstants.INIT_SIMULTANEOUS_TARGETING, false); + addOption(initiative, OptionsConstants.INIT_SIMULTANEOUS_FIRING, false); + addOption(initiative, OptionsConstants.INIT_SIMULTANEOUS_PHYSICAL, false); + addOption(initiative, OptionsConstants.INIT_FRONT_LOAD_INITIATIVE, false); + addOption(initiative, OptionsConstants.INIT_INITIATIVE_STREAK_COMPENSATION, false); + + IBasicOptionGroup rpg = addGroup("rpg"); + addOption(rpg, OptionsConstants.RPG_PILOT_ADVANTAGES, false); + addOption(rpg, OptionsConstants.EDGE, false); + addOption(rpg, OptionsConstants.RPG_MANEI_DOMINI, false); + addOption(rpg, OptionsConstants.RPG_INDIVIDUAL_INITIATIVE, false); + addOption(rpg, OptionsConstants.RPG_COMMAND_INIT, false); + addOption(rpg, OptionsConstants.RPG_RPG_GUNNERY, false); + addOption(rpg, OptionsConstants.RPG_ARTILLERY_SKILL, false); + addOption(rpg, OptionsConstants.RPG_TOUGHNESS, false); + addOption(rpg, OptionsConstants.RPG_CONDITIONAL_EJECTION, false); + addOption(rpg, OptionsConstants.RPG_BEGIN_SHUTDOWN, false); } public Vector loadOptions() { @@ -390,7 +346,7 @@ private IOption parseOptionNode(final IBasicOption node, final boolean print, fi if (null != tempOption) { if (!tempOption.getValue().toString() - .equals(value.toString())) { + .equals(value.toString())) { try { switch (tempOption.getType()) { case IOption.STRING: @@ -415,7 +371,7 @@ private IOption parseOptionNode(final IBasicOption node, final boolean print, fi option = tempOption; } catch (Exception ex) { logger.error(String.format( - "Error trying to load option '%s' with a value of '%s'!", name, value)); + "Error trying to load option '%s' with a value of '%s'!", name, value)); } } } else { @@ -448,7 +404,7 @@ public static void saveOptions(Vector options, String file) { marshaller.setProperty("org.glassfish.jaxb.xmlHeaders", ""); JAXBElement element = new JAXBElement<>(new QName("options"), GameOptionsXML.class, - new GameOptionsXML(options)); + new GameOptionsXML(options)); marshaller.marshal(element, new File(file)); } catch (Exception ex) { @@ -466,13 +422,8 @@ protected AbstractOptionsInfo getOptionsInfoImp() { return GameOptionsInfo.getInstance(); } - @Override - public Map getOptionsHash() { - return this.optionsHash; - } - private static class GameOptionsInfo extends AbstractOptionsInfo { - private static final AbstractOptionsInfo instance = new GameOptionsInfo(); + private static AbstractOptionsInfo instance = new GameOptionsInfo(); protected GameOptionsInfo() { super("GameOptionsInfo"); diff --git a/megamek/src/megamek/common/options/IGameOptions.java b/megamek/src/megamek/common/options/IGameOptions.java index 77d816e200..952af75ccb 100644 --- a/megamek/src/megamek/common/options/IGameOptions.java +++ b/megamek/src/megamek/common/options/IGameOptions.java @@ -30,8 +30,6 @@ public interface IGameOptions { IOptionsInfo getOptionsInfo(); - Map getOptionsHash(); - /** * Returns a string of all the quirk "codes" for this entity, using sep as * the separator diff --git a/megamek/src/megamek/common/options/Option.java b/megamek/src/megamek/common/options/Option.java index c90db5a5f2..a636e91a67 100755 --- a/megamek/src/megamek/common/options/Option.java +++ b/megamek/src/megamek/common/options/Option.java @@ -35,153 +35,10 @@ public class Option implements IOption, Serializable { private transient IOptionInfo info; - public static OptionValue of(String name, Object defaultValue) { - if (defaultValue instanceof Boolean) { - return new OptionBoolean(name, (Boolean) defaultValue); - } else if (defaultValue instanceof Integer) { - return new OptionInteger(name, (Integer) defaultValue); - } else if (defaultValue instanceof Float) { - return new OptionFloat(name, (Float) defaultValue); - } else if (defaultValue instanceof String) { - return new OptionString(name, (String) defaultValue); - } else if (defaultValue instanceof Vector) { - return new OptionChoice(name, (Vector) defaultValue); - } - throw new IllegalArgumentException("Invalid default value type"); - } - - public static abstract class OptionValue { - abstract Object getValue(); - abstract int getType(); - abstract String getName(); - } - - public static class OptionBoolean extends OptionValue { - private final boolean value; - private final String name; - - public OptionBoolean(String name, boolean value) { - this.value = value; - this.name = name; - } - - @Override - public Object getValue() { - return value; - } - @Override - public int getType() { - return BOOLEAN; - } - - @Override - public String getName() { - return name; - } - } - - public static class OptionInteger extends OptionValue { - private final String name; - private final int value; - public OptionInteger(String name, int value) { - this.value = value; - this.name = name; - } - - @Override - public Object getValue() { - return value; - } - @Override - public int getType() { - return INTEGER; - } - - @Override - public String getName() { - return name; - } - } - - public static class OptionFloat extends OptionValue { - private final String name; - private final float value; - public OptionFloat(String name, float value) { - this.value = value; - this.name = name; - } - - @Override - public Object getValue() { - return value; - } - @Override - public int getType() { - return FLOAT; - } - - @Override - public String getName() { - return name; - } - } - - public static class OptionString extends OptionValue { - private final String value; - private final String name; - public OptionString(String name, String value) { - this.value = value; - this.name = name; - } - - @Override - public Object getValue() { - return value; - } - @Override - public int getType() { - return STRING; - } - - @Override - public String getName() { - return name; - } - } - - public static class OptionChoice extends OptionValue { - // private final Vector value; - private final String name; - - public OptionChoice(String name, Vector value) { - // this.value = ""; - this.name = name; - } - - @Override - public Object getValue() { - // return value; - return ""; - } - @Override - public int getType() { - return CHOICE; - } - - @Override - public String getName() { - return name; - } - } - public Option(AbstractOptions owner, String name, String defaultValue) { this(owner, name, STRING, defaultValue); } - public Option(AbstractOptions owner, OptionValue defaultValue) { - this(owner, defaultValue.getName(), defaultValue.getType(), defaultValue.getValue()); - } - public Option(AbstractOptions owner, String name, boolean defaultValue) { this(owner, name, BOOLEAN, defaultValue); } @@ -230,7 +87,7 @@ public String getName() { public String getDisplayableNameWithValue() { updateInfo(); return info.getDisplayableName() - + ((type == IOption.INTEGER) || (type == IOption.CHOICE) ? " [" + value + "]" : ""); + + ((type == IOption.INTEGER) || (type == IOption.CHOICE) ? " [" + value + "]" : ""); } @Override diff --git a/megamek/src/megamek/common/options/PartialRepairs.java b/megamek/src/megamek/common/options/PartialRepairs.java index 194909a0db..4e3b3d092e 100644 --- a/megamek/src/megamek/common/options/PartialRepairs.java +++ b/megamek/src/megamek/common/options/PartialRepairs.java @@ -136,11 +136,6 @@ public static boolean isPartRepLegalFor(IOption quirk, Entity en) { } } - @Override - public Map getOptionsHash() { - return Map.of(); - } - private static class PartialRepairInfo extends AbstractOptionsInfo { private static AbstractOptionsInfo instance = new PartialRepairInfo(); diff --git a/megamek/src/megamek/common/options/PilotOptions.java b/megamek/src/megamek/common/options/PilotOptions.java index 861509135a..9e7a3440e1 100755 --- a/megamek/src/megamek/common/options/PilotOptions.java +++ b/megamek/src/megamek/common/options/PilotOptions.java @@ -14,8 +14,6 @@ package megamek.common.options; -import java.io.Serial; -import java.util.Map; import java.util.Vector; /** @@ -24,140 +22,162 @@ * @author Cord */ public class PilotOptions extends AbstractOptions { - - @Serial private static final long serialVersionUID = 6628080570425023949L; public static final String LVL3_ADVANTAGES = "lvl3Advantages"; public static final String EDGE_ADVANTAGES = "edgeAdvantages"; public static final String MD_ADVANTAGES = "MDAdvantages"; - private static final Option.OptionValue[] ADV_OPTIONS = { - Option.of(OptionsConstants.PILOT_ANIMAL_MIMIC, false ), - Option.of(OptionsConstants.PILOT_CROSS_COUNTRY, false ), - Option.of(OptionsConstants.PILOT_DODGE_MANEUVER, false ), - Option.of(OptionsConstants.PILOT_HVY_LIFTER, false ), - Option.of(OptionsConstants.PILOT_HOPPING_JACK, false ), - Option.of(OptionsConstants.PILOT_HOT_DOG, false ), - Option.of(OptionsConstants.PILOT_JUMPING_JACK, false ), - Option.of(OptionsConstants.PILOT_MANEUVERING_ACE, false ), - Option.of(OptionsConstants.PILOT_MELEE_MASTER, false ), - Option.of(OptionsConstants.PILOT_MELEE_SPECIALIST, false ), - Option.of(OptionsConstants.PILOT_APTITUDE_PILOTING, false ), - Option.of(OptionsConstants.PILOT_SHAKY_STICK, false ), - Option.of(OptionsConstants.PILOT_TM_FOREST_RANGER, false ), - Option.of(OptionsConstants.PILOT_TM_FROGMAN, false ), - Option.of(OptionsConstants.PILOT_TM_MOUNTAINEER, false ), - Option.of(OptionsConstants.PILOT_TM_NIGHTWALKER, false ), - Option.of(OptionsConstants.PILOT_TM_SWAMP_BEAST, false ), - Option.of(OptionsConstants.PILOT_ZWEIHANDER, false ), - - // Gunnery Abilities - Option.of(OptionsConstants.GUNNERY_BLOOD_STALKER, false ), - Option.of(OptionsConstants.GUNNERY_CLUSTER_HITTER, false ), - Option.of(OptionsConstants.GUNNERY_CLUSTER_MASTER, false ), - Option.of(OptionsConstants.GUNNERY_GOLDEN_GOOSE, false ), - Option.of(OptionsConstants.GUNNERY_SPECIALIST, new Vector() ), - Option.of(OptionsConstants.GUNNERY_MULTI_TASKER, false ), - Option.of(OptionsConstants.PILOT_APTITUDE_GUNNERY, false ), - Option.of(OptionsConstants.GUNNERY_OBLIQUE_ARTILLERY, false ), - Option.of(OptionsConstants.GUNNERY_OBLIQUE_ATTACKER, false ), - Option.of(OptionsConstants.GUNNERY_RANGE_MASTER, new Vector() ), - Option.of(OptionsConstants.GUNNERY_SANDBLASTER, new Vector() ), - Option.of(OptionsConstants.GUNNERY_SNIPER, false ), - Option.of(OptionsConstants.GUNNERY_WEAPON_SPECIALIST, new Vector() ), - - // Misc Abilities - Option.of(OptionsConstants.MISC_EAGLE_EYES, false ), - Option.of(OptionsConstants.MISC_ENV_SPECIALIST, new Vector() ), - Option.of(OptionsConstants.MISC_FORWARD_OBSERVER, false ), - Option.of(OptionsConstants.MISC_HUMAN_TRO, new Vector() ), - Option.of(OptionsConstants.MISC_IRON_MAN, false ), - Option.of(OptionsConstants.MISC_PAIN_RESISTANCE, false ), - Option.of(OptionsConstants.MISC_TACTICAL_GENIUS, false ), - - // Infantry abilities - Option.of(OptionsConstants.INFANTRY_FOOT_CAV, false ), - Option.of(OptionsConstants.INFANTRY_URBAN_GUERRILLA, false ), - - // Unofficial - Option.of(OptionsConstants.UNOFF_EI_IMPLANT, false ), - Option.of(OptionsConstants.UNOFF_GUNNERY_LASER, false ), - Option.of(OptionsConstants.UNOFF_GUNNERY_MISSILE, false ), - Option.of(OptionsConstants.UNOFF_GUNNERY_BALLISTIC, false ), - Option.of(OptionsConstants.UNOFF_CLAN_PILOT_TRAINING, false ), - Option.of(OptionsConstants.UNOFF_SOME_LIKE_IT_HOT, false ), - Option.of(OptionsConstants.UNOFF_WEATHERED, false ), - Option.of(OptionsConstants.UNOFF_ALLWEATHER, false ), - Option.of(OptionsConstants.UNOFF_BLIND_FIGHTER, false ), - Option.of(OptionsConstants.UNOFF_SENSOR_GEEK, false ), - Option.of(OptionsConstants.UNOFF_SMALL_PILOT, false ) - }; - - private static final Option.OptionValue[] EDGE_OPTIONS = { - Option.of(OptionsConstants.EDGE, 0 ), - Option.of(OptionsConstants.EDGE_WHEN_HEADHIT, true ), - Option.of(OptionsConstants.EDGE_WHEN_TAC, true ), - Option.of(OptionsConstants.EDGE_WHEN_KO, true ), - Option.of(OptionsConstants.EDGE_WHEN_EXPLOSION, true ), - Option.of(OptionsConstants.EDGE_WHEN_MASC_FAILS, true ), - Option.of(OptionsConstants.EDGE_WHEN_AERO_ALT_LOSS, true ), - Option.of(OptionsConstants.EDGE_WHEN_AERO_EXPLOSION, true ), - Option.of(OptionsConstants.EDGE_WHEN_AERO_KO, true ), - Option.of(OptionsConstants.EDGE_WHEN_AERO_LUCKY_CRIT, true ), - Option.of(OptionsConstants.EDGE_WHEN_AERO_NUKE_CRIT, true ), - Option.of(OptionsConstants.EDGE_WHEN_AERO_UNIT_CARGO_LOST, true) - }; - - private static final Option.OptionValue[] MD_OPTIONS = { - Option.of(OptionsConstants.MD_PAIN_SHUNT, false ), - Option.of(OptionsConstants.MD_COMM_IMPLANT, false ), - Option.of(OptionsConstants.MD_BOOST_COMM_IMPLANT, false ), - Option.of(OptionsConstants.MD_CYBER_IMP_AUDIO, false ), - Option.of(OptionsConstants.MD_CYBER_IMP_VISUAL, false ), - Option.of(OptionsConstants.MD_CYBER_IMP_LASER, false ), - Option.of(OptionsConstants.MD_MM_IMPLANTS, false ), - Option.of(OptionsConstants.MD_ENH_MM_IMPLANTS, false ), - Option.of(OptionsConstants.MD_FILTRATION, false ), - Option.of(OptionsConstants.MD_GAS_EFFUSER_PHERO, false ), - Option.of(OptionsConstants.MD_GAS_EFFUSER_TOXIN, false ), - Option.of(OptionsConstants.MD_DERMAL_ARMOR, false ), - Option.of(OptionsConstants.MD_DERMAL_CAMO_ARMOR, false ), - Option.of(OptionsConstants.MD_TSM_IMPLANT, false ), - Option.of(OptionsConstants.MD_TRIPLE_CORE_PROCESSOR, false ), - Option.of(OptionsConstants.MD_VDNI, false ), - Option.of(OptionsConstants.MD_BVDNI, false ), - Option.of(OptionsConstants.MD_PROTO_DNI, false ), - Option.of(OptionsConstants.MD_PL_ENHANCED, false ), - Option.of(OptionsConstants.MD_PL_IENHANCED, false ), - Option.of(OptionsConstants.MD_PL_EXTRA_LIMBS, false ), - Option.of(OptionsConstants.MD_PL_TAIL, false ), - Option.of(OptionsConstants.MD_PL_MASC, false ), - Option.of(OptionsConstants.MD_PL_GLIDER, false ), - Option.of(OptionsConstants.MD_PL_FLIGHT, false ), - Option.of(OptionsConstants.MD_SUICIDE_IMPLANTS, false) - }; - public PilotOptions() { super(); } @Override public void initialize() { - var optionsInfo = PilotOptionsInfo.getInstance(); - IBasicOptionGroup advGroup = optionsInfo.addGroup(OptionsConstants.ADV, LVL3_ADVANTAGES); - IBasicOptionGroup edgeGroup = optionsInfo.addGroup(OptionsConstants.EDGE, EDGE_ADVANTAGES); - IBasicOptionGroup mdGroup = optionsInfo.addGroup(OptionsConstants.MD, MD_ADVANTAGES); - - addOptions(optionsInfo, advGroup, ADV_OPTIONS); - addOptions(optionsInfo, edgeGroup, EDGE_OPTIONS); - addOptions(optionsInfo, mdGroup, MD_OPTIONS); - } + IBasicOptionGroup adv = addGroup("adv", LVL3_ADVANTAGES); + + addOption(adv, OptionsConstants.PILOT_ANIMAL_MIMIC, false); + addOption(adv, OptionsConstants.PILOT_CROSS_COUNTRY, false); + addOption(adv, OptionsConstants.PILOT_DODGE_MANEUVER, false); + // addOption(adv, OptionsConstants.PILOT_DUST_OFF, false); + addOption(adv, OptionsConstants.PILOT_HVY_LIFTER, false); + // addOption(adv, OptionsConstants.PILOT_HOPPER, false); + addOption(adv, OptionsConstants.PILOT_HOPPING_JACK, false); + addOption(adv, OptionsConstants.PILOT_HOT_DOG, false); + addOption(adv, OptionsConstants.PILOT_JUMPING_JACK, false); + addOption(adv, OptionsConstants.PILOT_MANEUVERING_ACE, false); + addOption(adv, OptionsConstants.PILOT_MELEE_MASTER, false); + addOption(adv, OptionsConstants.PILOT_MELEE_SPECIALIST, false); + addOption(adv, OptionsConstants.PILOT_APTITUDE_PILOTING, false); + // addOption(adv, OptionsConstants.PILOT_NATURAL_GRACE, false); + // addOption(adv, OptionsConstants.PILOT_RIDE_WASH, false); + addOption(adv, OptionsConstants.PILOT_SHAKY_STICK, false); + // addOption(adv, OptionsConstants.PILOT_SLUGGER, false); + // addOption(adv, OptionsConstants.PILOT_SPEED_DEMON, false); + // addOption(adv, OptionsConstants.PILOT_STAND_ASIDE, false); + // addOption(adv, OptionsConstants.PILOT_SWORDSMAN, false); + // addOption(adv, OptionsConstants.PILOT_TM_, false); + addOption(adv, OptionsConstants.PILOT_TM_FOREST_RANGER, false); + addOption(adv, OptionsConstants.PILOT_TM_FROGMAN, false); + addOption(adv, OptionsConstants.PILOT_TM_MOUNTAINEER, false); + addOption(adv, OptionsConstants.PILOT_TM_NIGHTWALKER, false); + addOption(adv, OptionsConstants.PILOT_TM_SWAMP_BEAST, false); + // addOption(adv, OptionsConstants.PILOT_WIND_WALKER, false); + addOption(adv, OptionsConstants.PILOT_ZWEIHANDER, false); - private void addOptions(AbstractOptionsInfo optionsInfo, IBasicOptionGroup group, Option.OptionValue[] options) { - for (var entry : options) { - optionsHash.put(entry.getName(), new Option(this, entry.getName(), entry.getType(), entry.getValue())); - optionsInfo.addOptionInfo(group, entry.getName()); - } + // Gunnery Abilities + addOption(adv, OptionsConstants.GUNNERY_BLOOD_STALKER, false); + addOption(adv, OptionsConstants.GUNNERY_CLUSTER_HITTER, false); + addOption(adv, OptionsConstants.GUNNERY_CLUSTER_MASTER, false); + // addOption(adv, OptionsConstants.GUNNERY_FIST_FIRE, false); + addOption(adv, OptionsConstants.GUNNERY_GOLDEN_GOOSE, false); + // addOption(adv, OptionsConstants.GUNNERY_GROUND_HUGGER, false); + addOption(adv, OptionsConstants.GUNNERY_SPECIALIST, new Vector<>()); + // addOption(adv, OptionsConstants.GUNNERY_MARKSMAN, false); + addOption(adv, OptionsConstants.GUNNERY_MULTI_TASKER, false); + addOption(adv, OptionsConstants.PILOT_APTITUDE_GUNNERY, false); + addOption(adv, OptionsConstants.GUNNERY_OBLIQUE_ARTILLERY, false); + addOption(adv, OptionsConstants.GUNNERY_OBLIQUE_ATTACKER, false); + addOption(adv, OptionsConstants.GUNNERY_RANGE_MASTER, new Vector<>()); + addOption(adv, OptionsConstants.GUNNERY_SANDBLASTER, new Vector<>()); + // addOption(adv, OptionsConstants.GUNNERY_SHARPSHOOTER, false); + addOption(adv, OptionsConstants.GUNNERY_SNIPER, false); + addOption(adv, OptionsConstants.GUNNERY_WEAPON_SPECIALIST, new Vector<>()); + + // Misc Abilities + // addOption(adv, OptionsConstants.MISC_ANTAGONIZER, false); + // addOption(adv, OptionsConstants.MISC_COMBAT_INTUITION, false); + // addOption(adv, OptionsConstants.MISC_DEMORALIZER, false); + addOption(adv, OptionsConstants.MISC_EAGLE_EYES, false); + addOption(adv, OptionsConstants.MISC_ENV_SPECIALIST, new Vector<>()); + addOption(adv, OptionsConstants.MISC_FORWARD_OBSERVER, false); + addOption(adv, OptionsConstants.MISC_HUMAN_TRO, new Vector<>()); + addOption(adv, OptionsConstants.MISC_IRON_MAN, false); + addOption(adv, OptionsConstants.MISC_PAIN_RESISTANCE, false); + addOption(adv, OptionsConstants.MISC_TACTICAL_GENIUS, false); + + // Infantry abilities - Only one until beast mounts are implemented + addOption(adv, OptionsConstants.INFANTRY_FOOT_CAV, false); + addOption(adv, OptionsConstants.INFANTRY_URBAN_GUERRILLA, false); + + // Unofficial + addOption(adv, OptionsConstants.UNOFF_EI_IMPLANT, false); + addOption(adv, OptionsConstants.UNOFF_GUNNERY_LASER, false); + addOption(adv, OptionsConstants.UNOFF_GUNNERY_MISSILE, false); + addOption(adv, OptionsConstants.UNOFF_GUNNERY_BALLISTIC, false); + addOption(adv, OptionsConstants.UNOFF_CLAN_PILOT_TRAINING, false); + addOption(adv, OptionsConstants.UNOFF_SOME_LIKE_IT_HOT, false); + addOption(adv, OptionsConstants.UNOFF_WEATHERED, false); + addOption(adv, OptionsConstants.UNOFF_ALLWEATHER, false); + addOption(adv, OptionsConstants.UNOFF_BLIND_FIGHTER, false); + addOption(adv, OptionsConstants.UNOFF_SENSOR_GEEK, false); + addOption(adv, OptionsConstants.UNOFF_SMALL_PILOT, false); + + IBasicOptionGroup edge = addGroup("edge", EDGE_ADVANTAGES); + addOption(edge, "edge", 0); + /* different edge triggers */ + // Mek Triggers + addOption(edge, "edge_when_headhit", true); + addOption(edge, "edge_when_tac", true); + addOption(edge, "edge_when_ko", true); + addOption(edge, "edge_when_explosion", true); + addOption(edge, "edge_when_masc_fails", true); + //Aero Triggers + addOption(edge, "edge_when_aero_alt_loss", true); + addOption(edge, "edge_when_aero_explosion", true); + addOption(edge, "edge_when_aero_ko", true); + addOption(edge, "edge_when_aero_lucky_crit", true); + addOption(edge, "edge_when_aero_nuke_crit", true); + addOption(edge, "edge_when_aero_unit_cargo_lost", true); + + addOption(edge, OptionsConstants.EDGE, 0); + // different edge triggers + //Mek Triggers + addOption(edge, OptionsConstants.EDGE_WHEN_HEADHIT, true); + addOption(edge, OptionsConstants.EDGE_WHEN_TAC, true); + addOption(edge, OptionsConstants.EDGE_WHEN_KO, true); + addOption(edge, OptionsConstants.EDGE_WHEN_EXPLOSION, true); + addOption(edge, OptionsConstants.EDGE_WHEN_MASC_FAILS, true); + //Aero Triggers + addOption(edge, OptionsConstants.EDGE_WHEN_AERO_ALT_LOSS, true); + addOption(edge, OptionsConstants.EDGE_WHEN_AERO_EXPLOSION, true); + addOption(edge, OptionsConstants.EDGE_WHEN_AERO_KO, true); + addOption(edge, OptionsConstants.EDGE_WHEN_AERO_LUCKY_CRIT, true); + addOption(edge, OptionsConstants.EDGE_WHEN_AERO_NUKE_CRIT, true); + addOption(edge, OptionsConstants.EDGE_WHEN_AERO_UNIT_CARGO_LOST, true); + + // manei domini + IBasicOptionGroup md = addGroup("md", MD_ADVANTAGES); + addOption(md, OptionsConstants.MD_PAIN_SHUNT, false); + addOption(md, OptionsConstants.MD_COMM_IMPLANT, false); + //TODO - -1 bonus when spotting for LRMs and moving through mines. + addOption(md, OptionsConstants.MD_BOOST_COMM_IMPLANT, false); + //TODO - -1 bonus when spotting for LRMs and moving through mines. + addOption(md, OptionsConstants.MD_CYBER_IMP_AUDIO, false); + addOption(md, OptionsConstants.MD_CYBER_IMP_VISUAL, false); + addOption(md, OptionsConstants.MD_CYBER_IMP_LASER, false); + addOption(md, OptionsConstants.MD_MM_IMPLANTS, false); + addOption(md, OptionsConstants.MD_ENH_MM_IMPLANTS, false); + addOption(md, OptionsConstants.MD_FILTRATION, false); + addOption(md, OptionsConstants.MD_GAS_EFFUSER_PHERO, false); + addOption(md, OptionsConstants.MD_GAS_EFFUSER_TOXIN, false); + addOption(md, OptionsConstants.MD_DERMAL_ARMOR, false); + addOption(md, OptionsConstants.MD_DERMAL_CAMO_ARMOR, false); + addOption(md, OptionsConstants.MD_TSM_IMPLANT, false); + addOption(md, OptionsConstants.MD_TRIPLE_CORE_PROCESSOR, false); + addOption(md, OptionsConstants.MD_VDNI, false); + addOption(md, OptionsConstants.MD_BVDNI, false); + addOption(md, OptionsConstants.MD_PROTO_DNI, false); + //Prosthetic Limbs (not MD Exclusive) + addOption(md, OptionsConstants.MD_PL_ENHANCED, false); + addOption(md, OptionsConstants.MD_PL_IENHANCED, false); + addOption(md, OptionsConstants.MD_PL_EXTRA_LIMBS, false); + addOption(md, OptionsConstants.MD_PL_TAIL, false); + addOption(md, OptionsConstants.MD_PL_MASC, false); + addOption(md, OptionsConstants.MD_PL_GLIDER, false); + addOption(md, OptionsConstants.MD_PL_FLIGHT, false); + addOption(md, OptionsConstants.MD_SUICIDE_IMPLANTS, false); + + //TODO - Prototype DNI IO pg 83 } /* @@ -170,18 +190,13 @@ protected AbstractOptionsInfo getOptionsInfoImp() { return PilotOptionsInfo.getInstance(); } - @Override - public Map getOptionsHash() { - return Map.of(); - } - private static class PilotOptionsInfo extends AbstractOptionsInfo { - private static boolean initialized = false; - private static final AbstractOptionsInfo instance = new PilotOptionsInfo(); + private static boolean initliazed = false; + private static AbstractOptionsInfo instance = new PilotOptionsInfo(); public static AbstractOptionsInfo getInstance() { - if (!initialized) { - initialized = true; + if (!initliazed) { + initliazed = true; // Create a new dummy PilotOptions; ensures values initialized // Otherwise, could have issues when loading saved games new PilotOptions(); diff --git a/megamek/src/megamek/common/options/Quirks.java b/megamek/src/megamek/common/options/Quirks.java index 876f70ccc0..9f7547b262 100644 --- a/megamek/src/megamek/common/options/Quirks.java +++ b/megamek/src/megamek/common/options/Quirks.java @@ -13,14 +13,12 @@ */ package megamek.common.options; -import megamek.common.*; +import static java.util.stream.Collectors.toList; +import static megamek.common.options.OptionsConstants.*; -import java.io.Serial; import java.util.List; -import java.util.Map; -import static java.util.stream.Collectors.toList; -import static megamek.common.options.OptionsConstants.*; +import megamek.common.*; /** * Contains the options determining Unit Quirks of a unit (but not weapon quirks). When changing this, note @@ -29,173 +27,126 @@ * @author Taharqa (Jay Lawson) */ public class Quirks extends AbstractOptions { - @Serial private static final long serialVersionUID = 7618380522964885740L; public static final String POS_QUIRKS = "PosQuirks"; public static final String NEG_QUIRKS = "NegQuirks"; - //not yet implemented - //Docking Arms (docking unimplemented) - //Fast Reload (no game effect at present) - //Improved Communications - //Variable Range Targeting - //VTOL Rotor Arrangement (no vee adv move rules) - //Compact Mek - - //quirks not implemented yet - //Exposed Weapon Linkage (weapon-specific, sort of) - //Gas Hog - //Large Dropship (no docking) - //Un-streamlined - //Weak Head Armor - //Weak Undercarriage (no landing) - //Ramshackle - public enum QuirkCategory { - POSITIVE, NEGATIVE - } - - public enum Quirk { - // Positive quirks - QUIRK_POS_ANIMALISTIC("animalistic", QuirkCategory.POSITIVE), - QUIRK_POS_ANTI_AIR("anti_air", QuirkCategory.POSITIVE), - QUIRK_POS_ATMO_FLYER("atmo_flyer", QuirkCategory.POSITIVE), - QUIRK_POS_BATTLE_COMP("battle_computer", QuirkCategory.POSITIVE), - QUIRK_POS_BARREL_FIST_LA("barrel_fists_la", QuirkCategory.POSITIVE), - QUIRK_POS_BARREL_FIST_RA("barrel_fists_ra", QuirkCategory.POSITIVE), - QUIRK_POS_BATTLE_FIST_LA("battle_fists_la", QuirkCategory.POSITIVE), - QUIRK_POS_BATTLE_FIST_RA("battle_fists_ra", QuirkCategory.POSITIVE), - QUIRK_POS_COMBAT_COMPUTER("combat_computer", QuirkCategory.POSITIVE), - QUIRK_POS_COMMAND_MEK("command_mech", QuirkCategory.POSITIVE), - QUIRK_POS_COMPACT("compact_mech", QuirkCategory.POSITIVE), - QUIRK_POS_COWL("cowl", QuirkCategory.POSITIVE), - QUIRK_POS_DIRECTIONAL_TORSO_MOUNT("directional_torso_mount", QuirkCategory.POSITIVE), - QUIRK_POS_DISTRACTING("distracting", QuirkCategory.POSITIVE), - QUIRK_POS_DOCKING_ARMS("docking_arms", QuirkCategory.POSITIVE), - QUIRK_POS_EASY_MAINTAIN("easy_maintain", QuirkCategory.POSITIVE), - QUIRK_POS_EASY_PILOT("easy_pilot", QuirkCategory.POSITIVE), - QUIRK_POS_EXT_TWIST("ext_twist", QuirkCategory.POSITIVE), - QUIRK_POS_FAST_RELOAD("fast_reload", QuirkCategory.POSITIVE), - QUIRK_POS_FINE_MANIPULATORS("fine_manipulators", QuirkCategory.POSITIVE), - QUIRK_POS_GOOD_REP_1("good_rep_1", QuirkCategory.POSITIVE), - QUIRK_POS_GOOD_REP_2("good_rep_2", QuirkCategory.POSITIVE), - QUIRK_POS_HYPER_ACTUATOR("hyper_actuator", QuirkCategory.POSITIVE), - QUIRK_POS_IMP_COM("imp_com", QuirkCategory.POSITIVE), - QUIRK_POS_IMP_LIFE_SUPPORT("imp_life_support", QuirkCategory.POSITIVE), - QUIRK_POS_IMP_TARG_L("imp_target_long", QuirkCategory.POSITIVE), - QUIRK_POS_IMP_TARG_M("imp_target_med", QuirkCategory.POSITIVE), - QUIRK_POS_IMP_TARG_S("imp_target_short", QuirkCategory.POSITIVE), - QUIRK_POS_IMPROVED_SENSORS("imp_sensors", QuirkCategory.POSITIVE), - QUIRK_POS_INTERNAL_BOMB("internal_bomb", QuirkCategory.POSITIVE), - QUIRK_POS_LOW_PROFILE("low_profile", QuirkCategory.POSITIVE), - QUIRK_POS_MULTI_TRAC("multi_trac", QuirkCategory.POSITIVE), - QUIRK_POS_NIMBLE_JUMPER("nimble_jumper", QuirkCategory.POSITIVE), - QUIRK_POS_OVERHEAD_ARMS("overhead_arms", QuirkCategory.POSITIVE), - QUIRK_POS_POWER_REVERSE("power_reverse", QuirkCategory.POSITIVE), - QUIRK_POS_PRO_ACTUATOR("pro_actuator", QuirkCategory.POSITIVE), - QUIRK_POS_REINFORCED_LEGS("reinforced_legs", QuirkCategory.POSITIVE), - QUIRK_POS_RUGGED_1("rugged_1", QuirkCategory.POSITIVE), - QUIRK_POS_RUGGED_2("rugged_2", QuirkCategory.POSITIVE), - QUIRK_POS_RUMBLE_SEAT("rumble_seat", QuirkCategory.POSITIVE), - QUIRK_POS_SCOUT_BIKE("scout_bike", QuirkCategory.POSITIVE), - QUIRK_POS_SEARCHLIGHT("searchlight", QuirkCategory.POSITIVE), - QUIRK_POS_STABLE("stable", QuirkCategory.POSITIVE), - QUIRK_POS_TRAILER_HITCH("trailer_hitch", QuirkCategory.POSITIVE), - QUIRK_POS_UBIQUITOUS_IS("ubiquitous_is", QuirkCategory.POSITIVE), - QUIRK_POS_UBIQUITOUS_CLAN("ubiquitous_clan", QuirkCategory.POSITIVE), - QUIRK_POS_VAR_RNG_TARG_L("variable_range_long", QuirkCategory.POSITIVE), - QUIRK_POS_VAR_RNG_TARG_S("variable_range_short", QuirkCategory.POSITIVE), - QUIRK_POS_VESTIGIAL_HANDS_LA("vestigial_hands_la", QuirkCategory.POSITIVE), - QUIRK_POS_VESTIGIAL_HANDS_RA("vestigial_hands_ra", QuirkCategory.POSITIVE), - QUIRK_POS_VTOL_ROTOR_COAXIAL("vtol_rotor_coaxial", QuirkCategory.POSITIVE), - QUIRK_POS_VTOL_ROTOR_DUAL("vtol_rotor_dual", QuirkCategory.POSITIVE), - - // Negative quirks - QUIRK_NEG_ATMO_INSTABILITY("atmo_instability", QuirkCategory.NEGATIVE), - QUIRK_NEG_BAD_REP_IS("bad_rep_is", QuirkCategory.NEGATIVE), - QUIRK_NEG_BAD_REP_CLAN("bad_rep_clan", QuirkCategory.NEGATIVE), - QUIRK_NEG_CRAMPED_COCKPIT("cramped_cockpit", QuirkCategory.NEGATIVE), - QUIRK_NEG_DIFFICULT_EJECT("difficult_eject", QuirkCategory.NEGATIVE), - QUIRK_NEG_DIFFICULT_MAINTAIN("difficult_maintain", QuirkCategory.NEGATIVE), - QUIRK_NEG_EM_INTERFERENCE_WHOLE("em_inter_whole", QuirkCategory.NEGATIVE), - QUIRK_NEG_EXP_ACTUATOR("exp_actuator", QuirkCategory.NEGATIVE), - QUIRK_NEG_FLAWED_COOLING("flawed_cooling", QuirkCategory.NEGATIVE), - QUIRK_NEG_FRAGILE_FUEL("fragile_fuel", QuirkCategory.NEGATIVE), - QUIRK_NEG_GAS_HOG("gas_hog", QuirkCategory.NEGATIVE), - QUIRK_NEG_HARD_PILOT("hard_pilot", QuirkCategory.NEGATIVE), - QUIRK_NEG_ILLEGAL_DESIGN("illegal_design", QuirkCategory.NEGATIVE), - QUIRK_NEG_LARGE_DROPPER("large_dropper", QuirkCategory.NEGATIVE), - QUIRK_NEG_LOW_ARMS("low_arms", QuirkCategory.NEGATIVE), - QUIRK_NEG_NO_ARMS("no_arms", QuirkCategory.NEGATIVE), - QUIRK_NEG_NO_EJECT("no_eject", QuirkCategory.NEGATIVE), - QUIRK_NEG_NO_TWIST("no_twist", QuirkCategory.NEGATIVE), - QUIRK_NEG_NON_STANDARD("non_standard", QuirkCategory.NEGATIVE), - QUIRK_NEG_OBSOLETE("obsolete", QuirkCategory.NEGATIVE), - QUIRK_NEG_OVERSIZED("oversized", QuirkCategory.NEGATIVE), - QUIRK_NEG_POOR_LIFE_SUPPORT("poor_life_support", QuirkCategory.NEGATIVE), - QUIRK_NEG_POOR_PERFORMANCE("poor_performance", QuirkCategory.NEGATIVE), - QUIRK_NEG_POOR_SEALING("poor_sealing", QuirkCategory.NEGATIVE), - QUIRK_NEG_POOR_TARG_L("poor_target_long", QuirkCategory.NEGATIVE), - QUIRK_NEG_POOR_TARG_M("poor_target_med", QuirkCategory.NEGATIVE), - QUIRK_NEG_POOR_TARG_S("poor_target_short", QuirkCategory.NEGATIVE), - QUIRK_NEG_POOR_WORK("poor_work", QuirkCategory.NEGATIVE), - QUIRK_NEG_PROTOTYPE("prototype", QuirkCategory.NEGATIVE), - QUIRK_NEG_RAMSHACKLE("ramshackle", QuirkCategory.NEGATIVE), - QUIRK_NEG_SENSOR_GHOSTS("sensor_ghosts", QuirkCategory.NEGATIVE), - QUIRK_NEG_SUSCEPTIBLE_CWS("susceptible_cws", QuirkCategory.NEGATIVE), - QUIRK_NEG_UNBALANCED("unbalanced", QuirkCategory.NEGATIVE), - QUIRK_NEG_UNSTREAMLINED("unstreamlined", QuirkCategory.NEGATIVE), - QUIRK_NEG_WEAK_HEAD_1("weak_head_1", QuirkCategory.NEGATIVE), - QUIRK_NEG_WEAK_HEAD_2("weak_head_2", QuirkCategory.NEGATIVE), - QUIRK_NEG_WEAK_HEAD_3("weak_head_3", QuirkCategory.NEGATIVE), - QUIRK_NEG_WEAK_HEAD_4("weak_head_4", QuirkCategory.NEGATIVE), - QUIRK_NEG_WEAK_HEAD_5("weak_head_5", QuirkCategory.NEGATIVE), - QUIRK_NEG_WEAK_LEGS("weak_legs", QuirkCategory.NEGATIVE), - QUIRK_NEG_WEAK_UNDERCARRIAGE("weak_undercarriage", QuirkCategory.NEGATIVE); - - private final QuirkCategory category; - private final String identifier; - - Quirk(String identifier, QuirkCategory category) { - this.identifier = identifier; - this.category = category; - } - - public QuirkCategory getCategory() { - return category; - } - - public String getIdentifier() { - return identifier; - } - - public static Quirk fromIdentifier(String id) { - for (Quirk q : values()) { - if (q.identifier.equals(id)) { - return q; - } - } - throw new IllegalArgumentException("Unknown quirk identifier: " + id); - } - } - @Override public synchronized void initialize() { - var optionInfo = getOptionsInfoImp(); IBasicOptionGroup posQuirk = addGroup("pos_quirks", POS_QUIRKS); - IBasicOptionGroup negQuirk = addGroup("neg_quirks", NEG_QUIRKS); + addOption(posQuirk, QUIRK_POS_ANIMALISTIC, false); + addOption(posQuirk, QUIRK_POS_ANTI_AIR, false); + addOption(posQuirk, QUIRK_POS_ATMO_FLYER, false); + addOption(posQuirk, QUIRK_POS_BATTLE_COMP, false); + addOption(posQuirk, QUIRK_POS_BARREL_FIST_LA, false); + addOption(posQuirk, QUIRK_POS_BARREL_FIST_RA, false); + addOption(posQuirk, QUIRK_POS_BATTLE_FIST_LA, false); + addOption(posQuirk, QUIRK_POS_BATTLE_FIST_RA, false); + addOption(posQuirk, QUIRK_POS_COMBAT_COMPUTER, false); + addOption(posQuirk, QUIRK_POS_COMMAND_MEK, false); + addOption(posQuirk, QUIRK_POS_COMPACT, false); + addOption(posQuirk, QUIRK_POS_COWL, false); + addOption(posQuirk, QUIRK_POS_DIRECTIONAL_TORSO_MOUNT, false); + addOption(posQuirk, QUIRK_POS_DISTRACTING, false); + addOption(posQuirk, QUIRK_POS_DOCKING_ARMS, false); + addOption(posQuirk, QUIRK_POS_EASY_MAINTAIN, false); + addOption(posQuirk, QUIRK_POS_EASY_PILOT, false); + addOption(posQuirk, QUIRK_POS_EXT_TWIST, false); + addOption(posQuirk, QUIRK_POS_FAST_RELOAD, false); + addOption(posQuirk, QUIRK_POS_FINE_MANIPULATORS, false); + addOption(posQuirk, QUIRK_POS_GOOD_REP_1, false); + addOption(posQuirk, QUIRK_POS_GOOD_REP_2, false); + addOption(posQuirk, QUIRK_POS_HYPER_ACTUATOR, false); + addOption(posQuirk, QUIRK_POS_IMP_COM, false); + addOption(posQuirk, QUIRK_POS_IMP_LIFE_SUPPORT, false); + addOption(posQuirk, QUIRK_POS_IMP_TARG_L, false); + addOption(posQuirk, QUIRK_POS_IMP_TARG_M, false); + addOption(posQuirk, QUIRK_POS_IMP_TARG_S, false); + addOption(posQuirk, QUIRK_POS_IMPROVED_SENSORS, false); + addOption(posQuirk, QUIRK_POS_INTERNAL_BOMB, false); + addOption(posQuirk, QUIRK_POS_LOW_PROFILE, false); + addOption(posQuirk, QUIRK_POS_MULTI_TRAC, false); + addOption(posQuirk, QUIRK_POS_NIMBLE_JUMPER, false); + addOption(posQuirk, QUIRK_POS_OVERHEAD_ARMS, false); + addOption(posQuirk, QUIRK_POS_POWER_REVERSE, false); + addOption(posQuirk, QUIRK_POS_PRO_ACTUATOR, false); + addOption(posQuirk, QUIRK_POS_REINFORCED_LEGS, false); + addOption(posQuirk, QUIRK_POS_RUGGED_1, false); + addOption(posQuirk, QUIRK_POS_RUGGED_2, false); + addOption(posQuirk, QUIRK_POS_RUMBLE_SEAT, false); + addOption(posQuirk, QUIRK_POS_SCOUT_BIKE, false); + addOption(posQuirk, QUIRK_POS_SEARCHLIGHT, false); + addOption(posQuirk, QUIRK_POS_STABLE, false); + addOption(posQuirk, QUIRK_POS_TRAILER_HITCH, false); + addOption(posQuirk, QUIRK_POS_UBIQUITOUS_IS, false); + addOption(posQuirk, QUIRK_POS_UBIQUITOUS_CLAN, false); + addOption(posQuirk, QUIRK_POS_VAR_RNG_TARG_L, false); + addOption(posQuirk, QUIRK_POS_VAR_RNG_TARG_S, false); + addOption(posQuirk, QUIRK_POS_VESTIGIAL_HANDS_LA, false); + addOption(posQuirk, QUIRK_POS_VESTIGIAL_HANDS_RA, false); + addOption(posQuirk, QUIRK_POS_VTOL_ROTOR_COAXIAL, false); + addOption(posQuirk, QUIRK_POS_VTOL_ROTOR_DUAL, false); + + + //not yet implemented + //Docking Arms (docking unimplemented) + //Fast Reload (no game effect at present) + //Improved Communications + //Variable Range Targeting + //VTOL Rotor Arrangement (no vee adv move rules) + //Compact Mek - for (Quirk q : Quirk.values()) { - if (q.getCategory() == QuirkCategory.POSITIVE) { - addOption(optionInfo, posQuirk, q.getIdentifier()); - } else { - addOption(optionInfo, negQuirk, q.getIdentifier()); - } - } - } - - private void addOption(AbstractOptionsInfo quirksInfo, IBasicOptionGroup group, String name) { - optionsHash.put(name, new Option(this, name, IOption.BOOLEAN, false)); - quirksInfo.addOptionInfo(group, name); + IBasicOptionGroup negQuirk = addGroup("neg_quirks", NEG_QUIRKS); + addOption(negQuirk, QUIRK_NEG_BAD_REP_IS, false); + addOption(negQuirk, QUIRK_NEG_BAD_REP_CLAN, false); + addOption(negQuirk, QUIRK_NEG_CRAMPED_COCKPIT, false); + addOption(negQuirk, QUIRK_NEG_DIFFICULT_EJECT, false); + addOption(negQuirk, QUIRK_NEG_DIFFICULT_MAINTAIN, false); + addOption(negQuirk, QUIRK_NEG_EM_INTERFERENCE_WHOLE, false); + addOption(negQuirk, QUIRK_NEG_EXP_ACTUATOR, false); + addOption(negQuirk, QUIRK_NEG_FLAWED_COOLING, false); + addOption(negQuirk, QUIRK_NEG_FRAGILE_FUEL, false); + addOption(negQuirk, QUIRK_NEG_GAS_HOG, false); + addOption(negQuirk, QUIRK_NEG_HARD_PILOT, false); + addOption(negQuirk, QUIRK_NEG_ILLEGAL_DESIGN, false); + addOption(negQuirk, QUIRK_NEG_LARGE_DROPPER, false); + addOption(negQuirk, QUIRK_NEG_LOW_ARMS, false); + addOption(negQuirk, QUIRK_NEG_NO_ARMS, false); + addOption(negQuirk, QUIRK_NEG_NO_EJECT, false); + addOption(negQuirk, QUIRK_NEG_NO_TWIST, false); + addOption(negQuirk, QUIRK_NEG_NON_STANDARD, false); + addOption(negQuirk, QUIRK_NEG_OBSOLETE, false); + addOption(negQuirk, QUIRK_NEG_POOR_LIFE_SUPPORT, false); + addOption(negQuirk, QUIRK_NEG_POOR_PERFORMANCE, false); + addOption(negQuirk, QUIRK_NEG_POOR_SEALING, false); + addOption(negQuirk, QUIRK_NEG_POOR_TARG_L, false); + addOption(negQuirk, QUIRK_NEG_POOR_TARG_M, false); + addOption(negQuirk, QUIRK_NEG_POOR_TARG_S, false); + addOption(negQuirk, QUIRK_NEG_POOR_WORK, false); + addOption(negQuirk, QUIRK_NEG_PROTOTYPE, false); + addOption(negQuirk, QUIRK_NEG_RAMSHACKLE, false); + addOption(negQuirk, QUIRK_NEG_SENSOR_GHOSTS, false); + addOption(negQuirk, QUIRK_NEG_SUSCEPTIBLE_CWS, false); + addOption(negQuirk, QUIRK_NEG_UNBALANCED, false); + addOption(negQuirk, QUIRK_NEG_UNSTREAMLINED, false); + addOption(negQuirk, QUIRK_NEG_WEAK_HEAD_1, false); + addOption(negQuirk, QUIRK_NEG_WEAK_HEAD_2, false); + addOption(negQuirk, QUIRK_NEG_WEAK_HEAD_3, false); + addOption(negQuirk, QUIRK_NEG_WEAK_HEAD_4, false); + addOption(negQuirk, QUIRK_NEG_WEAK_HEAD_5, false); + addOption(negQuirk, QUIRK_NEG_WEAK_LEGS, false); + addOption(negQuirk, QUIRK_NEG_WEAK_UNDERCARRIAGE, false); + addOption(negQuirk, QUIRK_NEG_ATMO_INSTABILITY, false); + addOption(negQuirk, QUIRK_NEG_OVERSIZED, false); + + //quirks not implemented yet + //Exposed Weapon Linkage (weapon-specific, sort of) + //Gas Hog + //Large Dropship (no docking) + //Un-streamlined + //Weak Head Armor + //Weak Undercarriage (no landing) + //Ramshackle } @Override @@ -290,20 +241,20 @@ public static boolean isQuirkIllegalFor(IOption quirk, Entity en) { if (en instanceof Aero) { if (quirk.isAnyOf( - QUIRK_POS_ATMO_FLYER, QUIRK_POS_COMBAT_COMPUTER, QUIRK_POS_EASY_MAINTAIN, - QUIRK_POS_EASY_PILOT, QUIRK_POS_GOOD_REP_1, QUIRK_POS_GOOD_REP_2, - QUIRK_POS_IMP_COM, QUIRK_POS_IMP_LIFE_SUPPORT, QUIRK_POS_IMP_TARG_L, - QUIRK_POS_IMP_TARG_M, QUIRK_POS_IMP_TARG_S, QUIRK_POS_INTERNAL_BOMB, - QUIRK_POS_RUGGED_1, QUIRK_POS_RUGGED_2, QUIRK_POS_RUMBLE_SEAT, - QUIRK_POS_UBIQUITOUS_IS, QUIRK_POS_UBIQUITOUS_CLAN, QUIRK_NEG_ATMO_INSTABILITY, - QUIRK_NEG_BAD_REP_IS, QUIRK_NEG_BAD_REP_CLAN, QUIRK_NEG_CRAMPED_COCKPIT, - QUIRK_NEG_DIFFICULT_EJECT, QUIRK_NEG_DIFFICULT_MAINTAIN, QUIRK_NEG_FRAGILE_FUEL, - QUIRK_NEG_HARD_PILOT, QUIRK_NEG_ILLEGAL_DESIGN, QUIRK_NEG_NO_EJECT, - QUIRK_NEG_NON_STANDARD, QUIRK_NEG_OBSOLETE, QUIRK_NEG_POOR_LIFE_SUPPORT, - QUIRK_NEG_POOR_PERFORMANCE, QUIRK_NEG_POOR_TARG_S, QUIRK_NEG_POOR_TARG_M, - QUIRK_NEG_POOR_TARG_L, QUIRK_NEG_POOR_WORK, QUIRK_NEG_PROTOTYPE, - QUIRK_NEG_RAMSHACKLE, QUIRK_NEG_SENSOR_GHOSTS, QUIRK_NEG_UNSTREAMLINED, - QUIRK_NEG_WEAK_UNDERCARRIAGE)) { + QUIRK_POS_ATMO_FLYER, QUIRK_POS_COMBAT_COMPUTER, QUIRK_POS_EASY_MAINTAIN, + QUIRK_POS_EASY_PILOT, QUIRK_POS_GOOD_REP_1, QUIRK_POS_GOOD_REP_2, + QUIRK_POS_IMP_COM, QUIRK_POS_IMP_LIFE_SUPPORT, QUIRK_POS_IMP_TARG_L, + QUIRK_POS_IMP_TARG_M, QUIRK_POS_IMP_TARG_S, QUIRK_POS_INTERNAL_BOMB, + QUIRK_POS_RUGGED_1, QUIRK_POS_RUGGED_2, QUIRK_POS_RUMBLE_SEAT, + QUIRK_POS_UBIQUITOUS_IS, QUIRK_POS_UBIQUITOUS_CLAN, QUIRK_NEG_ATMO_INSTABILITY, + QUIRK_NEG_BAD_REP_IS, QUIRK_NEG_BAD_REP_CLAN, QUIRK_NEG_CRAMPED_COCKPIT, + QUIRK_NEG_DIFFICULT_EJECT, QUIRK_NEG_DIFFICULT_MAINTAIN, QUIRK_NEG_FRAGILE_FUEL, + QUIRK_NEG_HARD_PILOT, QUIRK_NEG_ILLEGAL_DESIGN, QUIRK_NEG_NO_EJECT, + QUIRK_NEG_NON_STANDARD, QUIRK_NEG_OBSOLETE, QUIRK_NEG_POOR_LIFE_SUPPORT, + QUIRK_NEG_POOR_PERFORMANCE, QUIRK_NEG_POOR_TARG_S, QUIRK_NEG_POOR_TARG_M, + QUIRK_NEG_POOR_TARG_L, QUIRK_NEG_POOR_WORK, QUIRK_NEG_PROTOTYPE, + QUIRK_NEG_RAMSHACKLE, QUIRK_NEG_SENSOR_GHOSTS, QUIRK_NEG_UNSTREAMLINED, + QUIRK_NEG_WEAK_UNDERCARRIAGE)) { return false; } @@ -341,11 +292,6 @@ public static boolean isQuirkIllegalFor(IOption quirk, Entity en) { return true; } - @Override - public Map getOptionsHash() { - return Map.of(); - } - private static class QuirksInfo extends AbstractOptionsInfo { private static boolean initialized = false; private static final AbstractOptionsInfo instance = new QuirksInfo(); diff --git a/megamek/src/megamek/common/options/SBFRuleOptions.java b/megamek/src/megamek/common/options/SBFRuleOptions.java index 11a2e101d7..5c5e9a8974 100644 --- a/megamek/src/megamek/common/options/SBFRuleOptions.java +++ b/megamek/src/megamek/common/options/SBFRuleOptions.java @@ -102,11 +102,6 @@ protected AbstractOptionsInfo getOptionsInfoImp() { return SBFRuleOptionsInfo.getInstance(); } - @Override - public Map getOptionsHash() { - return Map.of(); - } - private static class SBFRuleOptionsInfo extends AbstractOptionsInfo { private static final AbstractOptionsInfo instance = new SBFRuleOptionsInfo(); diff --git a/megamek/src/megamek/common/options/StaticGameOptions.java b/megamek/src/megamek/common/options/StaticGameOptions.java index 27157a435c..4a066ed612 100644 --- a/megamek/src/megamek/common/options/StaticGameOptions.java +++ b/megamek/src/megamek/common/options/StaticGameOptions.java @@ -17,12 +17,17 @@ private StaticGameOptions(Map optionsHash) { tableInfo.putAll(optionsHash); } + public static final StaticGameOptions EMPTY = empty(); + public static StaticGameOptions empty() { return new StaticGameOptions(Map.of()); } public static StaticGameOptions create(IGameOptions gameOptions) { - return new StaticGameOptions(gameOptions.getOptionsHash()); + if (gameOptions instanceof AbstractOptions abstractOptions) { + return new StaticGameOptions(abstractOptions.getOptionsHash()); + } + return EMPTY; } @Override @@ -80,9 +85,4 @@ public IOptionsInfo getOptionsInfo() { throw new UnsupportedOperationException(); } - @Override - public Map getOptionsHash() { - return tableInfo; - } - } diff --git a/megamek/src/megamek/common/options/WeaponQuirks.java b/megamek/src/megamek/common/options/WeaponQuirks.java index 93f36812a6..e6c56cb28b 100644 --- a/megamek/src/megamek/common/options/WeaponQuirks.java +++ b/megamek/src/megamek/common/options/WeaponQuirks.java @@ -17,9 +17,7 @@ import megamek.common.weapons.AmmoWeapon; import megamek.common.weapons.lasers.EnergyWeapon; -import java.io.Serial; import java.util.List; -import java.util.Map; import static java.util.stream.Collectors.toList; @@ -32,44 +30,34 @@ */ public class WeaponQuirks extends AbstractOptions { - @Serial private static final long serialVersionUID = -8455685281028804229L; public static final String WPN_QUIRKS = "WeaponQuirks"; - // All quirks you add: - private static final String[] QUIRKS = { - OptionsConstants.QUIRK_WEAP_POS_ACCURATE, - OptionsConstants.QUIRK_WEAP_NEG_INACCURATE, - OptionsConstants.QUIRK_WEAP_POS_STABLE_WEAPON, - OptionsConstants.QUIRK_WEAP_POS_IMP_COOLING, - OptionsConstants.QUIRK_WEAP_NEG_POOR_COOLING, - OptionsConstants.QUIRK_WEAP_NEG_NO_COOLING, - OptionsConstants.QUIRK_WEAP_NEG_EXPOSED_LINKAGE, - OptionsConstants.QUIRK_WEAP_NEG_AMMO_FEED_PROBLEMS, - OptionsConstants.QUIRK_WEAP_NEG_STATIC_FEED, - OptionsConstants.QUIRK_WEAP_NEG_EM_INTERFERENCE, - OptionsConstants.QUIRK_WEAP_POS_FAST_RELOAD, - OptionsConstants.QUIRK_WEAP_POS_DIRECT_TORSO_MOUNT, - OptionsConstants.QUIRK_WEAP_POS_MOD_WEAPONS, - OptionsConstants.QUIRK_WEAP_POS_JETTISON_CAPABLE, - OptionsConstants.QUIRK_WEAP_NEG_NON_FUNCTIONAL, - OptionsConstants.QUIRK_WEAP_NEG_MISREPAIRED, - OptionsConstants.QUIRK_WEAP_NEG_MISREPLACED - }; - public WeaponQuirks() { super(); } @Override public void initialize() { - var wpnQuirk = addGroup("wpn_quirks", WPN_QUIRKS); - var wpnInfo = getOptionsInfoImp(); + IBasicOptionGroup wpnQuirk = addGroup("wpn_quirks", WPN_QUIRKS); + addOption(wpnQuirk, OptionsConstants.QUIRK_WEAP_POS_ACCURATE, false); + addOption(wpnQuirk, OptionsConstants.QUIRK_WEAP_NEG_INACCURATE, false); + addOption(wpnQuirk, OptionsConstants.QUIRK_WEAP_POS_STABLE_WEAPON, false); + addOption(wpnQuirk, OptionsConstants.QUIRK_WEAP_POS_IMP_COOLING, false); + addOption(wpnQuirk, OptionsConstants.QUIRK_WEAP_NEG_POOR_COOLING, false); + addOption(wpnQuirk, OptionsConstants.QUIRK_WEAP_NEG_NO_COOLING, false); + addOption(wpnQuirk, OptionsConstants.QUIRK_WEAP_NEG_EXPOSED_LINKAGE, false); + addOption(wpnQuirk, OptionsConstants.QUIRK_WEAP_NEG_AMMO_FEED_PROBLEMS, false); + addOption(wpnQuirk, OptionsConstants.QUIRK_WEAP_NEG_STATIC_FEED, false); + addOption(wpnQuirk, OptionsConstants.QUIRK_WEAP_NEG_EM_INTERFERENCE, false); + addOption(wpnQuirk, OptionsConstants.QUIRK_WEAP_POS_FAST_RELOAD, false); + addOption(wpnQuirk, OptionsConstants.QUIRK_WEAP_POS_DIRECT_TORSO_MOUNT, false); + addOption(wpnQuirk, OptionsConstants.QUIRK_WEAP_POS_MOD_WEAPONS, false); + addOption(wpnQuirk, OptionsConstants.QUIRK_WEAP_POS_JETTISON_CAPABLE, false); + addOption(wpnQuirk, OptionsConstants.QUIRK_WEAP_NEG_NON_FUNCTIONAL, false); + addOption(wpnQuirk, OptionsConstants.QUIRK_WEAP_NEG_MISREPAIRED, false); + addOption(wpnQuirk, OptionsConstants.QUIRK_WEAP_NEG_MISREPLACED, false); - for (String quirkName : QUIRKS) { - optionsHash.put(quirkName, new Option(this, quirkName, IOption.BOOLEAN, false)); - wpnInfo.addOptionInfo(wpnQuirk, quirkName); - } } //TODO @@ -96,27 +84,25 @@ public List activeQuirks() { return getOptionsList().stream().filter(IOption::booleanValue).collect(toList()); } - public static boolean isQuirkLegalFor(IOption quirk, Entity en, - EquipmentType etype) { + public static boolean isQuirkLegalFor(IOption quirk, Entity en, EquipmentType etype) { String qName = quirk.getName(); // There may be some non-WeaponType quirks, specifically melee weapons if (!(etype instanceof WeaponType) && !etype.hasFlag(MiscType.F_CLUB)) { return false; } else if (etype.hasFlag(MiscType.F_CLUB)) { if (qName.equals(OptionsConstants.QUIRK_WEAP_NEG_AMMO_FEED_PROBLEMS) - || qName.equals(OptionsConstants.QUIRK_WEAP_NEG_EM_INTERFERENCE) - || qName.equals(OptionsConstants.QUIRK_WEAP_NEG_NO_COOLING) - || qName.equals(OptionsConstants.QUIRK_WEAP_NEG_POOR_COOLING) - || qName.equals(OptionsConstants.QUIRK_WEAP_NEG_STATIC_FEED) - || qName.equals(OptionsConstants.QUIRK_WEAP_POS_IMP_COOLING) - || qName.equals(OptionsConstants.QUIRK_WEAP_POS_FAST_RELOAD)) { + || qName.equals(OptionsConstants.QUIRK_WEAP_NEG_EM_INTERFERENCE) + || qName.equals(OptionsConstants.QUIRK_WEAP_NEG_NO_COOLING) + || qName.equals(OptionsConstants.QUIRK_WEAP_NEG_POOR_COOLING) + || qName.equals(OptionsConstants.QUIRK_WEAP_NEG_STATIC_FEED) + || qName.equals(OptionsConstants.QUIRK_WEAP_POS_IMP_COOLING) + || qName.equals(OptionsConstants.QUIRK_WEAP_POS_FAST_RELOAD)) { return false; } return true; } // Anything else is a WeaponType - assert etype instanceof WeaponType; WeaponType wtype = (WeaponType) etype; if (!(wtype instanceof AmmoWeapon)) { @@ -146,11 +132,10 @@ public static boolean isQuirkLegalFor(IOption quirk, Entity en, } } - boolean coolingQuirks = qName.equals(OptionsConstants.QUIRK_WEAP_POS_IMP_COOLING) - || qName.equals(OptionsConstants.QUIRK_WEAP_NEG_POOR_COOLING) - || qName.equals(OptionsConstants.QUIRK_WEAP_NEG_NO_COOLING); if (en instanceof Tank || en instanceof BattleArmor || en instanceof ProtoMek) { - if (coolingQuirks) { + if (qName.equals(OptionsConstants.QUIRK_WEAP_POS_IMP_COOLING) + || qName.equals(OptionsConstants.QUIRK_WEAP_NEG_POOR_COOLING) + || qName.equals(OptionsConstants.QUIRK_WEAP_NEG_NO_COOLING)) { return false; } } @@ -160,7 +145,9 @@ public static boolean isQuirkLegalFor(IOption quirk, Entity en, } if (wtype.getHeat() == 0) { - if (coolingQuirks) { + if (qName.equals(OptionsConstants.QUIRK_WEAP_POS_IMP_COOLING) + || qName.equals(OptionsConstants.QUIRK_WEAP_NEG_POOR_COOLING) + || qName.equals(OptionsConstants.QUIRK_WEAP_NEG_NO_COOLING)) { return false; } } @@ -199,19 +186,16 @@ public static boolean isQuirkLegalFor(IOption quirk, Entity en, } if (qName.equals(OptionsConstants.QUIRK_WEAP_NEG_EM_INTERFERENCE)) { - return !(en instanceof Jumpship); + if (en instanceof Jumpship) { + return false; + } } return true; } - @Override - public Map getOptionsHash() { - return Map.of(); - } - private static class WeaponQuirksInfo extends AbstractOptionsInfo { - private static final AbstractOptionsInfo instance = new WeaponQuirksInfo(); + private static AbstractOptionsInfo instance = new WeaponQuirksInfo(); public static AbstractOptionsInfo getInstance() { return instance; diff --git a/megamek/src/megamek/common/preference/ClientPreferences.java b/megamek/src/megamek/common/preference/ClientPreferences.java index 75d3b4b794..958535617e 100644 --- a/megamek/src/megamek/common/preference/ClientPreferences.java +++ b/megamek/src/megamek/common/preference/ClientPreferences.java @@ -42,7 +42,9 @@ public class ClientPreferences extends PreferenceStoreProxy { public static final String MEMORY_DUMP_ON = "MemoryDumpOn"; public static final String DEBUG_OUTPUT_ON = "DebugOutputOn"; public static final String GAMELOG_KEEP = "KeepGameLog"; + public static final String AUTORESOLVE_GAMELOG_KEEP = "KeepAutoResolveGameLog"; public static final String GAMELOG_FILENAME = "GameLogFilename"; + public static final String AUTO_RESOLVE_GAMELOG_FILENAME = "AutoResolveGameLogFilename"; public static final String STAMP_FILENAMES = "StampFilenames"; public static final String STAMP_FORMAT = "StampFormat"; public static final String SHOW_UNIT_ID = "ShowUnitId"; @@ -88,6 +90,7 @@ public ClientPreferences(IPreferenceStore store) { store.setDefault(METASERVER_NAME, "https://api.megamek.org/servers/announce"); store.setDefault(GAMELOG_KEEP, true); store.setDefault(GAMELOG_FILENAME, "gamelog.html"); + store.setDefault(AUTO_RESOLVE_GAMELOG_FILENAME, "acar_gamelog.html"); store.setDefault(STAMP_FORMAT, "_yyyy-MM-dd_HH-mm-ss"); store.setDefault(UNIT_START_CHAR, 'A'); store.setDefault(GUI_NAME, "swing"); @@ -202,6 +205,10 @@ public String getGameLogFilename() { return store.getString(GAMELOG_FILENAME); } + public String getAutoResolveGameLogFilename() { + return store.getString(AUTO_RESOLVE_GAMELOG_FILENAME); + } + public boolean stampFilenames() { return store.getBoolean(STAMP_FILENAMES); } @@ -222,6 +229,10 @@ public boolean keepGameLog() { return store.getBoolean(GAMELOG_KEEP); } + public boolean keepAutoResolveGameLog() { + return store.getBoolean(AUTORESOLVE_GAMELOG_KEEP); + } + public boolean memoryDumpOn() { return store.getBoolean(MEMORY_DUMP_ON); } @@ -250,6 +261,10 @@ public void setKeepGameLog(boolean state) { store.setValue(GAMELOG_KEEP, state); } + public void setKeepAutoResolveGameLog(boolean state) { + store.setValue(AUTORESOLVE_GAMELOG_KEEP, state); + } + public void setLastConnectAddr(String serverAddr) { store.setValue(LAST_CONNECT_ADDR, serverAddr); }