Skip to content

Commit

Permalink
refactor: Use stream composition for C3 with active probes
Browse files Browse the repository at this point in the history
  • Loading branch information
Saklad5 committed Aug 24, 2024
1 parent 12ed947 commit 33a1c1f
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions megamek/src/megamek/common/actions/WeaponAttackAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -4424,26 +4424,12 @@ private static ToHitData compileTerrainAndLosToHitMods(Game game, Entity ae, Tar
&& (game.getBoard().getHex(te.getPosition()).containsTerrain(Terrains.WOODS)
|| game.getBoard().getHex(te.getPosition()).containsTerrain(Terrains.JUNGLE));
if (los.canSee() && (targetWoodsAffectModifier || los.thruWoods())) {
boolean bapInRange = Compute.bapInRange(game, ae, te);
boolean c3BAP = false;
if (!bapInRange) {
for (Entity en : game.getC3NetworkMembers(ae)) {
if (ae.equals(en)) {
continue;
}
bapInRange = Compute.bapInRange(game, en, te);
if (bapInRange) {
c3BAP = true;
break;
}
}
}
if (bapInRange) {
if (c3BAP) {
toHit.addModifier(-1, Messages.getString("WeaponAttackAction.BAPInWoodsC3"));
} else {
toHit.addModifier(-1, Messages.getString("WeaponAttackAction.BAPInWoods"));
}
if (Compute.bapInRange(game, ae, te)) {
toHit.addModifier(-1, Messages.getString("WeaponAttackAction.BAPInWoods"));
} else if (game.getC3NetworkMembers(ae).stream()
.anyMatch(en -> !ae.equals(en) && Compute.bapInRange(game, en, target))
) {
toHit.addModifier(-1, Messages.getString("WeaponAttackAction.BAPInWoodsC3"));
}
}
}
Expand Down

0 comments on commit 33a1c1f

Please sign in to comment.