use of megamek.common.WeaponType in project megameklab by MegaMek.
the class DropTargetCriticalList method mousePressed.
public void mousePressed(MouseEvent e) {
if (buildView) {
if (e.getButton() == MouseEvent.BUTTON2) {
setSelectedIndex(locationToIndex(e.getPoint()));
removeCrit();
} else if (e.getButton() == MouseEvent.BUTTON3) {
setSelectedIndex(locationToIndex(e.getPoint()));
if ((e.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) != 0) {
removeCrit();
return;
}
int location = getCritLocation();
JPopupMenu popup = new JPopupMenu();
CriticalSlot cs = getCrit();
Mounted mount = getMounted();
if ((e.getModifiersEx() & InputEvent.ALT_DOWN_MASK) != 0) {
changeWeaponFacing(!mount.isRearMounted());
return;
}
if ((e.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) != 0) {
changeOmniMounting(!mount.isOmniPodMounted());
return;
}
if (mount != null) {
popup.setAutoscrolls(true);
JMenuItem info;
if (!UnitUtil.isFixedLocationSpreadEquipment(mount.getType())) {
info = new JMenuItem("Remove " + mount.getName());
info.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
removeCrit();
}
});
popup.add(info);
}
info = new JMenuItem("Delete " + mount.getName());
info.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
removeMount();
}
});
popup.add(info);
if ((mount.getType() instanceof WeaponType) && getUnit().hasWorkingMisc(MiscType.F_SPONSON_TURRET) && ((mount.getLocation() == Tank.LOC_LEFT) || (mount.getLocation() == Tank.LOC_RIGHT))) {
if (!mount.isSponsonTurretMounted()) {
info = new JMenuItem("Mount " + mount.getName() + " in Sponson Turret");
info.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
changeSponsonTurretMount(true);
}
});
popup.add(info);
} else {
info = new JMenuItem("Remove " + mount.getName() + " from Sponson Turret");
info.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
changeSponsonTurretMount(false);
}
});
popup.add(info);
}
}
if ((mount.getType() instanceof WeaponType) && getUnit().hasWorkingMisc(MiscType.F_PINTLE_TURRET, mount.getLocation())) {
if (!mount.isPintleTurretMounted()) {
info = new JMenuItem("Mount " + mount.getName() + " in Pintle Turret");
info.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
changePintleTurretMount(true);
}
});
popup.add(info);
} else {
info = new JMenuItem("Remove " + mount.getName() + " from Pintle Turret");
info.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
changePintleTurretMount(false);
}
});
popup.add(info);
}
}
if (getUnit().isOmni() && !mount.getType().isOmniFixedOnly()) {
if (mount.isOmniPodMounted()) {
info = new JMenuItem("Change to fixed mount");
info.addActionListener(ev -> changeOmniMounting(false));
popup.add(info);
} else if (UnitUtil.canPodMount(getUnit(), mount)) {
info = new JMenuItem("Change to pod mount");
info.addActionListener(ev -> changeOmniMounting(true));
popup.add(info);
}
}
}
if (UnitUtil.isArmorable(cs) && ((UnitUtil.getUnitTechType(getUnit()) == UnitUtil.TECH_EXPERIMENTAL) || (UnitUtil.getUnitTechType(getUnit()) == UnitUtil.TECH_UNOFFICAL))) {
popup.addSeparator();
if (cs.isArmored()) {
JMenuItem info = new JMenuItem("Remove Armoring");
info.setActionCommand(Integer.toString(location));
info.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
changeArmoring();
}
});
popup.add(info);
} else {
JMenuItem info = new JMenuItem("Add Armoring");
info.setActionCommand(Integer.toString(location));
info.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
changeArmoring();
}
});
popup.add(info);
}
}
if (popup.getComponentCount() > 0) {
popup.show(this, e.getX(), e.getY());
}
}
}
}
use of megamek.common.WeaponType in project megameklab by MegaMek.
the class CriticalView method refresh.
public void refresh() {
critSuit = new CriticalSuit(getBattleArmor());
leftPanel.removeAll();
rightPanel.removeAll();
bodyPanel.removeAll();
turretPanel.removeAll();
int[] numAPWeapons = new int[BattleArmor.MOUNT_NUM_LOCS];
int[] numAMWeapons = new int[BattleArmor.MOUNT_NUM_LOCS];
for (Mounted m : getBattleArmor().getEquipment()) {
if (m.getLocation() == BattleArmor.LOC_SQUAD || m.getLocation() == trooper) {
critSuit.addMounted(m.getBaMountLoc(), m);
// Weapons mounted in a quad turret count against the body limits
int useLoc = m.getBaMountLoc();
if (useLoc == BattleArmor.MOUNT_LOC_TURRET) {
useLoc = BattleArmor.MOUNT_LOC_BODY;
}
if (useLoc != BattleArmor.MOUNT_LOC_NONE) {
if ((m.getType() instanceof WeaponType) && !(m.getType() instanceof InfantryWeapon)) {
numAMWeapons[useLoc]++;
}
if (m.getType().hasFlag(MiscType.F_AP_MOUNT)) {
numAPWeapons[useLoc]++;
}
}
}
}
synchronized (getBattleArmor()) {
for (int location = 0; location < critSuit.locations(); location++) {
Vector<String> critNames = new Vector<String>(1, 1);
for (int slot = 0; slot < critSuit.getNumCriticals(location); slot++) {
CriticalSlot cs = critSuit.getCritical(location, slot);
if (cs == null) {
if (showEmpty) {
critNames.add(MtfFile.EMPTY);
}
continue;
} else if (cs.getType() == CriticalSlot.TYPE_SYSTEM) {
// BattleArmor shouldn't have system type crits
continue;
} else if (cs.getType() == CriticalSlot.TYPE_EQUIPMENT) {
try {
Mounted m = cs.getMount();
// Critical didn't get removed. Remove it now.
if (m == null) {
if (showEmpty) {
critNames.add(MtfFile.EMPTY);
}
continue;
}
StringBuffer critName = new StringBuffer(m.getName());
critName.append(":" + slot + ":" + getBattleArmor().getEquipmentNum(m));
critNames.add(critName.toString());
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
DropTargetCriticalList<String> criticalSlotList = null;
criticalSlotList = new DropTargetCriticalList<String>(critNames, eSource, refresh, showEmpty);
criticalSlotList.setAlignmentX(JLabel.CENTER_ALIGNMENT);
criticalSlotList.setVisibleRowCount(critNames.size());
criticalSlotList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
criticalSlotList.setFont(new Font("Arial", Font.PLAIN, 10));
criticalSlotList.setName(location + ":" + trooper);
criticalSlotList.setBorder(BorderFactory.createEtchedBorder(Color.WHITE.brighter(), Color.BLACK.darker()));
switch(location) {
case BattleArmor.MOUNT_LOC_LARM:
leftPanel.add(criticalSlotList);
break;
case BattleArmor.MOUNT_LOC_RARM:
rightPanel.add(criticalSlotList);
break;
case BattleArmor.MOUNT_LOC_BODY:
bodyPanel.add(criticalSlotList);
break;
case BattleArmor.MOUNT_LOC_TURRET:
turretPanel.add(criticalSlotList);
break;
}
}
String[] amTxt = new String[BattleArmor.MOUNT_NUM_LOCS];
String[] apTxt = new String[BattleArmor.MOUNT_NUM_LOCS];
for (int loc = 0; loc < BattleArmor.MOUNT_NUM_LOCS; loc++) {
amTxt[loc] = "AM Wpn: " + numAMWeapons[loc] + "/" + getBattleArmor().getNumAllowedAntiMechWeapons(loc);
apTxt[loc] = "AP Wpn: " + numAPWeapons[loc] + "/" + getBattleArmor().getNumAllowedAntiPersonnelWeapons(loc, trooper);
if (numAMWeapons[loc] > getBattleArmor().getNumAllowedAntiMechWeapons(loc)) {
amTxt[loc] = "<html><font color='C00000'>" + amTxt[loc] + "</font></html>";
}
if (numAPWeapons[loc] > getBattleArmor().getNumAllowedAntiMechWeapons(loc)) {
apTxt[loc] = "<html><font color='C00000'>" + apTxt[loc] + "</font></html>";
}
}
leftPanel.add(makeLabel(amTxt[BattleArmor.MOUNT_LOC_LARM], lblSz));
leftPanel.add(makeLabel(apTxt[BattleArmor.MOUNT_LOC_LARM], lblSz));
rightPanel.add(makeLabel(amTxt[BattleArmor.MOUNT_LOC_RARM], lblSz));
rightPanel.add(makeLabel(apTxt[BattleArmor.MOUNT_LOC_RARM], lblSz));
bodyPanel.add(makeLabel(amTxt[BattleArmor.MOUNT_LOC_BODY], lblSz));
bodyPanel.add(makeLabel(apTxt[BattleArmor.MOUNT_LOC_BODY], lblSz));
// Hide the arm panels if we are a quad
if (getBattleArmor().getChassisType() == BattleArmor.CHASSIS_TYPE_QUAD) {
leftPanel.setVisible(false);
rightPanel.setVisible(false);
turretPanel.setVisible(getBattleArmor().getTurretCapacity() > 0);
} else {
leftPanel.setVisible(true);
rightPanel.setVisible(true);
turretPanel.setVisible(false);
}
EntityVerifier entityVerifier = EntityVerifier.getInstance(new File("data/mechfiles/UnitVerifierOptions.xml"));
TestBattleArmor testBA = new TestBattleArmor(getBattleArmor(), entityVerifier.baOption, null);
String weightTxt = "Weight: " + String.format("%1$.3f", testBA.calculateWeight(trooper)) + "/" + getBattleArmor().getTrooperWeight();
if (testBA.calculateWeight(trooper) > getBattleArmor().getTrooperWeight()) {
weightTxt = "<html><font color='C00000'>" + weightTxt + "</font></html>";
}
weightLabel.setText(weightTxt);
leftPanel.add(Box.createVerticalStrut(8));
rightPanel.add(Box.createVerticalStrut(8));
bodyPanel.add(Box.createVerticalStrut(8));
turretPanel.add(Box.createVerticalStrut(8));
leftPanel.invalidate();
leftPanel.invalidate();
rightPanel.invalidate();
turretPanel.invalidate();
bodyPanel.repaint();
leftPanel.repaint();
rightPanel.repaint();
turretPanel.repaint();
}
}
use of megamek.common.WeaponType in project megameklab by MegaMek.
the class StatusBar method calculateTotalHeat.
public double calculateTotalHeat() {
double heat = 0;
for (Mounted mounted : getSmallCraft().getWeaponList()) {
WeaponType wtype = (WeaponType) mounted.getType();
double weaponHeat = wtype.getHeat();
// only count non-damaged equipment
if (mounted.isMissing() || mounted.isHit() || mounted.isDestroyed() || mounted.isBreached()) {
continue;
}
// one shot weapons count 1/4
if ((wtype.getAmmoType() == AmmoType.T_ROCKET_LAUNCHER) || wtype.hasFlag(WeaponType.F_ONESHOT)) {
weaponHeat *= 0.25;
}
// double heat for ultras
if ((wtype.getAmmoType() == AmmoType.T_AC_ULTRA) || (wtype.getAmmoType() == AmmoType.T_AC_ULTRA_THB)) {
weaponHeat *= 2;
}
// Six times heat for RAC
if (wtype.getAmmoType() == AmmoType.T_AC_ROTARY) {
weaponHeat *= 6;
}
// half heat for streaks
if ((wtype.getAmmoType() == AmmoType.T_SRM_STREAK) || (wtype.getAmmoType() == AmmoType.T_MRM_STREAK) || (wtype.getAmmoType() == AmmoType.T_LRM_STREAK)) {
weaponHeat *= 0.5;
}
heat += weaponHeat;
}
return heat;
}
use of megamek.common.WeaponType in project megameklab by MegaMek.
the class AerospaceBuildView method mousePressed.
public void mousePressed(MouseEvent e) {
// locations, but only if those locations are make sense
if (e.getButton() == MouseEvent.BUTTON3) {
JPopupMenu popup = new JPopupMenu();
JMenuItem item = null;
if (equipmentTable.getSelectedRowCount() > 1) {
List<Mounted> list = new ArrayList<>();
for (int row : equipmentTable.getSelectedRows()) {
list.add((Mounted) equipmentTable.getModel().getValueAt(row, CriticalTableModel.EQUIPMENT));
}
for (BayWeaponCriticalTree l : arcViews) {
// Aerodyne small craft and dropships skip the aft side arcs
if (getAero().hasETypeFlag(Entity.ETYPE_SMALL_CRAFT) && !getAero().isSpheroid() && !l.validForAerodyne()) {
continue;
}
if (list.stream().anyMatch(eq -> l.canAdd(eq))) {
item = new JMenuItem(l.getLocationName());
item.addActionListener(ev -> l.addToLocation(list));
popup.add(item);
}
}
} else {
final int selectedRow = equipmentTable.rowAtPoint(e.getPoint());
Mounted eq = (Mounted) equipmentTable.getModel().getValueAt(selectedRow, CriticalTableModel.EQUIPMENT);
for (BayWeaponCriticalTree l : arcViews) {
// Aerodyne small craft and dropships skip the aft side arcs
if (getAero().hasETypeFlag(Entity.ETYPE_SMALL_CRAFT) && !getAero().isSpheroid() && !l.validForAerodyne()) {
continue;
}
if (getAero().usesWeaponBays()) {
JMenu menu = new JMenu(l.getLocationName());
for (Mounted bay : l.baysFor(eq)) {
if (eq.getType() instanceof AmmoType) {
final int shotCount = ((AmmoType) eq.getType()).getShots();
JMenu locMenu = new JMenu(bay.getName());
for (int shots = shotCount; shots <= eq.getUsableShotsLeft(); shots += shotCount) {
item = new JMenuItem("Add " + shots + ((shots > 1) ? " shots" : " shot"));
final int addShots = shots;
item.addActionListener(ev -> l.addAmmoToBay(bay, eq, addShots));
locMenu.add(item);
}
menu.add(locMenu);
} else {
item = new JMenuItem(bay.getName());
item.addActionListener(ev -> l.addToBay(bay, eq));
menu.add(item);
}
}
if (eq.getType() instanceof WeaponType) {
final EquipmentType bayType = ((WeaponType) eq.getType()).getBayType();
item = new JMenuItem("New " + bayType.getName());
item.addActionListener(ev -> l.addToNewBay(bayType, eq));
menu.add(item);
}
if (menu.getItemCount() > 0) {
popup.add(menu);
} else if ((eq.getType() instanceof MiscType) && l.canAdd(eq)) {
item = new JMenuItem(l.getLocationName());
item.addActionListener(ev -> l.addToLocation(eq));
popup.add(item);
}
} else {
item = new JMenuItem(l.getLocationName());
item.addActionListener(ev -> l.addToLocation(eq));
popup.add(item);
}
}
}
popup.show(this, e.getX(), e.getY());
}
}
use of megamek.common.WeaponType in project megameklab by MegaMek.
the class PrintInfantry method printImage.
public void printImage(Graphics2D g2d, PageFormat pageFormat) {
if ((null == g2d) || (null == infantry)) {
return;
}
SVGDiagram diagram;
int stop = Math.min(4, infantryList.size() - currentPosition);
if (stop > 3) {
diagram = ImageHelper.loadSVGImage(new File("data/images/recordsheets/Conventional_Infantry_no_tables.svg"));
} else {
diagram = ImageHelper.loadSVGImage(new File("data/images/recordsheets/Conventional_Infantry_tables.svg"));
}
try {
Tspan tspan = (Tspan) diagram.getElement("text_copyright");
tspan.setText(String.format(tspan.getText(), Calendar.getInstance().get(Calendar.YEAR)));
((Text) tspan.getParent()).rebuild();
diagram.render(g2d);
for (int pos = 0; pos < stop; pos++) {
diagram = ImageHelper.loadSVGImage(new File("data/images/recordsheets/Conventional_Infantry_platoon_" + (pos + 1) + ".svg"));
infantry = infantryList.get(pos + currentPosition);
tspan = (Tspan) diagram.getElement(ID_PLATOON_NAME);
String name = infantry.getChassis();
if (infantry.getModel().length() > 0) {
name += " " + infantry.getModel();
}
if (name.length() > 48) {
tspan.setText(infantry.getChassis());
} else {
tspan.setText(name);
}
((Text) tspan.getParent()).rebuild();
tspan = (Tspan) diagram.getElement(ID_ARMOR_KIT);
EquipmentType armor = infantry.getArmorKit();
if (armor != null) {
tspan.setText(armor.getName());
((Text) tspan.getParent()).rebuild();
} else if (infantry.hasDEST()) {
tspan.setText("DEST");
((Text) tspan.getParent()).rebuild();
} else {
StringJoiner sj = new StringJoiner("/");
if (infantry.hasSneakCamo()) {
sj.add("Camo");
}
if (infantry.hasSneakIR()) {
sj.add("IR");
}
if (infantry.hasSneakECM()) {
sj.add("ECM");
}
if (sj.length() > 0) {
tspan.setText("Sneak(" + sj.toString() + ")");
((Text) tspan.getParent()).rebuild();
}
}
tspan = (Tspan) diagram.getElement(ID_ARMOR_DIVISOR);
tspan.setText(String.valueOf(infantry.getDamageDivisor() + (infantry.isArmorEncumbering() ? "E" : "")));
((Text) tspan.getParent()).rebuild();
for (int j = 1; j <= 30; j++) {
if (j > infantry.getShootingStrength()) {
diagram.getElement(ID_SOLDIER + j).addAttribute("display", AnimationElement.AT_XML, "none");
diagram.getElement(ID_NO_SOLDIER + j).removeAttribute("display", AnimationElement.AT_XML);
} else {
tspan = (Tspan) diagram.getElement(ID_DAMAGE + j);
tspan.setText(String.valueOf((int) Math.round(infantry.getDamagePerTrooper() * j)));
((Text) tspan.getParent()).rebuild();
}
}
diagram.updateTime(0);
InfantryWeapon rangeWeapon = infantry.getPrimaryWeapon();
if (infantry.getSecondaryWeapon() != null && infantry.getSecondaryN() > 1 && !infantry.getSecondaryWeapon().hasFlag(WeaponType.F_TAG)) {
rangeWeapon = infantry.getSecondaryWeapon();
}
boolean scuba = infantry.getMovementMode() == EntityMovementMode.INF_UMU || infantry.getMovementMode() == EntityMovementMode.SUBMARINE;
if (scuba) {
diagram.getElement(ID_UW_LABEL).removeAttribute("display", AnimationElement.AT_XML);
}
InfantryWeapon singleSecondary = (infantry.getSecondaryN() == 1) ? infantry.getSecondaryWeapon() : null;
for (int j = 0; j <= 21; j++) {
tspan = (Tspan) diagram.getElement(ID_RANGE_MOD + j);
tspan.setText(rangeMod(j, rangeWeapon, singleSecondary, false));
if (scuba) {
tspan = (Tspan) diagram.getElement(ID_UW_RANGE_MOD + j);
tspan.setText(rangeMod(j, rangeWeapon, singleSecondary, true));
}
((Text) tspan.getParent()).rebuild();
}
int numGuns = 0;
int numShots = 0;
WeaponType gun = null;
for (Mounted m : infantry.getEquipment()) {
if (m.getLocation() == Infantry.LOC_FIELD_GUNS) {
if (m.getType() instanceof WeaponType) {
gun = (WeaponType) m.getType();
numGuns++;
} else if (m.getType() instanceof AmmoType) {
numShots += ((AmmoType) m.getType()).getShots();
}
}
}
if (gun == null) {
diagram.getElement(ID_FIELD_GUN_COLUMNS).addAttribute("display", AnimationElement.AT_XML, "none");
} else {
tspan = (Tspan) diagram.getElement(ID_FIELD_GUN_QTY);
tspan.setText(Integer.toString(numGuns));
((Text) tspan.getParent()).rebuild();
tspan = (Tspan) diagram.getElement(ID_FIELD_GUN_TYPE);
tspan.setText(gun.getName());
((Text) tspan.getParent()).rebuild();
/* We don't use StringUnits.getEquipmentInfo() to format the damage
* string because gauss explosion flags do not apply, and switchable
* only applies for non-LBX.
*/
tspan = (Tspan) diagram.getElement(ID_FIELD_GUN_DMG);
if (gun instanceof ArtilleryWeapon) {
tspan.setText(gun.getRackSize() + " [AE,S,F]");
} else {
StringBuilder sb = new StringBuilder(Integer.toString(gun.getDamage()));
switch(gun.getAmmoType()) {
case AmmoType.T_AC_ULTRA:
case AmmoType.T_AC_ULTRA_THB:
sb.append("/Sht, R2 [DB,R/S/C]");
break;
case AmmoType.T_AC_ROTARY:
sb.append("/Sht, R6 [DB,R/S/C]");
break;
case AmmoType.T_AC:
case AmmoType.T_AC_PRIMITIVE:
case AmmoType.T_LAC:
sb.append(" [DB,C/S/F]");
break;
case AmmoType.T_AC_LBX:
case AmmoType.T_AC_LBX_THB:
sb.append(" [DB,C/F]");
break;
default:
sb.append(" [DB]");
}
tspan.setText(sb.toString());
}
((Text) tspan.getParent()).rebuild();
tspan = (Tspan) diagram.getElement(ID_FIELD_GUN_MIN_RANGE);
if (gun.getMinimumRange() > 0) {
tspan.setText(Integer.toString(gun.getMinimumRange()));
} else {
tspan.setText("—");
}
((Text) tspan.getParent()).rebuild();
tspan = (Tspan) diagram.getElement(ID_FIELD_GUN_SHORT);
tspan.setText(Integer.toString(gun.getShortRange()));
((Text) tspan.getParent()).rebuild();
tspan = (Tspan) diagram.getElement(ID_FIELD_GUN_MED);
tspan.setText(Integer.toString(gun.getMediumRange()));
((Text) tspan.getParent()).rebuild();
tspan = (Tspan) diagram.getElement(ID_FIELD_GUN_LONG);
tspan.setText(Integer.toString(gun.getLongRange()));
((Text) tspan.getParent()).rebuild();
tspan = (Tspan) diagram.getElement(ID_FIELD_GUN_AMMO);
tspan.setText(Integer.toString(numShots));
((Text) tspan.getParent()).rebuild();
tspan = (Tspan) diagram.getElement(ID_FIELD_GUN_CREW);
tspan.setText(Integer.toString((int) Math.ceil(gun.getTonnage(infantry))));
((Text) tspan.getParent()).rebuild();
}
if (infantry.hasDEST()) {
diagram.getElement(ID_DEST_MODS).removeAttribute("display", AnimationElement.AT_XML);
diagram.getElement(ID_SNEAK_IR_MODS).removeAttribute("display", AnimationElement.AT_XML);
} else if (infantry.hasSneakCamo()) {
diagram.getElement(ID_SNEAK_CAMO_MODS).removeAttribute("display", AnimationElement.AT_XML);
}
if (infantry.hasSneakIR()) {
diagram.getElement(ID_SNEAK_IR_MODS).removeAttribute("display", AnimationElement.AT_XML);
}
tspan = (Tspan) diagram.getElement(ID_BV);
tspan.setText(Integer.toString(infantry.calculateBattleValue()));
((Text) tspan.getParent()).rebuild();
tspan = (Tspan) diagram.getElement(ID_TRANSPORT_WT);
tspan.setText(String.format("%.1f tons", infantry.getWeight()));
((Text) tspan.getParent()).rebuild();
Tspan mp1 = (Tspan) diagram.getElement(ID_MP_1);
Tspan mode1 = (Tspan) diagram.getElement(ID_MODE_1);
Tspan mp2 = (Tspan) diagram.getElement(ID_MP_2);
Tspan mode2 = (Tspan) diagram.getElement(ID_MODE_2);
switch(infantry.getMovementMode()) {
case INF_JUMP:
mp1.setText(Integer.toString(infantry.getJumpMP(false)));
mode1.setText("Jump");
mp2.setText(Integer.toString(infantry.getWalkMP(true, true, false)));
mode2.setText("Ground");
((Text) mp2.getParent()).rebuild();
((Text) mode2.getParent()).rebuild();
break;
case INF_UMU:
mp1.setText(Integer.toString(infantry.getActiveUMUCount()));
if (infantry.getOriginalJumpMP() > 1) {
mode1.setText("SCUBA (Motorized)");
} else {
mode1.setText("SCUBA");
}
mp2.setText(Integer.toString(infantry.getWalkMP(true, true, false)));
mode2.setText("Ground");
((Text) mp2.getParent()).rebuild();
((Text) mode2.getParent()).rebuild();
break;
case HOVER:
mp1.setText(Integer.toString(infantry.getWalkMP(true, true, false)));
mode1.setText("Mechanized Hover");
break;
case TRACKED:
mp1.setText(Integer.toString(infantry.getWalkMP(true, true, false)));
mode1.setText("Mechanized Tracked");
break;
case WHEELED:
mp1.setText(Integer.toString(infantry.getWalkMP(true, true, false)));
mode1.setText("Mechanized Wheeled");
break;
case VTOL:
mp1.setText(Integer.toString(infantry.getJumpMP(false)));
if (infantry.hasMicrolite()) {
mode1.setText("VTOL (Microlite)");
} else {
mode1.setText("VTOL (Micro-copter)");
}
break;
case SUBMARINE:
mp1.setText(Integer.toString(infantry.getActiveUMUCount()));
mode1.setText("Mechanized SCUBA");
break;
case INF_MOTORIZED:
mp1.setText(Integer.toString(infantry.getWalkMP(true, true, false)));
mode1.setText("Motorized");
break;
case INF_LEG:
default:
mp1.setText(Integer.toString(infantry.getWalkMP(true, true, false)));
mode1.setText("Ground");
break;
}
if (mp1.getText().equals("0")) {
mp1.setText("0*");
}
((Text) mp1.getParent()).rebuild();
((Text) mode1.getParent()).rebuild();
List<String> notes = new ArrayList<>();
if (infantry.isMechanized() || infantry.isArmorEncumbering()) {
notes.add("Cannot make anti-'Mech attacks.");
}
if (infantry.hasSpaceSuit()) {
notes.add("Can operate in vacuum.");
}
if (rangeWeapon.hasFlag(WeaponType.F_INF_BURST)) {
notes.add("+1D6 damage vs. conventional infantry.");
}
if (rangeWeapon.hasFlag(WeaponType.F_INF_NONPENETRATING)) {
notes.add("Can only damage conventional infantry.");
}
if (infantry.getPrimaryWeapon().hasFlag(WeaponType.F_INFERNO) || (infantry.getSecondaryWeapon() != null && infantry.getSecondaryWeapon().hasFlag(WeaponType.F_INFERNO))) {
notes.add("Flame-based weapon.");
} else {
for (int i = 0; i < infantry.getPrimaryWeapon().getModesCount(); i++) {
if (infantry.getPrimaryWeapon().getMode(i).equals("Heat")) {
notes.add("Flame-based weapon.");
break;
}
}
if (infantry.getSecondaryWeapon() != null) {
for (int i = 0; i < infantry.getSecondaryWeapon().getModesCount(); i++) {
if (infantry.getSecondaryWeapon().getMode(i).equals("Heat")) {
notes.add("Flame-based weapon.");
}
}
}
}
if (infantry.getPrimaryWeapon().hasFlag(WeaponType.F_INF_AA) || (infantry.getSecondaryWeapon() != null && infantry.getSecondaryWeapon().hasFlag(WeaponType.F_INF_AA))) {
notes.add("Can attack airborn units.");
}
if (infantry.hasSpecialization(Infantry.BRIDGE_ENGINEERS)) {
notes.add("Bridge-building equipment");
}
if (infantry.hasSpecialization(Infantry.DEMO_ENGINEERS)) {
notes.add("Equipped with demolition gear");
}
if (infantry.hasSpecialization(Infantry.FIRE_ENGINEERS)) {
notes.add("Firefighting equipment");
}
if (infantry.hasSpecialization(Infantry.MINE_ENGINEERS)) {
notes.add("Minesweeper equipment");
}
if (infantry.hasSpecialization(Infantry.TRENCH_ENGINEERS)) {
notes.add("Trench/Fieldwork equipment");
}
if (infantry.hasSpecialization(Infantry.MARINES)) {
notes.add("No penalties for vacuum or zero-G");
}
if (infantry.hasSpecialization(Infantry.MOUNTAIN_TROOPS)) {
notes.add("Mountain climbing equipment");
}
if (infantry.hasSpecialization(Infantry.PARAMEDICS)) {
notes.add("Paramedic equipment.");
}
if (infantry.hasSpecialization(Infantry.PARATROOPS)) {
notes.add("Can make atmospheric drops.");
}
if (infantry.hasSpecialization(Infantry.SENSOR_ENGINEERS)) {
notes.add("Surveillance and communication equipment");
}
if (infantry.hasSpecialization(Infantry.TAG_TROOPS)) {
notes.add("Equipped with TAG (Range 3/6/9)");
}
if (infantry.hasSneakECM()) {
notes.add("Invisible to standard/light active probes.");
}
for (int i = 0; i < Math.min(8, notes.size()); i++) {
tspan = (Tspan) diagram.getElement(ID_NOTE_LINE + i);
tspan.setText(notes.get(i));
}
((Text) diagram.getElement(ID_NOTES)).rebuild();
diagram.updateTime(0);
diagram.render(g2d);
}
} catch (SVGException ex) {
ex.printStackTrace();
}
g2d.scale(pageFormat.getImageableWidth(), pageFormat.getImageableHeight());
}
Aggregations