Skip to content

Commit

Permalink
use OptionsConstants instead of hard-coded strings
Browse files Browse the repository at this point in the history
  • Loading branch information
Algebro7 committed Aug 5, 2024
1 parent f09ccdb commit cab504f
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
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

0 comments on commit cab504f

Please sign in to comment.