diff --git a/megamek/src/megamek/common/Entity.java b/megamek/src/megamek/common/Entity.java index 69f2a5a276f..b51eb326d0d 100644 --- a/megamek/src/megamek/common/Entity.java +++ b/megamek/src/megamek/common/Entity.java @@ -15903,4 +15903,12 @@ public Base64Image getBase64Icon() { public boolean countForStrengthSum() { return !isDestroyed() && !isTrapped() && !isPartOfFighterSquadron(); } + + /** @return True if the unit should use Edge based on the current options and assigned Edge points */ + public boolean shouldUseEdge(String option) { + return (game.getOptions().booleanOption(OptionsConstants.EDGE) + && getCrew() != null + && getCrew().hasEdgeRemaining() + && getCrew().getOptions().booleanOption(option)); + } } \ No newline at end of file diff --git a/megamek/src/megamek/common/Mech.java b/megamek/src/megamek/common/Mech.java index d9425f84968..f7ab1efbc9f 100644 --- a/megamek/src/megamek/common/Mech.java +++ b/megamek/src/megamek/common/Mech.java @@ -1971,8 +1971,7 @@ public HitData rollHitLocation(int table, int side, int aimedLocation, AimingMod // normal front hits switch (roll) { case 2: - if ((getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_TAC)) + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_TAC) && !game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_NO_TAC)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); @@ -1997,9 +1996,7 @@ && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_TAC)) case 11: return new HitData(Mech.LOC_LARM); case 12: - if (getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption( - OptionsConstants.EDGE_WHEN_HEADHIT)) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); @@ -2012,8 +2009,7 @@ && getCrew().getOptions().booleanOption( // normal left side hits switch (roll) { case 2: - if ((getCrew().hasEdgeRemaining() && getCrew() - .getOptions().booleanOption(OptionsConstants.EDGE_WHEN_TAC)) + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_TAC) && !game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_NO_TAC)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, @@ -2049,9 +2045,7 @@ && getCrew().getOptions().booleanOption( case 11: return new HitData(Mech.LOC_RLEG); case 12: - if (getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption( - OptionsConstants.EDGE_WHEN_HEADHIT)) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); @@ -2064,8 +2058,7 @@ && getCrew().getOptions().booleanOption( // normal right side hits switch (roll) { case 2: - if ((getCrew().hasEdgeRemaining() && getCrew() - .getOptions().booleanOption(OptionsConstants.EDGE_WHEN_TAC)) + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_TAC) && !game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_NO_TAC)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, @@ -2101,9 +2094,7 @@ && getCrew().getOptions().booleanOption( case 11: return new HitData(Mech.LOC_LLEG); case 12: - if (getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption( - OptionsConstants.EDGE_WHEN_HEADHIT)) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); @@ -2119,9 +2110,7 @@ && getCrew().getOptions().booleanOption( && isProne()) { switch (roll) { case 2: - if ((getCrew().hasEdgeRemaining() && getCrew() - .getOptions() - .booleanOption(OptionsConstants.EDGE_WHEN_TAC)) + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_TAC) && !game.getOptions().booleanOption( OptionsConstants.ADVCOMBAT_NO_TAC)) { getCrew().decreaseEdge(); @@ -2149,9 +2138,7 @@ && isProne()) { case 11: return new HitData(Mech.LOC_LARM, true); case 12: - if (getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption( - OptionsConstants.EDGE_WHEN_HEADHIT)) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); @@ -2164,9 +2151,7 @@ && getCrew().getOptions().booleanOption( } else { switch (roll) { case 2: - if ((getCrew().hasEdgeRemaining() && getCrew() - .getOptions() - .booleanOption(OptionsConstants.EDGE_WHEN_TAC)) + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_TAC) && !game.getOptions().booleanOption( OptionsConstants.ADVCOMBAT_NO_TAC)) { getCrew().decreaseEdge(); @@ -2194,9 +2179,7 @@ && getCrew().getOptions().booleanOption( case 11: return new HitData(Mech.LOC_LARM, true); case 12: - if (getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption( - OptionsConstants.EDGE_WHEN_HEADHIT)) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); @@ -2239,9 +2222,7 @@ && getCrew().getOptions().booleanOption( case 5: return new HitData(Mech.LOC_RARM); case 6: - if (getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption( - OptionsConstants.EDGE_WHEN_HEADHIT)) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); @@ -2263,9 +2244,7 @@ && getCrew().getOptions().booleanOption( case 5: return new HitData(Mech.LOC_LARM); case 6: - if (getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption( - OptionsConstants.EDGE_WHEN_HEADHIT)) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); @@ -2287,9 +2266,7 @@ && getCrew().getOptions().booleanOption( case 5: return new HitData(Mech.LOC_RARM); case 6: - if (getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption( - OptionsConstants.EDGE_WHEN_HEADHIT)) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); @@ -2313,9 +2290,7 @@ && getCrew().getOptions().booleanOption( case 5: return new HitData(Mech.LOC_RARM, true); case 6: - if (getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption( - OptionsConstants.EDGE_WHEN_HEADHIT)) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); @@ -2392,8 +2367,7 @@ && getCrew().getOptions().booleanOption( // Swarm attack locations. switch (roll) { case 2: - if (getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_HEADHIT)) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); result.setUndoneLocation(new HitData(Mech.LOC_HEAD, false, effects)); @@ -2419,9 +2393,7 @@ && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_HEADHIT)) { case 11: return new HitData(Mech.LOC_CT, true, effects); case 12: - if (getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption( - OptionsConstants.EDGE_WHEN_HEADHIT)) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); @@ -2460,9 +2432,7 @@ && getCrew().getOptions().booleanOption( case 5: return new HitData(Mech.LOC_RARM, (side == ToHitData.SIDE_REAR)); case 6: - if (getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption( - OptionsConstants.EDGE_WHEN_HEADHIT)) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); diff --git a/megamek/src/megamek/common/QuadMech.java b/megamek/src/megamek/common/QuadMech.java index 83bc3ca0b02..284a93514ca 100644 --- a/megamek/src/megamek/common/QuadMech.java +++ b/megamek/src/megamek/common/QuadMech.java @@ -458,9 +458,8 @@ public HitData rollHitLocation(int table, int side, int aimedLocation, AimingMod // normal front hits switch (roll) { case 2: - if ((getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_TAC)) - && !game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_NO_TAC)) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_TAC) + && !game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_NO_TAC)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); result.setUndoneLocation(tac(table, side, Mech.LOC_CT, cover, false)); @@ -484,8 +483,7 @@ && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_TAC)) case 11: return new HitData(Mech.LOC_RLEG); case 12: - if ((getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_HEADHIT))) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); result.setUndoneLocation(new HitData(Mech.LOC_HEAD)); @@ -496,9 +494,8 @@ && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_HEADHIT))) { } else if (side == ToHitData.SIDE_REAR) { switch (roll) { case 2: - if ((getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_TAC)) - && !game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_NO_TAC)) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_TAC) + && !game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_NO_TAC)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); result.setUndoneLocation(tac(table, side, Mech.LOC_CT, cover, true)); @@ -522,8 +519,7 @@ && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_TAC)) case 11: return new HitData(Mech.LOC_RARM, true); case 12: - if ((getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_HEADHIT))) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); result.setUndoneLocation(new HitData(Mech.LOC_HEAD, true)); @@ -534,9 +530,8 @@ && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_HEADHIT))) { } else if (side == ToHitData.SIDE_LEFT) { switch (roll) { case 2: - if ((getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_TAC)) - && !game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_NO_TAC)) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_TAC) + && !game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_NO_TAC)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); result.setUndoneLocation(tac(table, side, Mech.LOC_LT, cover, false)); @@ -560,8 +555,7 @@ && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_TAC)) case 11: return new HitData(Mech.LOC_RLEG); case 12: - if ((getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_HEADHIT))) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); result.setUndoneLocation(new HitData(Mech.LOC_HEAD)); @@ -572,9 +566,8 @@ && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_HEADHIT))) { } else if (side == ToHitData.SIDE_RIGHT) { switch (roll) { case 2: - if ((getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_TAC)) - && !game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_NO_TAC)) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_TAC) + && !game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_NO_TAC)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); result.setUndoneLocation(tac(table, side, Mech.LOC_RT, cover, false)); @@ -598,8 +591,7 @@ && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_TAC)) case 11: return new HitData(Mech.LOC_LLEG); case 12: - if ((getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_HEADHIT))) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); result.setUndoneLocation(new HitData(Mech.LOC_HEAD)); @@ -639,8 +631,7 @@ && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_HEADHIT))) { case 5: return new HitData(Mech.LOC_RARM); case 6: - if (getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_HEADHIT)) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); result.setUndoneLocation(new HitData(Mech.LOC_HEAD, true)); @@ -661,8 +652,7 @@ && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_HEADHIT)) { case 5: return new HitData(Mech.LOC_RLEG, true); case 6: - if (getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_HEADHIT)) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); result.setUndoneLocation(new HitData(Mech.LOC_HEAD, true)); @@ -682,8 +672,7 @@ && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_HEADHIT)) { case 5: return new HitData(Mech.LOC_LLEG); case 6: - if (getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_HEADHIT)) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); result.setUndoneLocation(new HitData(Mech.LOC_HEAD, true)); @@ -703,8 +692,7 @@ && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_HEADHIT)) { case 5: return new HitData(Mech.LOC_RLEG); case 6: - if (getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_HEADHIT)) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); result.setUndoneLocation(new HitData(Mech.LOC_HEAD, true)); @@ -773,8 +761,7 @@ && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_HEADHIT)) { // Swarm attack locations. switch (roll) { case 2: - if (getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_HEADHIT)) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); result.setUndoneLocation(new HitData(Mech.LOC_HEAD, false, effects)); @@ -800,8 +787,7 @@ && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_HEADHIT)) { case 11: return new HitData(Mech.LOC_LT, false, effects); case 12: - if (getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_HEADHIT)) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); result.setUndoneLocation(new HitData(Mech.LOC_HEAD, false, effects)); diff --git a/megamek/src/megamek/common/TripodMech.java b/megamek/src/megamek/common/TripodMech.java index 92ee039874d..c5bcac64763 100644 --- a/megamek/src/megamek/common/TripodMech.java +++ b/megamek/src/megamek/common/TripodMech.java @@ -1029,8 +1029,7 @@ public HitData rollHitLocation(int table, int side, int aimedLocation, AimingMod // normal front hits switch (roll) { case 2: - if ((getCrew().hasEdgeRemaining() && getCrew() - .getOptions().booleanOption(OptionsConstants.EDGE_WHEN_TAC)) + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_TAC) && !game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_NO_TAC)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, @@ -1063,9 +1062,7 @@ public HitData rollHitLocation(int table, int side, int aimedLocation, AimingMod case 11: return new HitData(Mech.LOC_LARM); case 12: - if (getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption( - "edge_when_headhit")) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); @@ -1078,8 +1075,7 @@ && getCrew().getOptions().booleanOption( // normal left side hits switch (roll) { case 2: - if ((getCrew().hasEdgeRemaining() && getCrew() - .getOptions().booleanOption(OptionsConstants.EDGE_WHEN_TAC)) + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_TAC) && !game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_NO_TAC)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, @@ -1120,9 +1116,7 @@ && getCrew().getOptions().booleanOption( case 10: return new HitData(Mech.LOC_RARM); case 12: - if (getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption( - "edge_when_headhit")) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); @@ -1135,8 +1129,7 @@ && getCrew().getOptions().booleanOption( // normal right side hits switch (roll) { case 2: - if ((getCrew().hasEdgeRemaining() && getCrew() - .getOptions().booleanOption(OptionsConstants.EDGE_WHEN_TAC)) + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_TAC) && !game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_NO_TAC)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, @@ -1177,9 +1170,7 @@ && getCrew().getOptions().booleanOption( case 10: return new HitData(Mech.LOC_LARM); case 12: - if (getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption( - "edge_when_headhit")) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); @@ -1195,9 +1186,7 @@ && getCrew().getOptions().booleanOption( && isProne()) { switch (roll) { case 2: - if ((getCrew().hasEdgeRemaining() && getCrew() - .getOptions() - .booleanOption(OptionsConstants.EDGE_WHEN_TAC)) + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_TAC) && !game.getOptions().booleanOption( OptionsConstants.ADVCOMBAT_NO_TAC)) { getCrew().decreaseEdge(); @@ -1231,9 +1220,7 @@ && isProne()) { case 11: return new HitData(Mech.LOC_LARM, true); case 12: - if (getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption( - "edge_when_headhit")) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); @@ -1246,9 +1233,7 @@ && getCrew().getOptions().booleanOption( } else { switch (roll) { case 2: - if ((getCrew().hasEdgeRemaining() && getCrew() - .getOptions() - .booleanOption(OptionsConstants.EDGE_WHEN_TAC)) + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_TAC) && !game.getOptions().booleanOption( OptionsConstants.ADVCOMBAT_NO_TAC)) { getCrew().decreaseEdge(); @@ -1282,9 +1267,7 @@ && getCrew().getOptions().booleanOption( case 11: return new HitData(Mech.LOC_LARM, true); case 12: - if (getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption( - "edge_when_headhit")) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); @@ -1327,9 +1310,7 @@ && getCrew().getOptions().booleanOption( case 5: return new HitData(Mech.LOC_RARM); case 6: - if (getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption( - "edge_when_headhit")) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); @@ -1351,9 +1332,7 @@ && getCrew().getOptions().booleanOption( case 5: return new HitData(Mech.LOC_LARM); case 6: - if (getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption( - "edge_when_headhit")) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); @@ -1375,9 +1354,7 @@ && getCrew().getOptions().booleanOption( case 5: return new HitData(Mech.LOC_RARM); case 6: - if (getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption( - "edge_when_headhit")) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); @@ -1401,9 +1378,7 @@ && getCrew().getOptions().booleanOption( case 5: return new HitData(Mech.LOC_RARM, true); case 6: - if (getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption( - "edge_when_headhit")) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); @@ -1491,9 +1466,7 @@ && getCrew().getOptions().booleanOption( // Swarm attack locations. switch (roll) { case 2: - if (getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption( - "edge_when_headhit")) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); @@ -1521,9 +1494,7 @@ && getCrew().getOptions().booleanOption( case 11: return new HitData(Mech.LOC_CT, true, effects); case 12: - if (getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption( - "edge_when_headhit")) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); @@ -1562,9 +1533,7 @@ && getCrew().getOptions().booleanOption( case 5: return new HitData(Mech.LOC_RARM, (side == ToHitData.SIDE_REAR)); case 6: - if (getCrew().hasEdgeRemaining() - && getCrew().getOptions().booleanOption( - "edge_when_headhit")) { + if (shouldUseEdge(OptionsConstants.EDGE_WHEN_HEADHIT)) { getCrew().decreaseEdge(); HitData result = rollHitLocation(table, side, aimedLocation, aimingMode, cover); diff --git a/megamek/src/megamek/server/GameManager.java b/megamek/src/megamek/server/GameManager.java index 2eca511c570..4b5e9c3166d 100644 --- a/megamek/src/megamek/server/GameManager.java +++ b/megamek/src/megamek/server/GameManager.java @@ -8612,9 +8612,7 @@ private boolean checkMASCFailure(Entity entity, MovePath md) { if (entity.checkForMASCFailure(md, vReport, crits)) { boolean mascFailure = true; // Check to see if the pilot can reroll due to Edge - if (entity.getCrew().hasEdgeRemaining() - && entity.getCrew().getOptions() - .booleanOption(OptionsConstants.EDGE_WHEN_MASC_FAILS)) { + if (entity.shouldUseEdge(OptionsConstants.EDGE_WHEN_MASC_FAILS)) { entity.getCrew().decreaseEdge(); // Need to reset the MASCUsed flag entity.setMASCUsed(false); @@ -8665,9 +8663,7 @@ private boolean checkSuperchargerFailure(Entity entity, MovePath md) { if (entity.checkForSuperchargerFailure(md, vReport, crits)) { boolean superchargerFailure = true; // Check to see if the pilot can reroll due to Edge - if (entity.getCrew().hasEdgeRemaining() - && entity.getCrew().getOptions() - .booleanOption(OptionsConstants.EDGE_WHEN_MASC_FAILS)) { + if (entity.shouldUseEdge(OptionsConstants.EDGE_WHEN_MASC_FAILS)) { entity.getCrew().decreaseEdge(); // Need to reset the SuperchargerUsed flag entity.setSuperchargerUsed(false); @@ -20057,8 +20053,7 @@ private Vector resolveControl(Entity e) { if (e.getAltitude() <= 0 // Don't waste the edge if it won't help && origAltitude > 1 - && e.getCrew().hasEdgeRemaining() - && e.getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_AERO_ALT_LOSS)) { + && e.shouldUseEdge(OptionsConstants.EDGE_WHEN_AERO_ALT_LOSS)) { Roll diceRoll3 = Compute.rollD6(1); int rollValue3 = diceRoll3.getIntValue(); String rollReport3 = diceRoll3.getReport(); @@ -20443,9 +20438,8 @@ private Vector resolveCrewDamage(Entity e, int damage, int crewPos) { } else { e.getCrew().setKoThisRound(true, crewPos); r.choose(false); - if (e.getCrew().hasEdgeRemaining() - && (e.getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_KO) - || e.getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_AERO_KO))) { + if (e.shouldUseEdge(OptionsConstants.EDGE_WHEN_KO) + || e.shouldUseEdge(OptionsConstants.EDGE_WHEN_AERO_KO)) { edgeUsed = true; vDesc.add(r); r = new Report(6520); @@ -20457,10 +20451,9 @@ private Vector resolveCrewDamage(Entity e, int damage, int crewPos) { // return true; } // else vDesc.add(r); - } while (e.getCrew().hasEdgeRemaining() - && e.getCrew().isKoThisRound(crewPos) - && (e.getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_KO) - || e.getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_AERO_KO))); + } while ((e.shouldUseEdge(OptionsConstants.EDGE_WHEN_KO) + && e.getCrew().isKoThisRound(crewPos)) + || e.shouldUseEdge(OptionsConstants.EDGE_WHEN_AERO_KO)); // end of do-while if (e.getCrew().isKoThisRound(crewPos)) { boolean wasPilot = e.getCrew().getCurrentPilotIndex() == crewPos; @@ -24222,9 +24215,7 @@ private Vector applyAeroCritical(Aero aero, int loc, CriticalSlot cs, in r.subject = aero.getId(); if (fuelroll >= boomTarget) { // A chance to reroll the explosion with edge - if (aero.getCrew().hasEdgeRemaining() - && aero.getCrew().getOptions().booleanOption( - OptionsConstants.EDGE_WHEN_AERO_EXPLOSION)) { + if (aero.shouldUseEdge(OptionsConstants.EDGE_WHEN_AERO_EXPLOSION)) { // Reporting this is funky because 9120 only has room for 2 choices. Replace it. r = new Report(9123); r.subject = aero.getId(); @@ -24468,8 +24459,7 @@ private Vector applyAeroCritical(Aero aero, int loc, CriticalSlot cs, in boomTarget = 10; r.choose(ammoRoll >= boomTarget); // A chance to reroll an explosion with edge - if (aero.getCrew().hasEdgeRemaining() - && aero.getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_AERO_EXPLOSION) + if (aero.shouldUseEdge(OptionsConstants.EDGE_WHEN_AERO_EXPLOSION) && ammoRoll >= boomTarget) { // Report 9156 doesn't offer the right choices. Replace it. r = new Report(9158); @@ -24523,8 +24513,7 @@ private Vector applyAeroCritical(Aero aero, int loc, CriticalSlot cs, in int ammoroll = Compute.d6(2); if (ammoroll >= 10) { // A chance to reroll an explosion with edge - if (aero.getCrew().hasEdgeRemaining() - && aero.getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_AERO_EXPLOSION)) { + if (aero.shouldUseEdge(OptionsConstants.EDGE_WHEN_AERO_EXPLOSION)) { aero.getCrew().decreaseEdge(); r = new Report(6530); r.subject = aero.getId(); @@ -24552,8 +24541,7 @@ private Vector applyAeroCritical(Aero aero, int loc, CriticalSlot cs, in } } // If the weapon is explosive, use edge to roll up a new one - if (aero.getCrew().hasEdgeRemaining() - && aero.getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_AERO_EXPLOSION) + if (aero.shouldUseEdge(OptionsConstants.EDGE_WHEN_AERO_EXPLOSION) && (equipmentHit.getType().isExplosive(equipmentHit) && !equipmentHit.isHit() && !equipmentHit.isDestroyed())) { aero.getCrew().decreaseEdge(); @@ -24825,8 +24813,7 @@ private void applyCargoCritical(Aero aero, int damageCaused, Vector repo int roll = Compute.d6(1); // A hit on a bay filled with transported units is devastating // allow a reroll with edge - if (aero.getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_AERO_UNIT_CARGO_LOST) - && aero.getCrew().hasEdgeRemaining() && roll > 3) { + if (aero.shouldUseEdge(OptionsConstants.EDGE_WHEN_AERO_UNIT_CARGO_LOST) && roll > 3) { aero.getCrew().decreaseEdge(); r = new Report(9172); r.subject = aero.getId(); @@ -25859,7 +25846,7 @@ private void checkAeroCrits(Vector vDesc, Aero a, HitData hit, if (diceRoll.getIntValue() >= capitalMissile) { // Allow a reroll with edge - if (a.getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_AERO_NUKE_CRIT) + if (a.shouldUseEdge(OptionsConstants.EDGE_WHEN_AERO_NUKE_CRIT) && a.getCrew().hasEdgeRemaining()) { a.getCrew().decreaseEdge(); r = new Report(9148); @@ -25913,8 +25900,7 @@ private void checkAeroCrits(Vector vDesc, Aero a, HitData hit, if (hit.rolledBoxCars()) { if (hit.isFirstHit()) { // Allow edge use to ignore the critical roll - if (a.getCrew().getOptions().booleanOption(OptionsConstants.EDGE_WHEN_AERO_LUCKY_CRIT) - && a.getCrew().hasEdgeRemaining()) { + if (a.shouldUseEdge(OptionsConstants.EDGE_WHEN_AERO_LUCKY_CRIT)) { a.getCrew().decreaseEdge(); r = new Report(9103); r.subject = a.getId(); @@ -26280,8 +26266,7 @@ public Vector criticalEntity(Entity en, int loc, boolean isRear, } // if explosive use edge if ((en instanceof Mech) - && (en.getCrew().hasEdgeRemaining() && en.getCrew().getOptions() - .booleanOption(OptionsConstants.EDGE_WHEN_EXPLOSION)) + && en.shouldUseEdge(OptionsConstants.EDGE_WHEN_EXPLOSION) && (slot.getType() == CriticalSlot.TYPE_EQUIPMENT) && slot.getMount().getType().isExplosive(slot.getMount())) { en.getCrew().decreaseEdge();