Skip to content

Commit 6b8da9e

Browse files
committed
refactor: Use stream composition for finding TAG spotters
1 parent 175a3f1 commit 6b8da9e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -555,11 +555,11 @@ private static ToHitData toHitCalc(Game game, int attackerId, Targetable target,
555555
|| (atype.getAmmoType() == AmmoType.T_NLRM)
556556
|| (atype.getAmmoType() == AmmoType.T_MEK_MORTAR))
557557
&& (munition.contains(AmmoType.Munitions.M_SEMIGUIDED))) {
558-
for (TagInfo ti : game.getTagInfo()) {
559-
if (target.getId() == ti.target.getId()) {
560-
spotter = game.getEntity(ti.attackerId);
561-
}
562-
}
558+
spotter = game.getTagInfo().stream()
559+
.filter(ti -> target.getId() == ti.target.getId())
560+
.findAny()
561+
.map(ti -> game.getEntity(ti.attackerId))
562+
.orElse(null);
563563
}
564564
}
565565

0 commit comments

Comments
 (0)