Skip to content

Commit 6bdda62

Browse files
committed
refactor: Use stream composition for NC3 firing solutions
1 parent 2db8795 commit 6bdda62

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,13 +1276,9 @@ private static String toHitIsImpossible(Game game, Entity ae, int attackerId, Ta
12761276
&& ae.isSpaceborne()) {
12771277
boolean networkFiringSolution = false;
12781278
//Check to see if the attacker has a firing solution. Naval C3 networks share targeting data
1279-
if (ae.hasNavalC3()) {
1280-
for (Entity en : game.getC3NetworkMembers(ae)) {
1281-
if (te != null && en.hasFiringSolutionFor(te.getId())) {
1282-
networkFiringSolution = true;
1283-
break;
1284-
}
1285-
}
1279+
if (ae.hasNavalC3() && te != null
1280+
&& game.getC3NetworkMembers(ae).stream().anyMatch(en -> en.hasFiringSolutionFor(te.getId())) {
1281+
networkFiringSolution = true;
12861282
}
12871283
if (!networkFiringSolution) {
12881284
//If we don't check for target type here, we can't fire screens and missiles at hexes...

0 commit comments

Comments
 (0)