Skip to content

Commit

Permalink
check if Edge is enabled in Game Options before using it
Browse files Browse the repository at this point in the history
  • Loading branch information
Algebro7 committed Aug 5, 2024
1 parent f09ccdb commit 74ead35
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 66 deletions.
51 changes: 34 additions & 17 deletions megamek/src/megamek/common/Mech.java
Original file line number Diff line number Diff line change
Expand Up @@ -1971,7 +1971,8 @@ public HitData rollHitLocation(int table, int side, int aimedLocation, AimingMod
// normal front hits
switch (roll) {
case 2:
if ((getCrew().hasEdgeRemaining()
if (game.getOptions().booleanOption(OptionsConstants.EDGE)
&& (getCrew().hasEdgeRemaining()
&& getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_TAC))
&& !game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_NO_TAC)) {
getCrew().decreaseEdge();
Expand All @@ -1997,7 +1998,8 @@ && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_TAC))
case 11:
return new HitData(Mech.LOC_LARM);
case 12:
if (getCrew().hasEdgeRemaining()
if (game.getOptions().booleanOption(OptionsConstants.EDGE)
&& getCrew().hasEdgeRemaining()
&& getCrew().getOptions().booleanOption(
OptionsConstants.EDGE_WHEN_HEADHIT)) {
getCrew().decreaseEdge();
Expand All @@ -2012,7 +2014,8 @@ && getCrew().getOptions().booleanOption(
// normal left side hits
switch (roll) {
case 2:
if ((getCrew().hasEdgeRemaining() && getCrew()
if (game.getOptions().booleanOption(OptionsConstants.EDGE)
&& (getCrew().hasEdgeRemaining() && getCrew()
.getOptions().booleanOption(OptionsConstants.EDGE_WHEN_TAC))
&& !game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_NO_TAC)) {
getCrew().decreaseEdge();
Expand Down Expand Up @@ -2049,7 +2052,8 @@ && getCrew().getOptions().booleanOption(
case 11:
return new HitData(Mech.LOC_RLEG);
case 12:
if (getCrew().hasEdgeRemaining()
if (game.getOptions().booleanOption(OptionsConstants.EDGE)
&& getCrew().hasEdgeRemaining()
&& getCrew().getOptions().booleanOption(
OptionsConstants.EDGE_WHEN_HEADHIT)) {
getCrew().decreaseEdge();
Expand All @@ -2064,7 +2068,8 @@ && getCrew().getOptions().booleanOption(
// normal right side hits
switch (roll) {
case 2:
if ((getCrew().hasEdgeRemaining() && getCrew()
if (game.getOptions().booleanOption(OptionsConstants.EDGE)
&& (getCrew().hasEdgeRemaining() && getCrew()
.getOptions().booleanOption(OptionsConstants.EDGE_WHEN_TAC))
&& !game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_NO_TAC)) {
getCrew().decreaseEdge();
Expand Down Expand Up @@ -2101,7 +2106,8 @@ && getCrew().getOptions().booleanOption(
case 11:
return new HitData(Mech.LOC_LLEG);
case 12:
if (getCrew().hasEdgeRemaining()
if (game.getOptions().booleanOption(OptionsConstants.EDGE)
&& getCrew().hasEdgeRemaining()
&& getCrew().getOptions().booleanOption(
OptionsConstants.EDGE_WHEN_HEADHIT)) {
getCrew().decreaseEdge();
Expand All @@ -2119,7 +2125,8 @@ && getCrew().getOptions().booleanOption(
&& isProne()) {
switch (roll) {
case 2:
if ((getCrew().hasEdgeRemaining() && getCrew()
if (game.getOptions().booleanOption(OptionsConstants.EDGE)
&& (getCrew().hasEdgeRemaining() && getCrew()
.getOptions()
.booleanOption(OptionsConstants.EDGE_WHEN_TAC))
&& !game.getOptions().booleanOption(
Expand Down Expand Up @@ -2149,7 +2156,8 @@ && isProne()) {
case 11:
return new HitData(Mech.LOC_LARM, true);
case 12:
if (getCrew().hasEdgeRemaining()
if (game.getOptions().booleanOption(OptionsConstants.EDGE)
&& getCrew().hasEdgeRemaining()
&& getCrew().getOptions().booleanOption(
OptionsConstants.EDGE_WHEN_HEADHIT)) {
getCrew().decreaseEdge();
Expand All @@ -2164,7 +2172,8 @@ && getCrew().getOptions().booleanOption(
} else {
switch (roll) {
case 2:
if ((getCrew().hasEdgeRemaining() && getCrew()
if (game.getOptions().booleanOption(OptionsConstants.EDGE)
&& (getCrew().hasEdgeRemaining() && getCrew()
.getOptions()
.booleanOption(OptionsConstants.EDGE_WHEN_TAC))
&& !game.getOptions().booleanOption(
Expand Down Expand Up @@ -2194,7 +2203,8 @@ && getCrew().getOptions().booleanOption(
case 11:
return new HitData(Mech.LOC_LARM, true);
case 12:
if (getCrew().hasEdgeRemaining()
if (game.getOptions().booleanOption(OptionsConstants.EDGE)
&& getCrew().hasEdgeRemaining()
&& getCrew().getOptions().booleanOption(
OptionsConstants.EDGE_WHEN_HEADHIT)) {
getCrew().decreaseEdge();
Expand Down Expand Up @@ -2239,7 +2249,8 @@ && getCrew().getOptions().booleanOption(
case 5:
return new HitData(Mech.LOC_RARM);
case 6:
if (getCrew().hasEdgeRemaining()
if (game.getOptions().booleanOption(OptionsConstants.EDGE)
&& getCrew().hasEdgeRemaining()
&& getCrew().getOptions().booleanOption(
OptionsConstants.EDGE_WHEN_HEADHIT)) {
getCrew().decreaseEdge();
Expand All @@ -2263,7 +2274,8 @@ && getCrew().getOptions().booleanOption(
case 5:
return new HitData(Mech.LOC_LARM);
case 6:
if (getCrew().hasEdgeRemaining()
if (game.getOptions().booleanOption(OptionsConstants.EDGE)
&& getCrew().hasEdgeRemaining()
&& getCrew().getOptions().booleanOption(
OptionsConstants.EDGE_WHEN_HEADHIT)) {
getCrew().decreaseEdge();
Expand All @@ -2287,7 +2299,8 @@ && getCrew().getOptions().booleanOption(
case 5:
return new HitData(Mech.LOC_RARM);
case 6:
if (getCrew().hasEdgeRemaining()
if (game.getOptions().booleanOption(OptionsConstants.EDGE)
&& getCrew().hasEdgeRemaining()
&& getCrew().getOptions().booleanOption(
OptionsConstants.EDGE_WHEN_HEADHIT)) {
getCrew().decreaseEdge();
Expand All @@ -2313,7 +2326,8 @@ && getCrew().getOptions().booleanOption(
case 5:
return new HitData(Mech.LOC_RARM, true);
case 6:
if (getCrew().hasEdgeRemaining()
if (game.getOptions().booleanOption(OptionsConstants.EDGE)
&& getCrew().hasEdgeRemaining()
&& getCrew().getOptions().booleanOption(
OptionsConstants.EDGE_WHEN_HEADHIT)) {
getCrew().decreaseEdge();
Expand Down Expand Up @@ -2392,7 +2406,8 @@ && getCrew().getOptions().booleanOption(
// Swarm attack locations.
switch (roll) {
case 2:
if (getCrew().hasEdgeRemaining()
if (game.getOptions().booleanOption(OptionsConstants.EDGE)
&& getCrew().hasEdgeRemaining()
&& getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_HEADHIT)) {
getCrew().decreaseEdge();
HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover);
Expand All @@ -2419,7 +2434,8 @@ && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_HEADHIT)) {
case 11:
return new HitData(Mech.LOC_CT, true, effects);
case 12:
if (getCrew().hasEdgeRemaining()
if (game.getOptions().booleanOption(OptionsConstants.EDGE)
&& getCrew().hasEdgeRemaining()
&& getCrew().getOptions().booleanOption(
OptionsConstants.EDGE_WHEN_HEADHIT)) {
getCrew().decreaseEdge();
Expand Down Expand Up @@ -2460,7 +2476,8 @@ && getCrew().getOptions().booleanOption(
case 5:
return new HitData(Mech.LOC_RARM, (side == ToHitData.SIDE_REAR));
case 6:
if (getCrew().hasEdgeRemaining()
if (game.getOptions().booleanOption(OptionsConstants.EDGE)
&& getCrew().hasEdgeRemaining()
&& getCrew().getOptions().booleanOption(
OptionsConstants.EDGE_WHEN_HEADHIT)) {
getCrew().decreaseEdge();
Expand Down
Loading

0 comments on commit 74ead35

Please sign in to comment.