Search in sources :

Example 1 with ScreenLauncherWeapon

use of megamek.common.weapons.capitalweapons.ScreenLauncherWeapon in project megameklab by MegaMek.

the class StringUtils method getEquipmentInfo.

public static String getEquipmentInfo(Dropship unit, Mounted mount, Mounted bay) {
    String info = "";
    if (mount.getType() instanceof WeaponType) {
        WeaponType weapon = (WeaponType) mount.getType();
        if (weapon.getAmmoType() == AmmoType.T_AR10) {
            int barracudaAmmo = 0;
            int killerwhaleAmmo = 0;
            int whitesharkAmmo = 0;
            for (int ammoIndex : bay.getBayAmmo()) {
                Mounted ammoMount = unit.getEquipment(ammoIndex);
                try {
                    AmmoType aType = (AmmoType) ammoMount.getType();
                    if ((mount.getLinked() != null) && (aType.getRackSize() == weapon.getRackSize()) && (aType.getAmmoType() == weapon.getAmmoType())) {
                        if (aType.hasFlag(AmmoType.F_AR10_BARRACUDA)) {
                            barracudaAmmo += ammoMount.getUsableShotsLeft();
                        } else if (aType.hasFlag(AmmoType.F_AR10_KILLER_WHALE)) {
                            killerwhaleAmmo += ammoMount.getUsableShotsLeft();
                        } else if (aType.hasFlag(AmmoType.F_AR10_WHITE_SHARK)) {
                            whitesharkAmmo += ammoMount.getUsableShotsLeft();
                        }
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
            info = "";
            if (barracudaAmmo > 0) {
                info += String.format("[%1$s Barracuda misl]", barracudaAmmo);
            }
            if (killerwhaleAmmo > 0) {
                info += String.format("[%1$s Killer Whale misl]", killerwhaleAmmo);
            }
            if (whitesharkAmmo > 0) {
                info += String.format("[%1$s White Shark misl]", whitesharkAmmo);
            }
        } else if (weapon.getAmmoType() == AmmoType.T_MML) {
            int lrmAmmo = 0;
            int srmAmmo = 0;
            for (int ammoIndex : bay.getBayAmmo()) {
                Mounted ammoMount = unit.getEquipment(ammoIndex);
                try {
                    AmmoType aType = (AmmoType) ammoMount.getType();
                    if ((mount.getLinked() != null) && (aType.getRackSize() == weapon.getRackSize()) && (aType.getAmmoType() == weapon.getAmmoType())) {
                        if (aType.hasFlag(AmmoType.F_MML_LRM)) {
                            lrmAmmo += ammoMount.getUsableShotsLeft();
                        } else {
                            srmAmmo += ammoMount.getUsableShotsLeft();
                        }
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
            info = String.format("[%1$s LRM rnds][%2$s SRM rnds]", lrmAmmo, srmAmmo);
        } else {
            int totalAmmo = 0;
            for (int ammoIndex : bay.getBayAmmo()) {
                Mounted ammoMount = unit.getEquipment(ammoIndex);
                try {
                    if ((mount.getLinked() != null) && (ammoMount.getType() == mount.getLinked().getType())) {
                        totalAmmo += ammoMount.getUsableShotsLeft();
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
            if (weapon instanceof ScreenLauncherWeapon) {
                info = String.format("[%1$s Screens]", totalAmmo);
            } else if (weapon.hasFlag(WeaponType.F_BALLISTIC) || weapon.hasFlag(WeaponType.F_MISSILE) || weapon.hasFlag(WeaponType.F_ARTILLERY) || (weapon.getAtClass() == WeaponType.CLASS_CAPITAL_MISSILE)) {
                info = String.format("[%1$s rnds]", totalAmmo);
            }
        }
    }
    return info;
}
Also used : AmmoType(megamek.common.AmmoType) Mounted(megamek.common.Mounted) WeaponType(megamek.common.WeaponType) ScreenLauncherWeapon(megamek.common.weapons.capitalweapons.ScreenLauncherWeapon)

Aggregations

AmmoType (megamek.common.AmmoType)1 Mounted (megamek.common.Mounted)1 WeaponType (megamek.common.WeaponType)1 ScreenLauncherWeapon (megamek.common.weapons.capitalweapons.ScreenLauncherWeapon)1