From 6bdda62fe820908a3dd25d653e4685465b0cd566 Mon Sep 17 00:00:00 2001 From: Jeremy Saklad Date: Sun, 18 Aug 2024 13:40:03 -0500 Subject: [PATCH] refactor: Use stream composition for NC3 firing solutions --- .../src/megamek/common/actions/WeaponAttackAction.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/megamek/src/megamek/common/actions/WeaponAttackAction.java b/megamek/src/megamek/common/actions/WeaponAttackAction.java index 1414fc441e..4ce475ca54 100644 --- a/megamek/src/megamek/common/actions/WeaponAttackAction.java +++ b/megamek/src/megamek/common/actions/WeaponAttackAction.java @@ -1276,13 +1276,9 @@ private static String toHitIsImpossible(Game game, Entity ae, int attackerId, Ta && ae.isSpaceborne()) { boolean networkFiringSolution = false; //Check to see if the attacker has a firing solution. Naval C3 networks share targeting data - if (ae.hasNavalC3()) { - for (Entity en : game.getC3NetworkMembers(ae)) { - if (te != null && en.hasFiringSolutionFor(te.getId())) { - networkFiringSolution = true; - break; - } - } + if (ae.hasNavalC3() && te != null + && game.getC3NetworkMembers(ae).stream().anyMatch(en -> en.hasFiringSolutionFor(te.getId())) { + networkFiringSolution = true; } if (!networkFiringSolution) { //If we don't check for target type here, we can't fire screens and missiles at hexes...