Skip to content

Commit 33a1c1f

Browse files
committed
refactor: Use stream composition for C3 with active probes
1 parent 12ed947 commit 33a1c1f

File tree

1 file changed

+6
-20
lines changed

1 file changed

+6
-20
lines changed

megamek/src/megamek/common/actions/WeaponAttackAction.java

+6-20
Original file line numberDiff line numberDiff line change
@@ -4424,26 +4424,12 @@ private static ToHitData compileTerrainAndLosToHitMods(Game game, Entity ae, Tar
44244424
&& (game.getBoard().getHex(te.getPosition()).containsTerrain(Terrains.WOODS)
44254425
|| game.getBoard().getHex(te.getPosition()).containsTerrain(Terrains.JUNGLE));
44264426
if (los.canSee() && (targetWoodsAffectModifier || los.thruWoods())) {
4427-
boolean bapInRange = Compute.bapInRange(game, ae, te);
4428-
boolean c3BAP = false;
4429-
if (!bapInRange) {
4430-
for (Entity en : game.getC3NetworkMembers(ae)) {
4431-
if (ae.equals(en)) {
4432-
continue;
4433-
}
4434-
bapInRange = Compute.bapInRange(game, en, te);
4435-
if (bapInRange) {
4436-
c3BAP = true;
4437-
break;
4438-
}
4439-
}
4440-
}
4441-
if (bapInRange) {
4442-
if (c3BAP) {
4443-
toHit.addModifier(-1, Messages.getString("WeaponAttackAction.BAPInWoodsC3"));
4444-
} else {
4445-
toHit.addModifier(-1, Messages.getString("WeaponAttackAction.BAPInWoods"));
4446-
}
4427+
if (Compute.bapInRange(game, ae, te)) {
4428+
toHit.addModifier(-1, Messages.getString("WeaponAttackAction.BAPInWoods"));
4429+
} else if (game.getC3NetworkMembers(ae).stream()
4430+
.anyMatch(en -> !ae.equals(en) && Compute.bapInRange(game, en, target))
4431+
) {
4432+
toHit.addModifier(-1, Messages.getString("WeaponAttackAction.BAPInWoodsC3"));
44474433
}
44484434
}
44494435
}

0 commit comments

Comments
 (0)