Skip to content

Commit ddb0a7e

Browse files
committed
refactor: Use stream composition for NC3 firing solutions
1 parent 6b8da9e commit ddb0a7e

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

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

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

0 commit comments

Comments
 (0)