Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use OptionsConstants instead of hard-coded strings #5859

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion megamek/src/megamek/common/Compute.java
Original file line number Diff line number Diff line change
Expand Up @@ -2443,7 +2443,7 @@ public static ToHitData getSecondaryTargetMod(Game game, Entity attacker,
if (attacker.getCrew().hasDedicatedGunner()) {
maxPrimary = attacker.getCrew().getCrewType().getMaxPrimaryTargets();
}
if (game.getOptions().booleanOption("tacops_tank_crews")
if (game.getOptions().booleanOption(OptionsConstants.ADVANCED_TACOPS_TANK_CREWS)
&& (attacker instanceof Tank)) {

// If we are a tank, and only have 1 crew then we have some special
Expand Down
2 changes: 1 addition & 1 deletion megamek/src/megamek/common/FighterSquadron.java
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ public void computeSquadronBombLoadout() {
}

// Now that we know our bomb choices, load 'em
int gameTL = TechConstants.getSimpleLevel(game.getOptions().stringOption("techlevel"));
int gameTL = TechConstants.getSimpleLevel(game.getOptions().stringOption(OptionsConstants.ALLOWED_TECHLEVEL));
for (int type = 0; type < BombType.B_NUM; type++) {
for (int i = 0; i < extBombChoices[type]; i++) {
if ((type == BombType.B_ALAMO)
Expand Down
2 changes: 1 addition & 1 deletion megamek/src/megamek/common/IBomber.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ default int getBombPoints(boolean externalOnly) {
*/
default void applyBombs() {
Game game = ((Entity) this).getGame();
int gameTL = TechConstants.getSimpleLevel(game.getOptions().stringOption("techlevel"));
int gameTL = TechConstants.getSimpleLevel(game.getOptions().stringOption(OptionsConstants.ALLOWED_TECHLEVEL));
Integer[] iSorted = new Integer[BombType.B_NUM];
// Apply the largest bombs first because we need to fit larger bombs into a single location
// in LAMs.
Expand Down
4 changes: 3 additions & 1 deletion megamek/src/megamek/common/TechConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package megamek.common;

import megamek.common.options.OptionsConstants;

/**
* Contains some constants representing equipment/unit tech levels
*
Expand Down Expand Up @@ -166,7 +168,7 @@ public static int getTechLevel(String techLevel) {
* @return the Game's tech level as an integer.
*/
public static int getSimpleLevel(Game game) {
return getSimpleLevel(game.getOptions().stringOption("techlevel"));
return getSimpleLevel(game.getOptions().stringOption(OptionsConstants.ALLOWED_TECHLEVEL));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public boolean handle(GamePhase phase, Vector<Report> vPhaseReport) {

// Set Margin of Success/Failure.
toHit.setMoS(roll.getIntValue() - Math.max(2, toHit.getValue()));
bDirect = game.getOptions().booleanOption("tacops_direct_blow")
bDirect = game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_TACOPS_DIRECT_BLOW)
&& ((toHit.getMoS() / 3) >= 1) && (entityTarget != null);
if (bDirect) {
r = new Report(3189);
Expand Down