From 66ae719c359cd06bd63dae92f08c7693a6dc4cf5 Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 8 Dec 2023 17:02:40 +0100 Subject: [PATCH 1/2] Quirks updates: API improvements, validity check updates, MechView updates --- megamek/src/megamek/common/Entity.java | 3 +- megamek/src/megamek/common/MechView.java | 58 +- megamek/src/megamek/common/Mounted.java | 14 +- .../common/options/AbstractOptions.java | 19 +- .../megamek/common/options/IBasicOption.java | 16 + .../src/megamek/common/options/IOption.java | 32 +- .../src/megamek/common/options/Quirks.java | 812 +++++------------- .../megamek/common/options/WeaponQuirks.java | 13 +- 8 files changed, 292 insertions(+), 675 deletions(-) diff --git a/megamek/src/megamek/common/Entity.java b/megamek/src/megamek/common/Entity.java index 7adba24108f..c5550acab4e 100644 --- a/megamek/src/megamek/common/Entity.java +++ b/megamek/src/megamek/common/Entity.java @@ -12753,8 +12753,7 @@ public synchronized Quirks getQuirks() { } public boolean hasQuirk(String name) { - if ((null == game) - || !game.getOptions().booleanOption(OptionsConstants.ADVANCED_STRATOPS_QUIRKS)) { + if ((game != null) && !game.getOptions().booleanOption(OptionsConstants.ADVANCED_STRATOPS_QUIRKS)) { return false; } return quirks.booleanOption(name); diff --git a/megamek/src/megamek/common/MechView.java b/megamek/src/megamek/common/MechView.java index 98b5891d351..9579b5a3d81 100644 --- a/megamek/src/megamek/common/MechView.java +++ b/megamek/src/megamek/common/MechView.java @@ -488,53 +488,28 @@ public MechView(final Entity entity, final boolean showDetail, final boolean use Game game = entity.getGame(); if ((game == null) || game.getOptions().booleanOption(OptionsConstants.ADVANCED_STRATOPS_QUIRKS)) { - List quirksList = new ArrayList<>(); - Quirks quirks = entity.getQuirks(); + List activeUnitQuirksNames = entity.getQuirks().activeQuirks().stream() + .map(IOption::getDisplayableNameWithValue) + .collect(Collectors.toList()); - for (Enumeration optionGroups = quirks.getGroups(); optionGroups.hasMoreElements();) { - IOptionGroup group = optionGroups.nextElement(); - - if (quirks.count(group.getKey()) > 0) { - for (Enumeration options = group.getOptions(); options.hasMoreElements();) { - IOption option = options.nextElement(); - - if (option != null && option.booleanValue()) { - quirksList.add(option.getDisplayableNameWithValue()); - } - } - } - } - if (!quirksList.isEmpty()) { + if (!activeUnitQuirksNames.isEmpty()) { sFluff.add(new SingleLine()); ItemList list = new ItemList(Messages.getString("MechView.Quirks")); - quirksList.forEach(list::addItem); + activeUnitQuirksNames.forEach(list::addItem); sFluff.add(list); } List wpQuirksList = new ArrayList<>(); for (Mounted weapon: entity.getWeaponList()) { - for (Enumeration optionGroups = weapon.getQuirks().getGroups(); optionGroups.hasMoreElements();) { - IOptionGroup group = optionGroups.nextElement(); - - if (weapon.getQuirks().count(group.getKey()) > 0) { - String wq = ""; - - for (Enumeration options = group.getOptions(); options.hasMoreElements(); ) { - IOption option = options.nextElement(); - - if (option != null && option.booleanValue()) { - wq += option.getDisplayableNameWithValue() + " \u2022 "; - } - } - - if (!wq.isEmpty()) { - wq = weapon.getDesc() + ": " + wq.substring(0, wq.length() - 2); - wpQuirksList.add(wq); - } - } + List activeWeaponQuirksNames = weapon.getQuirks().activeQuirks().stream() + .map(IOption::getDisplayableNameWithValue) + .collect(Collectors.toList()); + if (!activeWeaponQuirksNames.isEmpty()) { + String wq = weapon.getDesc() + " (" + entity.getLocationAbbr(weapon.getLocation()) + "): "; + wq += String.join(", ", activeWeaponQuirksNames); + wpQuirksList.add(wq); } } - if (!wpQuirksList.isEmpty()) { sFluff.add(new SingleLine()); ItemList list = new ItemList(Messages.getString("MechView.WeaponQuirks")); @@ -858,7 +833,7 @@ private List getWeapons(boolean showDetail) { retVal.add(new SingleLine()); } - if (entity.getWeaponList().size() < 1) { + if (entity.getWeaponList().isEmpty()) { return retVal; } @@ -867,7 +842,8 @@ private List getWeapons(boolean showDetail) { wpnTable.setJustification(TableElement.JUSTIFIED_LEFT, TableElement.JUSTIFIED_CENTER, TableElement.JUSTIFIED_CENTER, TableElement.JUSTIFIED_CENTER); for (Mounted mounted : entity.getWeaponList()) { - String[] row = { mounted.getDesc(), entity.joinLocationAbbr(mounted.allLocations(), 3), "", "" }; + String[] row = { mounted.getDesc() + quirkMarker(mounted), + entity.joinLocationAbbr(mounted.allLocations(), 3), "", "" }; WeaponType wtype = (WeaponType) mounted.getType(); if (entity.isClan() @@ -974,6 +950,10 @@ private List getWeapons(boolean showDetail) { return retVal; } + private String quirkMarker(Mounted mounted) { + return (mounted.countQuirks() > 0) ? " (Q)" : ""; + } + private ViewElement getAmmo() { TableElement ammoTable = new TableElement(4); ammoTable.setColNames("Ammo", "Loc", "Shots", entity.isOmni() ? "Omni" : ""); diff --git a/megamek/src/megamek/common/Mounted.java b/megamek/src/megamek/common/Mounted.java index 57a8271eda1..0e353aa7bbc 100644 --- a/megamek/src/megamek/common/Mounted.java +++ b/megamek/src/megamek/common/Mounted.java @@ -1804,15 +1804,19 @@ public boolean hasQuirk(String name) { } /** - * Count all the quirks for this "mounted" object, positive and negative + * Count all the weapon quirks for this Mounted. Returns 0 when this Mounted is tied to an Entity and + * this Entity's game does not use quirks! In all other cases (e.g. outside of games), returns the quirk + * count of this Mounted. + * + * @return The number of active weapon quirks for this Mounted unless the game does not use quirks */ public int countQuirks() { - if ((null == entity) || (null == entity.game) - || !entity.game.getOptions().booleanOption(OptionsConstants.ADVANCED_STRATOPS_QUIRKS)) { + if ((entity != null) && (entity.getGame() != null) && + !entity.getGame().getOptions().booleanOption(OptionsConstants.ADVANCED_STRATOPS_QUIRKS)) { return 0; + } else { + return quirks.count(); } - - return quirks.count(); } /** diff --git a/megamek/src/megamek/common/options/AbstractOptions.java b/megamek/src/megamek/common/options/AbstractOptions.java index 05d2b804ecf..6c3e49cfbc6 100755 --- a/megamek/src/megamek/common/options/AbstractOptions.java +++ b/megamek/src/megamek/common/options/AbstractOptions.java @@ -16,18 +16,14 @@ import megamek.common.annotations.Nullable; import java.io.Serializable; -import java.util.Collections; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.List; -import java.util.Vector; +import java.util.*; /** * Parent class for options settings */ public abstract class AbstractOptions implements Serializable { private static final long serialVersionUID = 6406883135074654379L; - private Hashtable optionsHash = new Hashtable<>(); + private final Hashtable optionsHash = new Hashtable<>(); protected AbstractOptions() { initialize(); @@ -136,6 +132,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 * diff --git a/megamek/src/megamek/common/options/IBasicOption.java b/megamek/src/megamek/common/options/IBasicOption.java index 2e1d17b9a8c..dd6e172855b 100644 --- a/megamek/src/megamek/common/options/IBasicOption.java +++ b/megamek/src/megamek/common/options/IBasicOption.java @@ -14,6 +14,8 @@ package megamek.common.options; +import java.util.Arrays; + /** * Basic option. It's just String name - Object * value pair @@ -34,4 +36,18 @@ public interface IBasicOption { */ public abstract Object getValue(); + /** @return True when this Option's name is equal to the given Option name. */ + default boolean is(String otherName) { + return isAnyOf(otherName); + } + + /** @return True when this Option's name is equal to at least one of the given Option names. */ + default boolean isAnyOf(String otherName, String... otherNames) { + return getName().equals(otherName) || Arrays.stream(otherNames).anyMatch(name -> getName().equals(name)); + } + + /** @return True when this Option's name is not equal to any of the given names. */ + default boolean isNoneOf(String otherName, String... otherNames) { + return !isAnyOf(otherName, otherNames); + } } diff --git a/megamek/src/megamek/common/options/IOption.java b/megamek/src/megamek/common/options/IOption.java index 0a981a8b196..366637c10e5 100755 --- a/megamek/src/megamek/common/options/IOption.java +++ b/megamek/src/megamek/common/options/IOption.java @@ -29,27 +29,27 @@ public interface IOption extends IBasicOption, IOptionInfo { /** * Boolean option type */ - public static final int BOOLEAN = 0; + int BOOLEAN = 0; /** * Integer option type */ - public static final int INTEGER = 1; + int INTEGER = 1; /** * Float option type */ - public static final int FLOAT = 2; + int FLOAT = 2; /** * String option type */ - public static final int STRING = 3; + int STRING = 3; /** * Choice option type */ - public static final int CHOICE = 4; + int CHOICE = 4; /** * Returns this option container - GameOptions, PilotOptions etc @@ -71,66 +71,66 @@ public interface IOption extends IBasicOption, IOptionInfo { * * @return default option value */ - public abstract Object getDefault(); + Object getDefault(); /** * Return the value as the boolean */ - public abstract boolean booleanValue(); + boolean booleanValue(); /** * Return the value as the int */ - public abstract int intValue(); + int intValue(); /** * Return the value as the float */ - public abstract float floatValue(); + float floatValue(); /** * Return the value as the String */ - public abstract String stringValue(); + String stringValue(); /** * Sets the value * * @param value value to set */ - public abstract void setValue(Object value); + void setValue(Object value); /** * Sets the String value * * @param value value to set */ - public abstract void setValue(String value); + void setValue(String value); /** * Sets the boolean value * * @param value value to set */ - public abstract void setValue(boolean value); + void setValue(boolean value); /** * Sets the int value * * @param value value to set */ - public abstract void setValue(int value); + void setValue(int value); /** * Sets the float value * * @param value value to set */ - public abstract void setValue(float value); + void setValue(float value); /** * Resets the value to its "default" state */ - public abstract void clearValue(); + void clearValue(); } diff --git a/megamek/src/megamek/common/options/Quirks.java b/megamek/src/megamek/common/options/Quirks.java index 85b030d3641..7639a31f1ac 100644 --- a/megamek/src/megamek/common/options/Quirks.java +++ b/megamek/src/megamek/common/options/Quirks.java @@ -11,26 +11,18 @@ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. */ - package megamek.common.options; +import megamek.common.*; + +import java.util.List; -import megamek.common.Aero; -import megamek.common.BattleArmor; -import megamek.common.Dropship; -import megamek.common.Engine; -import megamek.common.Entity; -import megamek.common.EntityMovementMode; -import megamek.common.GunEmplacement; -import megamek.common.Jumpship; -import megamek.common.Mech; -import megamek.common.Protomech; -import megamek.common.SupportTank; -import megamek.common.SupportVTOL; -import megamek.common.Tank; +import static java.util.stream.Collectors.toList; +import static megamek.common.options.OptionsConstants.*; /** - * Contains the options determining quirks of the unit + * Contains the options determining Unit Quirks of a unit (but not weapon quirks). When changing this, note + * that all options should remain boolean options. * * @author Taharqa (Jay Lawson) */ @@ -41,62 +33,61 @@ public class Quirks extends AbstractOptions { @Override public synchronized void initialize() { - //positive quirks IBasicOptionGroup posQuirk = addGroup("pos_quirks", POS_QUIRKS); - addOption(posQuirk, OptionsConstants.QUIRK_POS_ANIMALISTIC, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_ANTI_AIR, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_ATMO_FLYER, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_BATTLE_COMP, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_BARREL_FIST_LA, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_BARREL_FIST_RA, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_BATTLE_FIST_LA, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_BATTLE_FIST_RA, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_COMBAT_COMPUTER, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_COMMAND_MECH, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_COMPACT, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_COWL, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_DIRECTIONAL_TORSO_MOUNT, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_DISTRACTING, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_DOCKING_ARMS, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_EASY_MAINTAIN, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_EASY_PILOT, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_EXT_TWIST, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_FAST_RELOAD, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_FINE_MANIPULATORS, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_GOOD_REP_1, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_GOOD_REP_2, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_HYPER_ACTUATOR, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_IMP_COM, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_IMP_LIFE_SUPPORT, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_IMP_TARG_L, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_IMP_TARG_M, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_IMP_TARG_S, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_IMPROVED_SENSORS, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_INTERNAL_BOMB, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_LOW_PROFILE, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_MULTI_TRAC, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_NIMBLE_JUMPER, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_OVERHEAD_ARMS, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_POWER_REVERSE, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_PRO_ACTUATOR, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_REINFORCED_LEGS, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_RUGGED_1, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_RUGGED_2, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_RUMBLE_SEAT, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_SCOUT_BIKE, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_SEARCHLIGHT, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_STABLE, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_TRAILER_HITCH, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_UBIQUITOUS_IS, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_UBIQUITOUS_CLAN, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_VAR_RNG_TARG_L, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_VAR_RNG_TARG_S, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_VESTIGIAL_HANDS_LA, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_VESTIGIAL_HANDS_RA, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_VTOL_ROTOR_COAXIAL, false); - addOption(posQuirk, OptionsConstants.QUIRK_POS_VTOL_ROTOR_DUAL, false); + 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_MECH, 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) @@ -106,50 +97,49 @@ public synchronized void initialize() { //VTOL Rotor Arrangement (no vee adv move rules) //Compact Mech - // negative quirks IBasicOptionGroup negQuirk = addGroup("neg_quirks", NEG_QUIRKS); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_BAD_REP_IS, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_BAD_REP_CLAN, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_CRAMPED_COCKPIT, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_DIFFICULT_EJECT, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_DIFFICULT_MAINTAIN, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_EM_INTERFERENCE_WHOLE, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_EXP_ACTUATOR, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_FLAWED_COOLING, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_FRAGILE_FUEL, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_GAS_HOG, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_HARD_PILOT, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_ILLEGAL_DESIGN, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_LARGE_DROPPER, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_LOW_ARMS, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_NO_ARMS, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_NO_EJECT, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_NO_TWIST, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_NON_STANDARD, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_OBSOLETE, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_POOR_LIFE_SUPPORT, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_POOR_PERFORMANCE, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_POOR_SEALING, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_POOR_TARG_L, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_POOR_TARG_M, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_POOR_TARG_S, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_POOR_WORK, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_PROTOTYPE, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_RAMSHACKLE, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_SENSOR_GHOSTS, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_SUSCEPTIBLE_CWS, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_UNBALANCED, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_UNSTREAMLINED, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_WEAK_HEAD_1, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_WEAK_HEAD_2, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_WEAK_HEAD_3, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_WEAK_HEAD_4, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_WEAK_HEAD_5, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_WEAK_LEGS, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_WEAK_UNDERCARRIAGE, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_ATMO_INSTABILITY, false); - addOption(negQuirk, OptionsConstants.QUIRK_NEG_OVERSIZED, false); - + 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 @@ -160,530 +150,140 @@ public synchronized void initialize() { //Ramshackle } - /* - * (non-Javadoc) - * - * @see megamek.common.options.AbstractOptions#getOptionsInfoImp() - */ @Override protected AbstractOptionsInfo getOptionsInfoImp() { return QuirksInfo.getInstance(); } + /** @return A list of unit quirks that are active in this Quirks object. */ + public List activeQuirks() { + return getOptionsList().stream().filter(IOption::booleanValue).collect(toList()); + } + public static boolean isQuirkLegalFor(IOption quirk, Entity en) { String qName = quirk.getName(); - - if (en.hasEngine() && - ((en.getEngine().getEngineType() == Engine.COMBUSTION_ENGINE) || - (en.getEngine().getEngineType() == Engine.FUEL_CELL)) && - qName.equals(OptionsConstants.QUIRK_NEG_GAS_HOG)) { - return true; - } - if (en instanceof Mech) { - if (qName.equals(OptionsConstants.QUIRK_POS_BATTLE_FIST_LA)) { - // Mechs with a hand actuator can have battlefists - if (en.hasSystem(Mech.ACTUATOR_HAND, Mech.LOC_LARM)) { - return true; - } else { - return false; - } - } - if (qName.equals(OptionsConstants.QUIRK_POS_BATTLE_FIST_RA)) { - // Mechs with a hand actuator can have battlefists - if (en.hasSystem(Mech.ACTUATOR_HAND, Mech.LOC_RARM)) { - return true; - } else { - return false; - } - } - if (qName.equals(OptionsConstants.QUIRK_POS_BARREL_FIST_RA)) { - if (en.hasSystem(Mech.ACTUATOR_LOWER_ARM, Mech.LOC_RARM) - && !en.hasSystem(Mech.ACTUATOR_HAND, Mech.LOC_RARM)) { - return true; - } else { - return false; - } - } - if (qName.equals(OptionsConstants.QUIRK_POS_BARREL_FIST_LA)) { - if (en.hasSystem(Mech.ACTUATOR_LOWER_ARM, Mech.LOC_LARM) - && !en.hasSystem(Mech.ACTUATOR_HAND, Mech.LOC_LARM)) { - return true; - } else { - return false; - } - } - - if (qName.equals(OptionsConstants.QUIRK_POS_ATMO_FLYER) - || qName.equals(OptionsConstants.QUIRK_NEG_ATMO_INSTABILITY) - || qName.equals(OptionsConstants.QUIRK_POS_DOCKING_ARMS) - || qName.equals(OptionsConstants.QUIRK_NEG_FRAGILE_FUEL) - || qName.equals(OptionsConstants.QUIRK_POS_INTERNAL_BOMB) - || qName.equals(OptionsConstants.QUIRK_POS_TRAILER_HITCH) - || qName.equals(OptionsConstants.QUIRK_NEG_LARGE_DROPPER) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_UNDERCARRIAGE) - || qName.equals(OptionsConstants.QUIRK_POS_VTOL_ROTOR_COAXIAL) - || qName.equals(OptionsConstants.QUIRK_POS_VTOL_ROTOR_DUAL) - || qName.equals(OptionsConstants.QUIRK_NEG_GAS_HOG) - || qName.equals(OptionsConstants.QUIRK_POS_POWER_REVERSE) - || qName.equals(OptionsConstants.QUIRK_NEG_UNSTREAMLINED)) { - return false; - } - - if ((en.getWeight()<60) && (qName.equals(OptionsConstants.QUIRK_NEG_OVERSIZED))) { - return false; - } - - if ((en.getWeight()>55) && (qName.equals(OptionsConstants.QUIRK_POS_COMPACT))) { - return false; - } - - return true; + if (qName.equals(QUIRK_NEG_GAS_HOG)) { + return en.hasEngine() && + ((en.getEngine().getEngineType() == Engine.COMBUSTION_ENGINE) + || (en.getEngine().getEngineType() == Engine.FUEL_CELL)); } - // Nov 2016 - Reviewed the idea of quirks with Ray from CGL. The working - // made sense to him. Uncertain at this time if CGL would adopt them but - // including them since Quirks is already an option. Hammer - if (en instanceof GunEmplacement) { - if (qName.equals(OptionsConstants.QUIRK_POS_ATMO_FLYER) - || qName.equals(OptionsConstants.QUIRK_POS_ANIMALISTIC) - || qName.equals(OptionsConstants.QUIRK_POS_BARREL_FIST_LA) - || qName.equals(OptionsConstants.QUIRK_POS_BARREL_FIST_RA) - || qName.equals(OptionsConstants.QUIRK_POS_COMBAT_COMPUTER) - || qName.equals(OptionsConstants.QUIRK_POS_COMMAND_MECH) - || qName.equals(OptionsConstants.QUIRK_POS_COWL) - || qName.equals(OptionsConstants.QUIRK_POS_DIRECTIONAL_TORSO_MOUNT) - || qName.equals(OptionsConstants.QUIRK_POS_DOCKING_ARMS) - || qName.equals(OptionsConstants.QUIRK_POS_EASY_PILOT) - || qName.equals(OptionsConstants.QUIRK_POS_EASY_MAINTAIN) - || qName.equals(OptionsConstants.QUIRK_POS_EXT_TWIST) - || qName.equals(OptionsConstants.QUIRK_POS_FINE_MANIPULATORS) - || qName.equals(OptionsConstants.QUIRK_POS_GOOD_REP_1) - || qName.equals(OptionsConstants.QUIRK_POS_GOOD_REP_2) - || qName.equals(OptionsConstants.QUIRK_POS_HYPER_ACTUATOR) - || qName.equals(OptionsConstants.QUIRK_POS_IMP_LIFE_SUPPORT) - || qName.equals(OptionsConstants.QUIRK_POS_INTERNAL_BOMB) - || qName.equals(OptionsConstants.QUIRK_WEAP_POS_JETTISON_CAPABLE) - || qName.equals(OptionsConstants.QUIRK_POS_MULTI_TRAC) - || qName.equals(OptionsConstants.QUIRK_POS_NIMBLE_JUMPER) - || qName.equals(OptionsConstants.QUIRK_POS_REINFORCED_LEGS) - || qName.equals(OptionsConstants.QUIRK_POS_POWER_REVERSE) - || qName.equals(OptionsConstants.QUIRK_POS_RUMBLE_SEAT) - || qName.equals(OptionsConstants.QUIRK_POS_TRAILER_HITCH) - || qName.equals(OptionsConstants.QUIRK_POS_STABLE) - || qName.equals(OptionsConstants.QUIRK_POS_OVERHEAD_ARMS) - || qName.equals(OptionsConstants.QUIRK_POS_COMPACT) - || qName.equals(OptionsConstants.QUIRK_POS_BATTLE_FIST_RA) - || qName.equals(OptionsConstants.QUIRK_POS_BATTLE_FIST_LA) - || qName.equals(OptionsConstants.QUIRK_POS_PRO_ACTUATOR) - || qName.equals(OptionsConstants.QUIRK_NEG_ATMO_INSTABILITY) - || qName.equals(OptionsConstants.QUIRK_NEG_BAD_REP_CLAN) - || qName.equals(OptionsConstants.QUIRK_NEG_CRAMPED_COCKPIT) - || qName.equals(OptionsConstants.QUIRK_NEG_DIFFICULT_EJECT) - || qName.equals(OptionsConstants.QUIRK_NEG_DIFFICULT_MAINTAIN) - || qName.equals(OptionsConstants.QUIRK_NEG_EXP_ACTUATOR) - || qName.equals(OptionsConstants.QUIRK_NEG_FRAGILE_FUEL) - || qName.equals(OptionsConstants.QUIRK_NEG_HARD_PILOT) - || qName.equals(OptionsConstants.QUIRK_NEG_ILLEGAL_DESIGN) - || qName.equals(OptionsConstants.QUIRK_NEG_LOW_ARMS) - || qName.equals(OptionsConstants.QUIRK_NEG_NON_STANDARD) - || qName.equals(OptionsConstants.QUIRK_NEG_OBSOLETE) - || qName.equals(OptionsConstants.QUIRK_NEG_POOR_PERFORMANCE) - || qName.equals(OptionsConstants.QUIRK_NEG_POOR_SEALING) - || qName.equals(OptionsConstants.QUIRK_NEG_PROTOTYPE) - || qName.equals(OptionsConstants.QUIRK_NEG_SUSCEPTIBLE_CWS) - || qName.equals(OptionsConstants.QUIRK_NEG_NO_ARMS) - || qName.equals(OptionsConstants.QUIRK_NEG_NO_EJECT) - || qName.equals(OptionsConstants.QUIRK_NEG_NO_TWIST) - || qName.equals(OptionsConstants.QUIRK_NEG_LARGE_DROPPER) - || qName.equals(OptionsConstants.QUIRK_NEG_POOR_LIFE_SUPPORT) - || qName.equals(OptionsConstants.QUIRK_NEG_UNBALANCED) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_LEGS) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_UNDERCARRIAGE) - || qName.equals(OptionsConstants.QUIRK_POS_VTOL_ROTOR_COAXIAL) - || qName.equals(OptionsConstants.QUIRK_POS_VTOL_ROTOR_DUAL) - || qName.equals(OptionsConstants.QUIRK_NEG_FLAWED_COOLING) - || qName.equals(OptionsConstants.QUIRK_NEG_UNSTREAMLINED) - || qName.equals(OptionsConstants.QUIRK_NEG_GAS_HOG) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_HEAD_1) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_HEAD_2) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_HEAD_3) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_HEAD_4) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_HEAD_5) - || qName.equals(OptionsConstants.QUIRK_POS_VESTIGIAL_HANDS_LA) - || qName.equals(OptionsConstants.QUIRK_POS_VESTIGIAL_HANDS_RA)) { - return false; + if (en instanceof Mech) { + switch (qName) { + case QUIRK_POS_BATTLE_FIST_LA: + return en.hasSystem(Mech.ACTUATOR_HAND, Mech.LOC_LARM); + case QUIRK_POS_BATTLE_FIST_RA: + return en.hasSystem(Mech.ACTUATOR_HAND, Mech.LOC_RARM); + case QUIRK_POS_BARREL_FIST_RA: + return en.hasSystem(Mech.ACTUATOR_LOWER_ARM, Mech.LOC_RARM) + && !en.hasSystem(Mech.ACTUATOR_HAND, Mech.LOC_RARM); + case QUIRK_POS_BARREL_FIST_LA: + return en.hasSystem(Mech.ACTUATOR_LOWER_ARM, Mech.LOC_LARM) + && !en.hasSystem(Mech.ACTUATOR_HAND, Mech.LOC_LARM); + case QUIRK_NEG_OVERSIZED: + return en.getWeight() >= 60; + case QUIRK_POS_COMPACT: + return en.getWeight() <= 55; + default: + return quirk.isNoneOf(QUIRK_POS_ATMO_FLYER, QUIRK_NEG_ATMO_INSTABILITY, QUIRK_POS_DOCKING_ARMS, + QUIRK_NEG_FRAGILE_FUEL, QUIRK_POS_INTERNAL_BOMB, QUIRK_POS_TRAILER_HITCH, + QUIRK_NEG_LARGE_DROPPER, QUIRK_NEG_WEAK_UNDERCARRIAGE, QUIRK_POS_VTOL_ROTOR_COAXIAL, + QUIRK_POS_VTOL_ROTOR_DUAL, QUIRK_POS_POWER_REVERSE, QUIRK_NEG_UNSTREAMLINED); } - return true; } if (en instanceof Tank) { - - // Power reverse only legal for wheeled or tracked combat vehicles - if (qName.equals(OptionsConstants.QUIRK_POS_POWER_REVERSE)) { - if ((en.getMovementMode() == EntityMovementMode.WHEELED - || en.getMovementMode() == EntityMovementMode.TRACKED) - && !((en instanceof SupportTank) - || (en instanceof SupportVTOL))) { - return true; - } else { - return false; - } - } else if (en.hasEngine() && en.getEngine().isFusion() && qName.equals(OptionsConstants.QUIRK_NEG_FRAGILE_FUEL)) { - return false; - } else if (qName.equals(OptionsConstants.QUIRK_POS_ATMO_FLYER) - || qName.equals(OptionsConstants.QUIRK_POS_ANIMALISTIC) - || qName.equals(OptionsConstants.QUIRK_POS_BARREL_FIST_LA) - || qName.equals(OptionsConstants.QUIRK_POS_BARREL_FIST_RA) - || qName.equals(OptionsConstants.QUIRK_POS_COMBAT_COMPUTER) - || qName.equals(OptionsConstants.QUIRK_POS_COMMAND_MECH) - || qName.equals(OptionsConstants.QUIRK_POS_COWL) - || qName.equals(OptionsConstants.QUIRK_POS_DIRECTIONAL_TORSO_MOUNT) - || qName.equals(OptionsConstants.QUIRK_POS_DOCKING_ARMS) - || qName.equals(OptionsConstants.QUIRK_POS_EASY_PILOT) - || qName.equals(OptionsConstants.QUIRK_POS_EXT_TWIST) - || qName.equals(OptionsConstants.QUIRK_POS_FINE_MANIPULATORS) - || qName.equals(OptionsConstants.QUIRK_POS_HYPER_ACTUATOR) - || qName.equals(OptionsConstants.QUIRK_POS_IMP_LIFE_SUPPORT) - || qName.equals(OptionsConstants.QUIRK_POS_INTERNAL_BOMB) - || qName.equals(OptionsConstants.QUIRK_POS_MULTI_TRAC) - || qName.equals(OptionsConstants.QUIRK_POS_NIMBLE_JUMPER) - || qName.equals(OptionsConstants.QUIRK_POS_REINFORCED_LEGS) - || qName.equals(OptionsConstants.QUIRK_POS_STABLE) - || qName.equals(OptionsConstants.QUIRK_POS_OVERHEAD_ARMS) - || qName.equals(OptionsConstants.QUIRK_POS_COMPACT) - || qName.equals(OptionsConstants.QUIRK_POS_BATTLE_FIST_RA) - || qName.equals(OptionsConstants.QUIRK_POS_BATTLE_FIST_LA) - || qName.equals(OptionsConstants.QUIRK_POS_PRO_ACTUATOR) - || qName.equals(OptionsConstants.QUIRK_NEG_ATMO_INSTABILITY) - || qName.equals(OptionsConstants.QUIRK_NEG_CRAMPED_COCKPIT) - || qName.equals(OptionsConstants.QUIRK_NEG_DIFFICULT_EJECT) - || qName.equals(OptionsConstants.QUIRK_NEG_EXP_ACTUATOR) - || qName.equals(OptionsConstants.QUIRK_NEG_NO_ARMS) - || qName.equals(OptionsConstants.QUIRK_NEG_NO_EJECT) - || qName.equals(OptionsConstants.QUIRK_NEG_NO_TWIST) - || qName.equals(OptionsConstants.QUIRK_NEG_LARGE_DROPPER) - || qName.equals(OptionsConstants.QUIRK_NEG_LOW_ARMS) - || qName.equals(OptionsConstants.QUIRK_NEG_POOR_LIFE_SUPPORT) - || qName.equals(OptionsConstants.QUIRK_NEG_UNBALANCED) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_LEGS) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_UNDERCARRIAGE) - || qName.equals(OptionsConstants.QUIRK_POS_VTOL_ROTOR_COAXIAL) - || qName.equals(OptionsConstants.QUIRK_POS_VTOL_ROTOR_DUAL) - || qName.equals(OptionsConstants.QUIRK_NEG_FLAWED_COOLING) - || qName.equals(OptionsConstants.QUIRK_NEG_UNSTREAMLINED) - || qName.equals(OptionsConstants.QUIRK_NEG_GAS_HOG) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_HEAD_1) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_HEAD_2) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_HEAD_3) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_HEAD_4) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_HEAD_5) - || qName.equals(OptionsConstants.QUIRK_POS_VESTIGIAL_HANDS_LA) - || qName.equals(OptionsConstants.QUIRK_POS_VESTIGIAL_HANDS_RA)) { - return false; - } - - if (qName.equals(OptionsConstants.QUIRK_POS_TRAILER_HITCH) - && (en.getMovementMode() == EntityMovementMode.HOVER)) { - return false; - } - - if (qName.equals(OptionsConstants.QUIRK_POS_TRAILER_HITCH) - && (en.getMovementMode() == EntityMovementMode.VTOL)) { - return false; + if (en instanceof GunEmplacement) { + // Nov 2016 - Reviewed the idea of quirks with Ray from CGL. The working + // made sense to him. Uncertain at this time if CGL would adopt them but + // including them since Quirks is already an option. Hammer + return quirk.isAnyOf(QUIRK_POS_ANTI_AIR, QUIRK_POS_IMP_COM, QUIRK_POS_IMPROVED_SENSORS, + QUIRK_POS_IMP_TARG_S, QUIRK_POS_IMP_TARG_M, QUIRK_POS_IMP_TARG_L, QUIRK_POS_LOW_PROFILE, + QUIRK_NEG_EM_INTERFERENCE_WHOLE, QUIRK_NEG_POOR_TARG_S, QUIRK_NEG_POOR_TARG_M, + QUIRK_NEG_POOR_TARG_L, QUIRK_NEG_POOR_WORK, QUIRK_NEG_SENSOR_GHOSTS); } - - if (qName.equals(OptionsConstants.QUIRK_POS_SCOUT_BIKE)) { - return (en.getMovementMode().isHover() || - en.getMovementMode().isWheeled()) && - (en.getWeight() <= 10.0); + + switch (qName) { + case QUIRK_POS_POWER_REVERSE: + return en.getMovementMode().isTrackedOrWheeled() && !en.isSupportVehicle(); + case QUIRK_NEG_FRAGILE_FUEL: + return !(en.hasEngine() && en.getEngine().isFusion()); + case QUIRK_POS_TRAILER_HITCH: + return !(en.getMovementMode().isHover() || en.getMovementMode().isVTOL()); + case QUIRK_POS_SCOUT_BIKE: + return (en.getMovementMode().isHover() || en.getMovementMode().isWheeled()) + && (en.getWeight() <= 10.0); + case QUIRK_POS_VTOL_ROTOR_COAXIAL: + case QUIRK_POS_VTOL_ROTOR_DUAL: + return en instanceof VTOL; + default: + return quirk.isAnyOf(QUIRK_POS_ANTI_AIR, QUIRK_POS_BATTLE_COMP, QUIRK_POS_EASY_MAINTAIN, + QUIRK_POS_FAST_RELOAD, QUIRK_POS_IMP_COM, QUIRK_POS_IMPROVED_SENSORS, QUIRK_POS_IMP_TARG_S, + QUIRK_POS_IMP_TARG_M, QUIRK_POS_IMP_TARG_L, QUIRK_POS_LOW_PROFILE, QUIRK_POS_SEARCHLIGHT, + QUIRK_NEG_BAD_REP_IS, QUIRK_NEG_BAD_REP_CLAN, QUIRK_NEG_DIFFICULT_MAINTAIN, + QUIRK_NEG_EM_INTERFERENCE_WHOLE, QUIRK_NEG_HARD_PILOT, QUIRK_NEG_NON_STANDARD, + 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_SENSOR_GHOSTS); } - - return true; } - + if (en instanceof BattleArmor) { - if (qName.equals(OptionsConstants.QUIRK_POS_ATMO_FLYER) - || qName.equals(OptionsConstants.QUIRK_POS_ANIMALISTIC) - || qName.equals(OptionsConstants.QUIRK_POS_ANTI_AIR) - || qName.equals(OptionsConstants.QUIRK_POS_BARREL_FIST_LA) - || qName.equals(OptionsConstants.QUIRK_POS_BARREL_FIST_RA) - || qName.equals(OptionsConstants.QUIRK_POS_BATTLE_COMP) - || qName.equals(OptionsConstants.QUIRK_POS_COMBAT_COMPUTER) - || qName.equals(OptionsConstants.QUIRK_POS_COMMAND_MECH) - || qName.equals(OptionsConstants.QUIRK_POS_COWL) - || qName.equals(OptionsConstants.QUIRK_POS_DIRECTIONAL_TORSO_MOUNT) - || qName.equals(OptionsConstants.QUIRK_POS_DOCKING_ARMS) - || qName.equals(OptionsConstants.QUIRK_POS_EXT_TWIST) - || qName.equals(OptionsConstants.QUIRK_POS_FINE_MANIPULATORS) - || qName.equals(OptionsConstants.QUIRK_POS_HYPER_ACTUATOR) - || qName.equals(OptionsConstants.QUIRK_POS_IMPROVED_SENSORS) - || qName.equals(OptionsConstants.QUIRK_POS_IMP_LIFE_SUPPORT) - || qName.equals(OptionsConstants.QUIRK_POS_IMP_TARG_S) - || qName.equals(OptionsConstants.QUIRK_POS_IMP_TARG_M) - || qName.equals(OptionsConstants.QUIRK_POS_IMP_TARG_L) - || qName.equals(OptionsConstants.QUIRK_POS_INTERNAL_BOMB) - || qName.equals(OptionsConstants.QUIRK_POS_LOW_PROFILE) - || qName.equals(OptionsConstants.QUIRK_POS_MULTI_TRAC) - || qName.equals(OptionsConstants.QUIRK_POS_NIMBLE_JUMPER) - || qName.equals(OptionsConstants.QUIRK_POS_REINFORCED_LEGS) - || qName.equals(OptionsConstants.QUIRK_POS_STABLE) - || qName.equals(OptionsConstants.QUIRK_POS_SEARCHLIGHT) - || qName.equals(OptionsConstants.QUIRK_POS_TRAILER_HITCH) - || qName.equals(OptionsConstants.QUIRK_NEG_ATMO_INSTABILITY) - || qName.equals(OptionsConstants.QUIRK_NEG_CRAMPED_COCKPIT) - || qName.equals(OptionsConstants.QUIRK_NEG_DIFFICULT_EJECT) - || qName.equals(OptionsConstants.QUIRK_NEG_EXP_ACTUATOR) - || qName.equals(OptionsConstants.QUIRK_NEG_FRAGILE_FUEL) - || qName.equals(OptionsConstants.QUIRK_NEG_NO_ARMS) - || qName.equals(OptionsConstants.QUIRK_NEG_NO_EJECT) - || qName.equals(OptionsConstants.QUIRK_NEG_NO_TWIST) - || qName.equals(OptionsConstants.QUIRK_NEG_LARGE_DROPPER) - || qName.equals(OptionsConstants.QUIRK_NEG_LOW_ARMS) - || qName.equals(OptionsConstants.QUIRK_NEG_POOR_LIFE_SUPPORT) - || qName.equals(OptionsConstants.QUIRK_NEG_UNBALANCED) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_LEGS) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_UNDERCARRIAGE) - || qName.equals(OptionsConstants.QUIRK_POS_VTOL_ROTOR_COAXIAL) - || qName.equals(OptionsConstants.QUIRK_POS_VTOL_ROTOR_DUAL) - || qName.equals(OptionsConstants.QUIRK_NEG_FLAWED_COOLING) - || qName.equals(OptionsConstants.QUIRK_NEG_UNSTREAMLINED) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_HEAD_1) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_HEAD_2) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_HEAD_3) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_HEAD_4) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_HEAD_5) - || qName.equals(OptionsConstants.QUIRK_NEG_GAS_HOG) - || qName.equals(OptionsConstants.QUIRK_POS_RUMBLE_SEAT) - || qName.equals(OptionsConstants.QUIRK_NEG_POOR_PERFORMANCE) - || qName.equals(OptionsConstants.QUIRK_POS_POWER_REVERSE) - || qName.equals(OptionsConstants.QUIRK_POS_COMPACT) - || qName.equals(OptionsConstants.QUIRK_POS_OVERHEAD_ARMS) - || qName.equals(OptionsConstants.QUIRK_POS_PRO_ACTUATOR) - || qName.equals(OptionsConstants.QUIRK_POS_BATTLE_FIST_LA) - || qName.equals(OptionsConstants.QUIRK_POS_BATTLE_FIST_RA) - || qName.equals(OptionsConstants.QUIRK_POS_VESTIGIAL_HANDS_LA) - || qName.equals(OptionsConstants.QUIRK_POS_VESTIGIAL_HANDS_RA)) { - return false; - } - return true; + return quirk.isAnyOf(QUIRK_NEG_HARD_PILOT, QUIRK_NEG_BAD_REP_IS, QUIRK_NEG_BAD_REP_CLAN, + QUIRK_NEG_DIFFICULT_MAINTAIN, QUIRK_NEG_NON_STANDARD, QUIRK_NEG_POOR_TARG_S, + QUIRK_NEG_POOR_TARG_M, QUIRK_NEG_POOR_TARG_L, QUIRK_NEG_POOR_WORK, QUIRK_NEG_PROTOTYPE, + QUIRK_NEG_SENSOR_GHOSTS, QUIRK_POS_EASY_MAINTAIN, QUIRK_POS_IMP_COM, + QUIRK_POS_EASY_PILOT, QUIRK_POS_FAST_RELOAD, QUIRK_NEG_EM_INTERFERENCE_WHOLE); } - if (en instanceof Jumpship) { - if (qName.equals(OptionsConstants.QUIRK_POS_ATMO_FLYER) - || qName.equals(OptionsConstants.QUIRK_POS_ANIMALISTIC) - || qName.equals(OptionsConstants.QUIRK_POS_ANTI_AIR) - || qName.equals(OptionsConstants.QUIRK_POS_BARREL_FIST_LA) - || qName.equals(OptionsConstants.QUIRK_POS_BARREL_FIST_RA) - || qName.equals(OptionsConstants.QUIRK_POS_BATTLE_COMP) - || qName.equals(OptionsConstants.QUIRK_POS_COMBAT_COMPUTER) - || qName.equals(OptionsConstants.QUIRK_POS_COMMAND_MECH) - || qName.equals(OptionsConstants.QUIRK_POS_COWL) - || qName.equals(OptionsConstants.QUIRK_POS_DIRECTIONAL_TORSO_MOUNT) - || qName.equals(OptionsConstants.QUIRK_POS_DOCKING_ARMS) - || qName.equals(OptionsConstants.QUIRK_POS_EXT_TWIST) - || qName.equals(OptionsConstants.QUIRK_POS_FAST_RELOAD) - || qName.equals(OptionsConstants.QUIRK_POS_FINE_MANIPULATORS) - || qName.equals(OptionsConstants.QUIRK_POS_HYPER_ACTUATOR) - || qName.equals(OptionsConstants.QUIRK_POS_IMPROVED_SENSORS) - || qName.equals(OptionsConstants.QUIRK_POS_IMP_LIFE_SUPPORT) - || qName.equals(OptionsConstants.QUIRK_POS_INTERNAL_BOMB) - || qName.equals(OptionsConstants.QUIRK_POS_MULTI_TRAC) - || qName.equals(OptionsConstants.QUIRK_POS_NIMBLE_JUMPER) - || qName.equals(OptionsConstants.QUIRK_POS_OVERHEAD_ARMS) - || qName.equals(OptionsConstants.QUIRK_POS_LOW_PROFILE) - || qName.equals(OptionsConstants.QUIRK_POS_REINFORCED_LEGS) - || qName.equals(OptionsConstants.QUIRK_POS_STABLE) - || qName.equals(OptionsConstants.QUIRK_POS_TRAILER_HITCH) - || qName.equals(OptionsConstants.QUIRK_POS_SEARCHLIGHT) - || qName.equals(OptionsConstants.QUIRK_POS_VESTIGIAL_HANDS_LA) - || qName.equals(OptionsConstants.QUIRK_POS_VESTIGIAL_HANDS_RA) - || qName.equals(OptionsConstants.QUIRK_NEG_ATMO_INSTABILITY) - || qName.equals(OptionsConstants.QUIRK_NEG_CRAMPED_COCKPIT) - || qName.equals(OptionsConstants.QUIRK_NEG_DIFFICULT_EJECT) - || qName.equals(OptionsConstants.QUIRK_NEG_EXP_ACTUATOR) - || qName.equals(OptionsConstants.QUIRK_NEG_NO_TWIST) - || qName.equals(OptionsConstants.QUIRK_NEG_NO_ARMS) - || qName.equals(OptionsConstants.QUIRK_NEG_NO_EJECT) - || qName.equals(OptionsConstants.QUIRK_NEG_LOW_ARMS) - || qName.equals(OptionsConstants.QUIRK_NEG_LARGE_DROPPER) - || qName.equals(OptionsConstants.QUIRK_NEG_POOR_LIFE_SUPPORT) - || qName.equals(OptionsConstants.QUIRK_NEG_UNBALANCED) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_LEGS) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_UNDERCARRIAGE) - || qName.equals(OptionsConstants.QUIRK_POS_VTOL_ROTOR_COAXIAL) - || qName.equals(OptionsConstants.QUIRK_POS_VTOL_ROTOR_DUAL) - || qName.equals(OptionsConstants.QUIRK_NEG_FLAWED_COOLING) - || qName.equals(OptionsConstants.QUIRK_NEG_UNSTREAMLINED) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_HEAD_1) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_HEAD_2) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_HEAD_3) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_HEAD_4) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_HEAD_5) - || qName.equals(OptionsConstants.QUIRK_NEG_GAS_HOG) - || qName.equals(OptionsConstants.QUIRK_POS_RUMBLE_SEAT) - || qName.equals(OptionsConstants.QUIRK_NEG_POOR_PERFORMANCE) - || qName.equals(OptionsConstants.QUIRK_POS_DISTRACTING) - || qName.equals(OptionsConstants.QUIRK_NEG_POOR_SEALING) - || qName.equals(OptionsConstants.QUIRK_POS_POWER_REVERSE) - || qName.equals(OptionsConstants.QUIRK_POS_COMPACT) - || qName.equals(OptionsConstants.QUIRK_POS_PRO_ACTUATOR) - || qName.equals(OptionsConstants.QUIRK_POS_BATTLE_FIST_LA) - || qName.equals(OptionsConstants.QUIRK_POS_BATTLE_FIST_RA)) { - return false; - } - return true; - } else if (en instanceof Dropship) { - if (qName.equals(OptionsConstants.QUIRK_POS_ANTI_AIR) - || qName.equals(OptionsConstants.QUIRK_POS_ANIMALISTIC) - || qName.equals(OptionsConstants.QUIRK_POS_BARREL_FIST_LA) - || qName.equals(OptionsConstants.QUIRK_POS_BARREL_FIST_RA) - || qName.equals(OptionsConstants.QUIRK_POS_BATTLE_COMP) - || qName.equals(OptionsConstants.QUIRK_POS_COMBAT_COMPUTER) - || qName.equals(OptionsConstants.QUIRK_POS_COMMAND_MECH) - || qName.equals(OptionsConstants.QUIRK_POS_COWL) - || qName.equals(OptionsConstants.QUIRK_POS_DIRECTIONAL_TORSO_MOUNT) - || qName.equals(OptionsConstants.QUIRK_POS_EXT_TWIST) - || qName.equals(OptionsConstants.QUIRK_POS_FINE_MANIPULATORS) - || qName.equals(OptionsConstants.QUIRK_POS_FAST_RELOAD) - || qName.equals(OptionsConstants.QUIRK_POS_HYPER_ACTUATOR) - || qName.equals(OptionsConstants.QUIRK_POS_IMPROVED_SENSORS) - || qName.equals(OptionsConstants.QUIRK_POS_IMP_LIFE_SUPPORT) - || qName.equals(OptionsConstants.QUIRK_POS_MULTI_TRAC) - || qName.equals(OptionsConstants.QUIRK_POS_NIMBLE_JUMPER) - || qName.equals(OptionsConstants.QUIRK_POS_OVERHEAD_ARMS) - || qName.equals(OptionsConstants.QUIRK_POS_LOW_PROFILE) - || qName.equals(OptionsConstants.QUIRK_POS_REINFORCED_LEGS) - || qName.equals(OptionsConstants.QUIRK_POS_SEARCHLIGHT) - || qName.equals(OptionsConstants.QUIRK_POS_TRAILER_HITCH) - || qName.equals(OptionsConstants.QUIRK_NEG_CRAMPED_COCKPIT) - || qName.equals(OptionsConstants.QUIRK_NEG_DIFFICULT_EJECT) - || qName.equals(OptionsConstants.QUIRK_NEG_EXP_ACTUATOR) - || qName.equals(OptionsConstants.QUIRK_NEG_LOW_ARMS) - || qName.equals(OptionsConstants.QUIRK_NEG_NO_ARMS) - || qName.equals(OptionsConstants.QUIRK_NEG_NO_EJECT) - || qName.equals(OptionsConstants.QUIRK_NEG_NO_TWIST) - || qName.equals(OptionsConstants.QUIRK_NEG_POOR_LIFE_SUPPORT) - || qName.equals(OptionsConstants.QUIRK_NEG_UNBALANCED) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_UNDERCARRIAGE) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_LEGS) - || qName.equals(OptionsConstants.QUIRK_POS_VTOL_ROTOR_COAXIAL) - || qName.equals(OptionsConstants.QUIRK_POS_VTOL_ROTOR_DUAL) - || qName.equals(OptionsConstants.QUIRK_NEG_FLAWED_COOLING) - || qName.equals(OptionsConstants.QUIRK_POS_RUMBLE_SEAT) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_HEAD_1) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_HEAD_2) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_HEAD_3) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_HEAD_4) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_HEAD_5) - || qName.equals(OptionsConstants.QUIRK_NEG_POOR_SEALING) - || qName.equals(OptionsConstants.QUIRK_POS_POWER_REVERSE) - || qName.equals(OptionsConstants.QUIRK_POS_STABLE) - || qName.equals(OptionsConstants.QUIRK_POS_COMPACT) - || qName.equals(OptionsConstants.QUIRK_POS_PRO_ACTUATOR) - || qName.equals(OptionsConstants.QUIRK_POS_BATTLE_FIST_LA) - || qName.equals(OptionsConstants.QUIRK_POS_BATTLE_FIST_RA) - || qName.equals(OptionsConstants.QUIRK_POS_VESTIGIAL_HANDS_LA) - || qName.equals(OptionsConstants.QUIRK_POS_VESTIGIAL_HANDS_RA)) { - return false; - } - return true; - } else if (en instanceof Aero) { - if (qName.equals(OptionsConstants.QUIRK_POS_ANTI_AIR) - || qName.equals(OptionsConstants.QUIRK_POS_ANIMALISTIC) - || qName.equals(OptionsConstants.QUIRK_POS_BARREL_FIST_LA) - || qName.equals(OptionsConstants.QUIRK_POS_BARREL_FIST_RA) - || qName.equals(OptionsConstants.QUIRK_POS_BATTLE_COMP) - || qName.equals(OptionsConstants.QUIRK_POS_COMMAND_MECH) - || qName.equals(OptionsConstants.QUIRK_POS_COWL) - || qName.equals(OptionsConstants.QUIRK_POS_DIRECTIONAL_TORSO_MOUNT) - || qName.equals(OptionsConstants.QUIRK_POS_DOCKING_ARMS) - || qName.equals(OptionsConstants.QUIRK_POS_EXT_TWIST) - || qName.equals(OptionsConstants.QUIRK_POS_FINE_MANIPULATORS) - || qName.equals(OptionsConstants.QUIRK_POS_HYPER_ACTUATOR) - || qName.equals(OptionsConstants.QUIRK_POS_IMPROVED_SENSORS) - || qName.equals(OptionsConstants.QUIRK_POS_MULTI_TRAC) - || qName.equals(OptionsConstants.QUIRK_POS_NIMBLE_JUMPER) - || qName.equals(OptionsConstants.QUIRK_POS_OVERHEAD_ARMS) - || qName.equals(OptionsConstants.QUIRK_POS_PRO_ACTUATOR) - || qName.equals(OptionsConstants.QUIRK_POS_LOW_PROFILE) - || qName.equals(OptionsConstants.QUIRK_POS_SEARCHLIGHT) - || qName.equals(OptionsConstants.QUIRK_POS_TRAILER_HITCH) - || qName.equals(OptionsConstants.QUIRK_POS_REINFORCED_LEGS) - || qName.equals(OptionsConstants.QUIRK_NEG_EXP_ACTUATOR) - || qName.equals(OptionsConstants.QUIRK_NEG_FLAWED_COOLING) - || qName.equals(OptionsConstants.QUIRK_NEG_NO_ARMS) - || qName.equals(OptionsConstants.QUIRK_NEG_NO_TWIST) - || qName.equals(OptionsConstants.QUIRK_NEG_LARGE_DROPPER) - || qName.equals(OptionsConstants.QUIRK_NEG_LOW_ARMS) - || qName.equals(OptionsConstants.QUIRK_NEG_UNBALANCED) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_LEGS) - || qName.equals(OptionsConstants.QUIRK_POS_VTOL_ROTOR_COAXIAL) - || qName.equals(OptionsConstants.QUIRK_POS_VTOL_ROTOR_DUAL) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_HEAD_1) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_HEAD_2) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_HEAD_3) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_HEAD_4) - || qName.equals(OptionsConstants.QUIRK_NEG_WEAK_HEAD_5) - || qName.equals(OptionsConstants.QUIRK_NEG_POOR_SEALING) - || qName.equals(OptionsConstants.QUIRK_POS_POWER_REVERSE) - || qName.equals(OptionsConstants.QUIRK_POS_STABLE) - || qName.equals(OptionsConstants.QUIRK_POS_COMPACT) - || qName.equals(OptionsConstants.QUIRK_POS_BATTLE_FIST_RA) - || qName.equals(OptionsConstants.QUIRK_POS_BATTLE_FIST_LA) - || qName.equals(OptionsConstants.QUIRK_POS_VESTIGIAL_HANDS_LA) - || qName.equals(OptionsConstants.QUIRK_POS_VESTIGIAL_HANDS_RA)) { - return false; - } - return true; - } else if (en instanceof Protomech) { - //Not the reverse is true in the code. Returns positivs. - if (qName.equals(OptionsConstants.QUIRK_WEAP_POS_ACCURATE) - || qName.equals(OptionsConstants.QUIRK_POS_ANIMALISTIC) - || qName.equals(OptionsConstants.QUIRK_POS_DISTRACTING) - || qName.equals(OptionsConstants.QUIRK_POS_EASY_MAINTAIN) - || qName.equals(OptionsConstants.QUIRK_POS_EXT_TWIST) - || qName.equals(OptionsConstants.QUIRK_POS_IMP_COM) - || qName.equals(OptionsConstants.QUIRK_POS_IMPROVED_SENSORS) - || qName.equals(OptionsConstants.QUIRK_POS_IMP_TARG_S) - || qName.equals(OptionsConstants.QUIRK_POS_IMP_TARG_M) - || qName.equals(OptionsConstants.QUIRK_POS_IMP_TARG_L) - || qName.equals(OptionsConstants.QUIRK_POS_VAR_RNG_TARG_L) - || qName.equals(OptionsConstants.QUIRK_WEAP_NEG_AMMO_FEED_PROBLEMS) - || qName.equals(OptionsConstants.QUIRK_NEG_BAD_REP_CLAN) - || qName.equals(OptionsConstants.QUIRK_NEG_DIFFICULT_MAINTAIN) - || qName.equals(OptionsConstants.QUIRK_WEAP_NEG_EXPOSED_LINKAGE) - || qName.equals(OptionsConstants.QUIRK_NEG_HARD_PILOT) - || qName.equals(OptionsConstants.QUIRK_WEAP_NEG_INACCURATE) - || qName.equals(OptionsConstants.QUIRK_NEG_NO_TWIST) - || qName.equals(OptionsConstants.QUIRK_NEG_OBSOLETE) - || qName.equals(OptionsConstants.QUIRK_NEG_POOR_PERFORMANCE) - || qName.equals(OptionsConstants.QUIRK_NEG_POOR_SEALING) - || qName.equals(OptionsConstants.QUIRK_NEG_POOR_TARG_S) - || qName.equals(OptionsConstants.QUIRK_NEG_POOR_TARG_M) - || qName.equals(OptionsConstants.QUIRK_NEG_POOR_TARG_L) - || qName.equals(OptionsConstants.QUIRK_NEG_POOR_WORK) - || qName.equals(OptionsConstants.QUIRK_NEG_PROTOTYPE) - || qName.equals(OptionsConstants.QUIRK_POS_PRO_ACTUATOR) - || qName.equals(OptionsConstants.QUIRK_NEG_SENSOR_GHOSTS)) - { + if (en instanceof Aero) { + if (quirk.isAnyOf(QUIRK_NEG_HARD_PILOT, QUIRK_NEG_BAD_REP_IS, QUIRK_NEG_BAD_REP_CLAN, + QUIRK_NEG_DIFFICULT_MAINTAIN, QUIRK_NEG_NON_STANDARD, QUIRK_NEG_POOR_TARG_S, + QUIRK_NEG_POOR_TARG_M, QUIRK_NEG_POOR_TARG_L, QUIRK_NEG_POOR_WORK, QUIRK_NEG_PROTOTYPE, + QUIRK_NEG_SENSOR_GHOSTS, QUIRK_POS_EASY_MAINTAIN, QUIRK_POS_IMP_COM, + QUIRK_POS_EASY_PILOT, QUIRK_POS_IMP_TARG_S, QUIRK_POS_IMP_TARG_M, QUIRK_POS_IMP_TARG_L, + QUIRK_NEG_FRAGILE_FUEL)) { return true; } - return false; + + if (en instanceof Warship) { + return quirk.is(QUIRK_NEG_POOR_PERFORMANCE); + } else if (en instanceof Jumpship) { + return quirk.is(QUIRK_POS_DOCKING_ARMS); + } else if (en instanceof Dropship) { + return quirk.isAnyOf(QUIRK_NEG_ATMO_INSTABILITY, QUIRK_NEG_EM_INTERFERENCE_WHOLE, + QUIRK_NEG_LARGE_DROPPER, QUIRK_NEG_UNSTREAMLINED, QUIRK_NEG_WEAK_UNDERCARRIAGE, + QUIRK_POS_ATMO_FLYER, QUIRK_POS_INTERNAL_BOMB, QUIRK_NEG_POOR_PERFORMANCE); + } else { // Fighter/SmallCraft + return quirk.isAnyOf(QUIRK_NEG_ATMO_INSTABILITY, QUIRK_NEG_CRAMPED_COCKPIT, QUIRK_NEG_DIFFICULT_EJECT, + QUIRK_NEG_EM_INTERFERENCE_WHOLE, QUIRK_NEG_NO_EJECT, QUIRK_NEG_POOR_LIFE_SUPPORT, + QUIRK_NEG_POOR_PERFORMANCE, QUIRK_NEG_UNSTREAMLINED, QUIRK_NEG_WEAK_UNDERCARRIAGE, + QUIRK_POS_ATMO_FLYER, QUIRK_POS_COMBAT_COMPUTER, QUIRK_POS_FAST_RELOAD, + QUIRK_POS_IMP_LIFE_SUPPORT, QUIRK_POS_INTERNAL_BOMB); + } } + if (en instanceof Protomech) { + return quirk.isAnyOf(QUIRK_NEG_HARD_PILOT, QUIRK_NEG_BAD_REP_IS, QUIRK_NEG_BAD_REP_CLAN, + QUIRK_NEG_DIFFICULT_MAINTAIN, QUIRK_NEG_NON_STANDARD, QUIRK_NEG_POOR_TARG_S, + QUIRK_NEG_POOR_TARG_M, QUIRK_NEG_POOR_TARG_L, QUIRK_NEG_POOR_WORK, QUIRK_NEG_PROTOTYPE, + QUIRK_NEG_SENSOR_GHOSTS, QUIRK_POS_EASY_MAINTAIN, QUIRK_POS_IMP_COM, + QUIRK_POS_ANIMALISTIC, QUIRK_POS_DISTRACTING, QUIRK_POS_EXT_TWIST, + QUIRK_POS_IMPROVED_SENSORS, QUIRK_POS_IMP_TARG_S, QUIRK_POS_IMP_TARG_M, QUIRK_POS_IMP_TARG_L, + QUIRK_POS_VAR_RNG_TARG_L, QUIRK_NEG_NO_TWIST, QUIRK_NEG_OBSOLETE, QUIRK_NEG_POOR_PERFORMANCE, + QUIRK_NEG_POOR_SEALING, QUIRK_POS_PRO_ACTUATOR); + } return false; - } private static class QuirksInfo extends AbstractOptionsInfo { - private static boolean initliazed = false; - private static AbstractOptionsInfo instance = new QuirksInfo(); + private static boolean initialized = false; + private static final AbstractOptionsInfo instance = new QuirksInfo(); public static AbstractOptionsInfo getInstance() { - if (!initliazed) { - initliazed = true; + if (!initialized) { + initialized = true; // Create a new dummy Quirks; ensures values initialized // Otherwise, could have issues when loading saved games new Quirks(); @@ -695,4 +295,4 @@ protected QuirksInfo() { super("QuirksInfo"); } } -} +} \ No newline at end of file diff --git a/megamek/src/megamek/common/options/WeaponQuirks.java b/megamek/src/megamek/common/options/WeaponQuirks.java index 4fd0ee37193..0eb60681da6 100644 --- a/megamek/src/megamek/common/options/WeaponQuirks.java +++ b/megamek/src/megamek/common/options/WeaponQuirks.java @@ -17,8 +17,14 @@ import megamek.common.weapons.AmmoWeapon; import megamek.common.weapons.lasers.EnergyWeapon; +import java.util.List; + +import static java.util.stream.Collectors.toList; + /** - * Contains the options determining quirks of the unit + * This class represents the weapon quirks of an individual weapon. Each weapon on a unit has its own + * WeaponQuirks object assigned that contains its specific quirks, see {@link Mounted#getQuirks()}. + * When changing this, note that all options should remain boolean options. * * @author Taharqa (Jay Lawson) */ @@ -73,6 +79,11 @@ protected AbstractOptionsInfo getOptionsInfoImp() { return WeaponQuirksInfo.getInstance(); } + /** @return A list of weapon quirks that are active in this Quirks object. */ + public List activeQuirks() { + return getOptionsList().stream().filter(IOption::booleanValue).collect(toList()); + } + public static boolean isQuirkLegalFor(IOption quirk, Entity en, EquipmentType etype) { String qName = quirk.getName(); From 6cc2ac582493d631ec533bfa0aa674fa0142cc03 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 12 Dec 2023 16:58:08 +0100 Subject: [PATCH 2/2] Quirks update: formatting --- .../src/megamek/common/options/Quirks.java | 97 +++++++++++-------- 1 file changed, 55 insertions(+), 42 deletions(-) diff --git a/megamek/src/megamek/common/options/Quirks.java b/megamek/src/megamek/common/options/Quirks.java index 7639a31f1ac..d7e83c24445 100644 --- a/megamek/src/megamek/common/options/Quirks.java +++ b/megamek/src/megamek/common/options/Quirks.java @@ -186,10 +186,11 @@ public static boolean isQuirkLegalFor(IOption quirk, Entity en) { case QUIRK_POS_COMPACT: return en.getWeight() <= 55; default: - return quirk.isNoneOf(QUIRK_POS_ATMO_FLYER, QUIRK_NEG_ATMO_INSTABILITY, QUIRK_POS_DOCKING_ARMS, - QUIRK_NEG_FRAGILE_FUEL, QUIRK_POS_INTERNAL_BOMB, QUIRK_POS_TRAILER_HITCH, - QUIRK_NEG_LARGE_DROPPER, QUIRK_NEG_WEAK_UNDERCARRIAGE, QUIRK_POS_VTOL_ROTOR_COAXIAL, - QUIRK_POS_VTOL_ROTOR_DUAL, QUIRK_POS_POWER_REVERSE, QUIRK_NEG_UNSTREAMLINED); + return quirk.isNoneOf( + QUIRK_POS_ATMO_FLYER, QUIRK_NEG_ATMO_INSTABILITY, QUIRK_POS_DOCKING_ARMS, + QUIRK_NEG_FRAGILE_FUEL, QUIRK_POS_INTERNAL_BOMB, QUIRK_POS_TRAILER_HITCH, + QUIRK_NEG_LARGE_DROPPER, QUIRK_NEG_WEAK_UNDERCARRIAGE, QUIRK_POS_VTOL_ROTOR_COAXIAL, + QUIRK_POS_VTOL_ROTOR_DUAL, QUIRK_POS_POWER_REVERSE, QUIRK_NEG_UNSTREAMLINED); } } @@ -198,10 +199,12 @@ public static boolean isQuirkLegalFor(IOption quirk, Entity en) { // Nov 2016 - Reviewed the idea of quirks with Ray from CGL. The working // made sense to him. Uncertain at this time if CGL would adopt them but // including them since Quirks is already an option. Hammer - return quirk.isAnyOf(QUIRK_POS_ANTI_AIR, QUIRK_POS_IMP_COM, QUIRK_POS_IMPROVED_SENSORS, - QUIRK_POS_IMP_TARG_S, QUIRK_POS_IMP_TARG_M, QUIRK_POS_IMP_TARG_L, QUIRK_POS_LOW_PROFILE, - QUIRK_NEG_EM_INTERFERENCE_WHOLE, QUIRK_NEG_POOR_TARG_S, QUIRK_NEG_POOR_TARG_M, - QUIRK_NEG_POOR_TARG_L, QUIRK_NEG_POOR_WORK, QUIRK_NEG_SENSOR_GHOSTS); + return quirk.isAnyOf( + QUIRK_POS_ANTI_AIR, QUIRK_POS_IMP_COM, QUIRK_POS_IMPROVED_SENSORS, + QUIRK_POS_IMP_TARG_S, QUIRK_POS_IMP_TARG_M, QUIRK_POS_IMP_TARG_L, + QUIRK_POS_LOW_PROFILE, QUIRK_NEG_POOR_TARG_M, QUIRK_NEG_EM_INTERFERENCE_WHOLE, + QUIRK_NEG_POOR_TARG_S, QUIRK_NEG_POOR_TARG_L, QUIRK_NEG_POOR_WORK, + QUIRK_NEG_SENSOR_GHOSTS); } switch (qName) { @@ -218,31 +221,37 @@ public static boolean isQuirkLegalFor(IOption quirk, Entity en) { case QUIRK_POS_VTOL_ROTOR_DUAL: return en instanceof VTOL; default: - return quirk.isAnyOf(QUIRK_POS_ANTI_AIR, QUIRK_POS_BATTLE_COMP, QUIRK_POS_EASY_MAINTAIN, - QUIRK_POS_FAST_RELOAD, QUIRK_POS_IMP_COM, QUIRK_POS_IMPROVED_SENSORS, QUIRK_POS_IMP_TARG_S, - QUIRK_POS_IMP_TARG_M, QUIRK_POS_IMP_TARG_L, QUIRK_POS_LOW_PROFILE, QUIRK_POS_SEARCHLIGHT, - QUIRK_NEG_BAD_REP_IS, QUIRK_NEG_BAD_REP_CLAN, QUIRK_NEG_DIFFICULT_MAINTAIN, - QUIRK_NEG_EM_INTERFERENCE_WHOLE, QUIRK_NEG_HARD_PILOT, QUIRK_NEG_NON_STANDARD, - 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_SENSOR_GHOSTS); + return quirk.isAnyOf( + QUIRK_POS_ANTI_AIR, QUIRK_POS_BATTLE_COMP, QUIRK_POS_EASY_MAINTAIN, + QUIRK_POS_FAST_RELOAD, QUIRK_POS_IMP_COM, QUIRK_POS_IMPROVED_SENSORS, + QUIRK_POS_IMP_TARG_S, QUIRK_POS_SEARCHLIGHT, QUIRK_NEG_NON_STANDARD, + QUIRK_POS_IMP_TARG_M, QUIRK_POS_IMP_TARG_L, QUIRK_POS_LOW_PROFILE, + QUIRK_NEG_BAD_REP_IS, QUIRK_NEG_BAD_REP_CLAN, QUIRK_NEG_DIFFICULT_MAINTAIN, + QUIRK_NEG_EM_INTERFERENCE_WHOLE, QUIRK_NEG_POOR_PERFORMANCE, + QUIRK_NEG_HARD_PILOT, QUIRK_NEG_POOR_TARG_S, QUIRK_NEG_POOR_TARG_M, + QUIRK_NEG_POOR_TARG_L, QUIRK_NEG_POOR_WORK, QUIRK_NEG_PROTOTYPE, + QUIRK_NEG_SENSOR_GHOSTS); } } if (en instanceof BattleArmor) { - return quirk.isAnyOf(QUIRK_NEG_HARD_PILOT, QUIRK_NEG_BAD_REP_IS, QUIRK_NEG_BAD_REP_CLAN, - QUIRK_NEG_DIFFICULT_MAINTAIN, QUIRK_NEG_NON_STANDARD, QUIRK_NEG_POOR_TARG_S, - QUIRK_NEG_POOR_TARG_M, QUIRK_NEG_POOR_TARG_L, QUIRK_NEG_POOR_WORK, QUIRK_NEG_PROTOTYPE, - QUIRK_NEG_SENSOR_GHOSTS, QUIRK_POS_EASY_MAINTAIN, QUIRK_POS_IMP_COM, - QUIRK_POS_EASY_PILOT, QUIRK_POS_FAST_RELOAD, QUIRK_NEG_EM_INTERFERENCE_WHOLE); + return quirk.isAnyOf( + QUIRK_NEG_HARD_PILOT, QUIRK_NEG_BAD_REP_IS, QUIRK_NEG_BAD_REP_CLAN, + QUIRK_NEG_DIFFICULT_MAINTAIN, QUIRK_NEG_PROTOTYPE, QUIRK_NEG_POOR_TARG_S, + QUIRK_NEG_POOR_TARG_M, QUIRK_NEG_POOR_TARG_L, QUIRK_NEG_POOR_WORK, + QUIRK_NEG_SENSOR_GHOSTS, QUIRK_POS_EASY_MAINTAIN, QUIRK_POS_IMP_COM, + QUIRK_POS_EASY_PILOT, QUIRK_POS_FAST_RELOAD, QUIRK_NEG_EM_INTERFERENCE_WHOLE, + QUIRK_NEG_NON_STANDARD); } if (en instanceof Aero) { - if (quirk.isAnyOf(QUIRK_NEG_HARD_PILOT, QUIRK_NEG_BAD_REP_IS, QUIRK_NEG_BAD_REP_CLAN, - QUIRK_NEG_DIFFICULT_MAINTAIN, QUIRK_NEG_NON_STANDARD, QUIRK_NEG_POOR_TARG_S, - QUIRK_NEG_POOR_TARG_M, QUIRK_NEG_POOR_TARG_L, QUIRK_NEG_POOR_WORK, QUIRK_NEG_PROTOTYPE, - QUIRK_NEG_SENSOR_GHOSTS, QUIRK_POS_EASY_MAINTAIN, QUIRK_POS_IMP_COM, - QUIRK_POS_EASY_PILOT, QUIRK_POS_IMP_TARG_S, QUIRK_POS_IMP_TARG_M, QUIRK_POS_IMP_TARG_L, - QUIRK_NEG_FRAGILE_FUEL)) { + if (quirk.isAnyOf( + QUIRK_NEG_HARD_PILOT, QUIRK_NEG_BAD_REP_IS, QUIRK_NEG_BAD_REP_CLAN, + QUIRK_NEG_DIFFICULT_MAINTAIN, QUIRK_NEG_NON_STANDARD, QUIRK_NEG_POOR_TARG_S, + QUIRK_NEG_POOR_TARG_M, QUIRK_NEG_POOR_TARG_L, QUIRK_NEG_POOR_WORK, + QUIRK_NEG_SENSOR_GHOSTS, QUIRK_POS_EASY_MAINTAIN, QUIRK_POS_IMP_COM, + QUIRK_POS_EASY_PILOT, QUIRK_POS_IMP_TARG_S, QUIRK_POS_IMP_TARG_M, + QUIRK_NEG_FRAGILE_FUEL, QUIRK_NEG_PROTOTYPE, QUIRK_POS_IMP_TARG_L)) { return true; } @@ -251,27 +260,31 @@ public static boolean isQuirkLegalFor(IOption quirk, Entity en) { } else if (en instanceof Jumpship) { return quirk.is(QUIRK_POS_DOCKING_ARMS); } else if (en instanceof Dropship) { - return quirk.isAnyOf(QUIRK_NEG_ATMO_INSTABILITY, QUIRK_NEG_EM_INTERFERENCE_WHOLE, - QUIRK_NEG_LARGE_DROPPER, QUIRK_NEG_UNSTREAMLINED, QUIRK_NEG_WEAK_UNDERCARRIAGE, - QUIRK_POS_ATMO_FLYER, QUIRK_POS_INTERNAL_BOMB, QUIRK_NEG_POOR_PERFORMANCE); + return quirk.isAnyOf( + QUIRK_NEG_ATMO_INSTABILITY, QUIRK_NEG_EM_INTERFERENCE_WHOLE, + QUIRK_NEG_LARGE_DROPPER, QUIRK_NEG_UNSTREAMLINED, QUIRK_NEG_WEAK_UNDERCARRIAGE, + QUIRK_POS_ATMO_FLYER, QUIRK_POS_INTERNAL_BOMB, QUIRK_NEG_POOR_PERFORMANCE); } else { // Fighter/SmallCraft - return quirk.isAnyOf(QUIRK_NEG_ATMO_INSTABILITY, QUIRK_NEG_CRAMPED_COCKPIT, QUIRK_NEG_DIFFICULT_EJECT, - QUIRK_NEG_EM_INTERFERENCE_WHOLE, QUIRK_NEG_NO_EJECT, QUIRK_NEG_POOR_LIFE_SUPPORT, - QUIRK_NEG_POOR_PERFORMANCE, QUIRK_NEG_UNSTREAMLINED, QUIRK_NEG_WEAK_UNDERCARRIAGE, - QUIRK_POS_ATMO_FLYER, QUIRK_POS_COMBAT_COMPUTER, QUIRK_POS_FAST_RELOAD, - QUIRK_POS_IMP_LIFE_SUPPORT, QUIRK_POS_INTERNAL_BOMB); + return quirk.isAnyOf( + QUIRK_NEG_ATMO_INSTABILITY, QUIRK_NEG_CRAMPED_COCKPIT, QUIRK_NEG_DIFFICULT_EJECT, + QUIRK_NEG_EM_INTERFERENCE_WHOLE, QUIRK_NEG_POOR_LIFE_SUPPORT, + QUIRK_NEG_POOR_PERFORMANCE, QUIRK_NEG_UNSTREAMLINED, QUIRK_NEG_WEAK_UNDERCARRIAGE, + QUIRK_POS_ATMO_FLYER, QUIRK_POS_COMBAT_COMPUTER, QUIRK_POS_FAST_RELOAD, + QUIRK_POS_IMP_LIFE_SUPPORT, QUIRK_POS_INTERNAL_BOMB, QUIRK_NEG_NO_EJECT); } } if (en instanceof Protomech) { - return quirk.isAnyOf(QUIRK_NEG_HARD_PILOT, QUIRK_NEG_BAD_REP_IS, QUIRK_NEG_BAD_REP_CLAN, - QUIRK_NEG_DIFFICULT_MAINTAIN, QUIRK_NEG_NON_STANDARD, QUIRK_NEG_POOR_TARG_S, - QUIRK_NEG_POOR_TARG_M, QUIRK_NEG_POOR_TARG_L, QUIRK_NEG_POOR_WORK, QUIRK_NEG_PROTOTYPE, - QUIRK_NEG_SENSOR_GHOSTS, QUIRK_POS_EASY_MAINTAIN, QUIRK_POS_IMP_COM, - QUIRK_POS_ANIMALISTIC, QUIRK_POS_DISTRACTING, QUIRK_POS_EXT_TWIST, - QUIRK_POS_IMPROVED_SENSORS, QUIRK_POS_IMP_TARG_S, QUIRK_POS_IMP_TARG_M, QUIRK_POS_IMP_TARG_L, - QUIRK_POS_VAR_RNG_TARG_L, QUIRK_NEG_NO_TWIST, QUIRK_NEG_OBSOLETE, QUIRK_NEG_POOR_PERFORMANCE, - QUIRK_NEG_POOR_SEALING, QUIRK_POS_PRO_ACTUATOR); + return quirk.isAnyOf( + QUIRK_NEG_HARD_PILOT, QUIRK_NEG_BAD_REP_IS, QUIRK_NEG_BAD_REP_CLAN, + QUIRK_NEG_DIFFICULT_MAINTAIN, QUIRK_NEG_NON_STANDARD, QUIRK_NEG_POOR_TARG_S, + QUIRK_NEG_POOR_TARG_M, QUIRK_NEG_POOR_TARG_L, QUIRK_NEG_POOR_WORK, + QUIRK_NEG_SENSOR_GHOSTS, QUIRK_POS_EASY_MAINTAIN, QUIRK_POS_IMP_COM, + QUIRK_POS_ANIMALISTIC, QUIRK_POS_DISTRACTING, QUIRK_POS_EXT_TWIST, + QUIRK_POS_IMPROVED_SENSORS, QUIRK_POS_IMP_TARG_S, QUIRK_POS_IMP_TARG_M, + QUIRK_POS_VAR_RNG_TARG_L, QUIRK_NEG_NO_TWIST, QUIRK_NEG_OBSOLETE, + QUIRK_NEG_POOR_PERFORMANCE, QUIRK_NEG_PROTOTYPE, QUIRK_POS_IMP_TARG_L, + QUIRK_NEG_POOR_SEALING, QUIRK_POS_PRO_ACTUATOR); } return false;