Skip to content

Commit

Permalink
refactor: Use stream composition for firing Arrow IV bays
Browse files Browse the repository at this point in the history
  • Loading branch information
Saklad5 committed Aug 21, 2024
1 parent ca0bbd2 commit 3ce1501
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions megamek/src/megamek/common/actions/WeaponAttackAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -1733,13 +1733,14 @@ private static String toHitIsImpossible(Game game, Entity ae, int attackerId, Ta
// and finally, can only use Arrow IV artillery
if (ae.usesWeaponBays()) {
//For Dropships
for (WeaponMounted bayW : weapon.getBayWeapons()) {
if (weapon.streamBayWeapons()
// check the loaded ammo for the Arrow IV flag
AmmoMounted bayWAmmo = bayW.getLinkedAmmo();
AmmoType bAType = bayWAmmo.getType();
if (bAType.getAmmoType() != AmmoType.T_ARROW_IV) {
return Messages.getString("WeaponAttackAction.OnlyArrowArty");
}
.map(WeaponMounted::getLinkedAmmo)
.map(AmmoMounted::getType)
.map(AmmoType::getAmmoType)
.anyMatch(bAType -> bAType != AmmoType.T_ARROW_IV)
) {
return Messages.getString("WeaponAttackAction.OnlyArrowArty");
}
} else if ((wtype.getAmmoType() != AmmoType.T_ARROW_IV) &&
(wtype.getAmmoType() != AmmoType.T_ARROW_IV_BOMB)) {
Expand Down

0 comments on commit 3ce1501

Please sign in to comment.