final boolean usesAmmo = wtype.getAmmoType() != AmmoType.T_NA;
final boolean isWeaponInfantry = (wtype.getFlags() & WeaponType.F_INFANTRY) == WeaponType.F_INFANTRY; final boolean usesAmmo = wtype.getAmmoType() != AmmoType.T_NA && !isWeaponInfantry;
    private void resolveWeaponAttack(WeaponAttackAction waa, int lastEntityId) {        final Entity ae = game.getEntity(waa.getEntityId());        final Entity te = game.getEntity(waa.getTargetId());        final Mounted weapon = ae.getEquipment(waa.getWeaponId());        final WeaponType wtype = (WeaponType)weapon.getType();        final boolean usesAmmo = wtype.getAmmoType() != AmmoType.T_NA;        Mounted ammo = null;        if (usesAmmo) {            if (waa.getAmmoId() > -1) {                ammo = ae.getEquipment(waa.getAmmoId());                weapon.setLinked(ammo);            }            else {                ammo = weapon.getLinked();            }        }        final AmmoType atype = ammo == null ? null : (AmmoType)ammo.getType();                        if (lastEntityId != waa.getEntityId()) {            phaseReport.append("\nWeapons fire for " + ae.getDisplayName() + "\n");        }                phaseReport.append("    " + wtype.getName() + " at " + te.getDisplayName());                // has this weapon fired already?        if (weapon.isUsedThisRound()) {            phaseReport.append(" but the weapon has already fired this round!\n");            return;        }                // is the weapon functional?        if (weapon.isDestroyed()) {            phaseReport.append(" but the weapon has been destroyed in a previous round!\n");            return;        }                // try reloading        if (usesAmmo && ammo != null && ammo.getShotsLeft() == 0) {            ae.loadWeapon(weapon);            ammo = weapon.getLinked();        }                // should we even bother?        if (te.isDestroyed() || te.isDoomed() || te.crew.isDead()) {            phaseReport.append(" but the target is already destroyed!\n");            return;        }                // compute to-hit        ToHitData toHit = Compute.toHitWeapon(game, waa, attacks);        if (toHit.getValue() == ToHitData.IMPOSSIBLE) {            phaseReport.append(", but the shot is impossible (" + toHit.getDesc() + ")\n");            return;        } else if (toHit.getValue() == ToHitData.AUTOMATIC_FAIL) {            phaseReport.append(", the shot is an automatic miss (" + toHit.getDesc() + "), ");        } else {            phaseReport.append("; needs " + toHit.getValue() + ", ");        }                        // use up ammo (if weapon is out of ammo, we shouldn't be here)        if (usesAmmo) {            ammo.setShotsLeft(ammo.getShotsLeft() - 1);                /*                Fire Mode - Takes 2 shots of ammo away if we are firing uAC Double Rate.                If you don't have enough ammo for a Double Rate shot, you can't do it!                Rasia                 */            if (wtype.getAmmoType() == AmmoType.T_AC_ULTRA && ammo != null && weapon.getFiringMode() == 2) {                if (ammo.getShotsLeft() <= 0) {                    ae.loadWeapon(weapon);                    ammo = weapon.getLinked();                    if (ammo.getShotsLeft() <= 0) {                        weapon.setFiringMode(1);                        phaseReport.append("(Out of Ammo, Single Rate Only):");                    } else {                        ammo.setShotsLeft(ammo.getShotsLeft() - 1);                    }                                    } else {                    ammo.setShotsLeft(ammo.getShotsLeft() - 1);                }            }        }                // build up some heat        ae.heatBuildup += wtype.getHeat();        if (wtype.getAmmoType() == AmmoType.T_AC_ULTRA && weapon.getFiringMode() == 2) // Fire Mode - If we are shooting an Ultra AC twice            ae.heatBuildup += wtype.getHeat();                // set the weapon as having fired        weapon.setUsedThisRound(true);                        // roll        int roll = Compute.d6(2);        phaseReport.append("rolls " + roll + " : ");                if (roll == 2 && ammo != null && wtype.getAmmoType() == AmmoType.T_AC_ULTRA && weapon.getFiringMode() == 2) {            phaseReport.append("misses AND THE AUTOCANNON JAMS.\n");            weapon.setHit(true);            return;        }                // do we hit?        if (roll < toHit.getValue()) {            // miss            phaseReport.append("misses.\n");            if (wtype.getAmmoType() == AmmoType.T_SRM_STREAK) {                ae.heatBuildup -= wtype.getHeat();                ammo.setShotsLeft(ammo.getShotsLeft() + 1);                phaseReport.append("    Streak fails to achieve lock on target.\n");            }            return;        }                // Fire Mode - If we roll 2 and shooting uAC twice, it Jams        if (roll < 3 && ammo != null && wtype.getAmmoType() == AmmoType.T_AC_ULTRA && weapon.getFiringMode() == 2) {            phaseReport.append("misses AND THE AUTOCANNON JAMS.\n");            weapon.setHit(true);            return;        }                if (wtype.getDamage() == WeaponType.DAMAGE_MISSILE || (ammo != null && wtype.getAmmoType() == AmmoType.T_AC_ULTRA && weapon.getFiringMode() == 2) || (ammo != null && atype.hasFlag(AmmoType.F_CLUSTER))) {            if (ammo != null) {                // missiles; determine number of missiles hitting                int hits;                if (wtype.getAmmoType() == AmmoType.T_SRM_STREAK) {                    hits = wtype.getRackSize();                } else if (wtype.getRackSize() == 30 || wtype.getRackSize() == 40) {                    // I'm going to assume these are MRMs                    hits = Compute.missilesHit(wtype.getRackSize() / 2) + Compute.missilesHit(wtype.getRackSize() / 2);                } else if (wtype.getAmmoType() == AmmoType.T_AC_ULTRA) {                    hits = Compute.missilesHit(2);                } else {                    hits = Compute.missilesHit(wtype.getRackSize());                }                phaseReport.append(hits + " missiles hit" + toHit.getTableDesc() + ".");                if (wtype.getAmmoType() == AmmoType.T_SRM || wtype.getAmmoType() == AmmoType.T_SRM_STREAK) {                    // for SRMs, do each missile seperately                    for (int j = 0; j < hits; j++) {                        HitData hit = te.rollHitLocation(toHit.getHitTable(), toHit.getSideTable());                        phaseReport.append(damageEntity(te, hit, 2));                    }                } else if (atype.hasFlag(AmmoType.F_CLUSTER)) {                    // for LBX cluster ammo                    for (int j = 0; j < hits; j++) {                        HitData hit = te.rollHitLocation(toHit.getHitTable(), toHit.getSideTable());                        phaseReport.append(damageEntity(te, hit, 1));                    }                } else if (wtype.getAmmoType() == AmmoType.T_AC_ULTRA) {                    // Fire Mode - uAC ammo                    for (int j = 0; j < hits; j++) {                        HitData hit = te.rollHitLocation(toHit.getHitTable(), toHit.getSideTable());                        phaseReport.append(damageEntity(te, hit, wtype.getDamage()));                                            }                } else if (wtype.getAmmoType() == AmmoType.T_LRM || wtype.getAmmoType() == AmmoType.T_MRM) {                    // LRMs, MRMs do salvos of 5                    while (hits > 0) {                        int salvo = Math.min(5, hits);                        HitData hit = te.rollHitLocation(toHit.getHitTable(), toHit.getSideTable());                        phaseReport.append(damageEntity(te, hit, salvo));                        hits -= salvo;                    }                }            }        } else if (wtype.hasFlag(WeaponType.F_FLAMER) && game.getOptions().booleanOption("flamer_heat")) {            phaseReport.append("hits; target gains 2 more heat during heat phase.");            te.heatBuildup += 2;        } else {            // normal weapon; deal damage            HitData hit = te.rollHitLocation(toHit.getHitTable(), toHit.getSideTable());            phaseReport.append("hits" + toHit.getTableDesc() + " " + te.getLocationAbbr(hit));            phaseReport.append(damageEntity(te, hit, wtype.getDamage()));        }                phaseReport.append("\n");    }