fout.write(csvLine.toString()); for (MechSummary mech : mechs){ if (mech.getUnitType().equals("Gun Emplacement")){ continue; csvLine.append(mech.getChassis() + ","); csvLine.append(mech.getModel() + ","); csvLine.append(mech.getChassis() + " " + mech.getModel()+ ","); csvLine.append(mech.getSourceFile() + ","); csvLine.append(mech.getTons() + ","); csvLine.append(mech.getYear() + ","); if(mech.getAdvancedTechYear() <= mech.getYear()) { csvLine.append(","); } else { csvLine.append(mech.getYear() + ","); if(mech.getAdvancedTechYear()>0) { csvLine.append(mech.getAdvancedTechYear()).append(","); } else { csvLine.append(","); if(mech.getStandardTechYear()>0) { csvLine.append(mech.getStandardTechYear()).append(",");
return ms.getModel(); return ms.getChassis(); if ((opts != null) && ms.getUnitType().equals("BattleArmor")) { if (opts.booleanOption(OptionsConstants.ADVANCED_TACOPS_BA_WEIGHT)) { return ms.getTOweight(); } else { return ms.getTWweight(); return ms.getTons(); && opts.booleanOption(OptionsConstants.ADVANCED_GEOMETRIC_MEAN_BV)) { if (opts.booleanOption(OptionsConstants.ADVANCED_REDUCED_OVERHEAT_MODIFIER_BV)) { return ms.getRHGMBV(); } else { return ms.getGMBV(); return ms.getRHBV(); } else { return ms.getBV(); return ms.getYear(); return ms.getCost(); return ms.getLevel(client.getGame().getOptions().intOption(OptionsConstants.ALLOWED_YEAR)); return ms.getLevel();
private void stockBattleArmorSuits(Campaign c) { //this is just a test for(MechSummary summary : MechSummaryCache.getInstance().getAllMechs()) { if(!summary.getUnitType().equals("BattleArmor")) { continue; } //FIXME: I can't pull entity movement mode and quad shape off of mechsummary //try loading the full entity, but this might take too long if(null != summary) { Entity newEntity = null; try { newEntity = new MechFileParser(summary.getSourceFile(), summary.getEntryName()).getEntity(); } catch (EntityLoadingException e) { e.printStackTrace(); } if(null != newEntity) { BattleArmorSuit ba = new BattleArmorSuit(summary.getChassis(), summary.getModel(), (int)summary.getTons(), 1, summary.getWeightClass(), summary.getWalkMp(), summary.getJumpMp(), newEntity.entityIsQuad(), summary.isClan(), newEntity.getMovementMode(), c); parts.add(ba); } } } }
public int getWeightClass() { double tons; if (getUnitType().equals("BattleArmor")){ tons = getSuitWeight(); } else { tons = getTons(); } if (isSupport()) { return EntityWeightClass.getSupportWeightClass(m_nTons, m_sUnitSubType); } return EntityWeightClass.getWeightClass(tons, getUnitType()); }
@Override public int compare(MechSummary ms1, MechSummary ms2) { switch (m_nType) { case T_CHASSIS: return ms1.getChassis().compareTo(ms2.getChassis()); case T_MODEL: return ms1.getModel().compareTo(ms2.getModel()); case T_WEIGHT: return Double.compare(ms1.getTons(), ms2.getTons()); case T_BV: return Integer.compare(ms1.getBV(), ms2.getBV()); case T_YEAR: return Integer.compare(ms1.getYear(), ms2.getYear()); case T_COST: return Long.compare(ms1.getCost(), ms2.getCost()); case T_LEVEL: return ms1.getLevel().compareTo(ms2.getLevel()); default: return 0; } } }
officialUnitList).getAllMechs(); for (MechSummary unit : units) { String unitType = unit.getUnitType(); if (unitType.equalsIgnoreCase("mek")) { unitType = "'Mech"; w.write(unitType); w.write(","); w.write(unit.getUnitSubType()); w.write(","); w.write(unit.getChassis()); w.write(","); w.write(unit.getModel()); w.write(","); w.write(Integer.toString(unit.getBV())); w.write(","); w.write(Long.toString(unit.getCost())); w.write(","); w.write(Long.toString(unit.getUnloadedCost())); w.write(","); w.write(Integer.toString(unit.getYear())); w.write(","); w.write(TechConstants.getLevelDisplayableName(unit .getType())); w.write(","); w.write(Double.toString(unit.getTons())); w.write(","); if (unit.isClan()) { w.write("Clan,");
public ModelRecord(MechSummary ms) { this(ms.getChassis(), ms.getModel()); mechSummary = ms; unitType = parseUnitType(ms.getUnitType()); introYear = ms.getYear(); if (unitType == UnitType.MEK) { movementMode = EntityMovementMode.getMode(ms.getUnitSubType().toLowerCase()); double ammoBV = 0.0; boolean losTech = false; for (int i = 0; i < ms.getEquipmentNames().size(); i++) { if (null == ms.getEquipmentNames().get(i)) { DefaultMmLogger.getInstance().log(getClass(), "<init>(MechSummary)", LogLevel.ERROR, "RATGenerator ModelRecord encountered null equipment name in MechSummary for " + ms.getName() + ", index " + i); continue; EquipmentType eq = EquipmentType.get(ms.getEquipmentNames().get(i)); if (eq == null) { continue; totalBV += eq.getBV(null) * ms.getEquipmentQuantities().get(i); switch (((megamek.common.weapons.Weapon)eq).getAmmoType()) { case AmmoType.T_AC_LBX: case AmmoType.T_HAG: case AmmoType.T_SBGAUSS: flakBV += eq.getBV(null) * ms.getEquipmentQuantities().get(i);
/** * Loads the Entity and counts the number of docking hardpoints. * * @param ms The unit to load * @return The number of docking hardpoints on the unit. */ private int countHardpoints(MechSummary ms) { try { Entity entity = new MechFileParser(ms.getSourceFile(), ms.getEntryName()).getEntity(); int hardpoints = entity.getDockingCollars().size(); // TODO: count dropshuttle bays hardpointCache.put(ms, hardpoints); return hardpoints; } catch (EntityLoadingException ex) { return 0; } }
.intOption(OptionsConstants.ALLOWED_YEAR) : 999999; boolean techLevelMatch = false; int type = mech.getType(); if (client != null && client.getGame() != null && client.getGame().getOptions().booleanOption(OptionsConstants.ALLOWED_ERA_BASED)) { type = mech.getType(year); ((nClass == EntityWeightClass.SIZE) || (mech.getWeightClass() == nClass)) && (!cannonOnly || mech.isCanon() || useAlternate) && || (!checkSupportVee && mech.getUnitType().equals(UnitType.getTypeName(nUnit))) || (checkSupportVee && mech.isSupport())) && !(mech.getYear() > year)) { if(txtFilter.getText().length() > 0) { String text = txtFilter.getText(); return mech.getName().toLowerCase().contains(text.toLowerCase());
private static ITechnology calcTechProgression(MechSummary ms, int techFaction) { final String METHOD_NAME = "calcTechProgression(MechSummary, int)"; // $NON-NLS-1$ try { Entity en = new MechFileParser(ms.getSourceFile(), ms.getEntryName()).getEntity(); if (null == en) { MekHQ.getLogger().log(BuildMapTask.class, METHOD_NAME, LogLevel.ERROR, "Entity was null: " + ms.getName()); } return en.factionTechLevel(techFaction); } catch (EntityLoadingException ex) { MekHQ.getLogger().log(BuildMapTask.class, METHOD_NAME, LogLevel.ERROR, "Exception loading entity " + ms.getName()); MekHQ.getLogger().error(BuildMapTask.class, METHOD_NAME, ex); return null; } }
if (mech.getWalkMp() < walk) { return false; if (walk != mech.getWalkMp()) { return false; if (mech.getWalkMp() > walk) { return false; if (mech.getJumpMp() < jump) { return false; if (jump != mech.getJumpMp()) { return false; if (mech.getJumpMp() > jump) { return false; if (f.internalsType != mech.getInternalsType()) return false; if (!mech.getArmorType().contains(f.armorType)) return false; if (f.cockpitType != mech.getCockpitType()) return false; int armor = mech.getTotalArmor(); int maxArmor = mech.getTotalInternal() * 2 + 3;
for(MechSummary summary : MechSummaryCache.getInstance().getAllMechs()) { if(!en.getChassis().equalsIgnoreCase(summary.getChassis()) || en.getModel().equalsIgnoreCase(summary.getModel()) || summary.getTons() != en.getWeight() || !summary.getUnitType().equals(UnitType.determineUnitType(en))) { continue; if(!summary.isCanon() && options.allowCanonRefitOnly()) { continue; "Could not determine tech progression for " + summary.getName() // $NON-NLS-1$ + ", including among available refits."); // $NON-NLS-1$ } else if (!campaign.isLegal(techProg)) { variants.add(summary.getModel());
public Object getValueAt(int row, int col) { MechSummary ms = data[row]; if(col == COL_MODEL) { return ms.getModel(); } if(col == COL_CHASSIS) { return ms.getChassis(); } if(col == COL_WEIGHT) { return ms.getTons(); } if(col == COL_BV) { return ms.getBV(); } if(col == COL_YEAR) { return ms.getYear(); } if(col == COL_COST) { return formatter.format(getPurchasePrice(ms)); } return "?"; }
@Override public Object getValueAt(int rowIndex, int columnIndex) { MechSummary ms = units.get(rowIndex); switch(columnIndex) { case COL_NAME: return ms.getName(); case COL_WEIGHT_CLASS: return EntityWeightClass.getClassName(EntityWeightClass.getWeightClass(ms.getTons(), ms.getUnitType())); case COL_MOVEMENT: StringBuilder sb = new StringBuilder(); sb.append(String.valueOf(ms.getWalkMp())).append("/") .append(String.valueOf(ms.getRunMp())); if (formationType.isGround()) { sb.append("/").append(String.valueOf(ms.getJumpMp())); } return sb.toString(); case COL_ROLE: ModelRecord mr = RATGenerator.getInstance().getModelRecord(ms.getName()); if (null == mr) { return UnitRole.UNDETERMINED.toString(); } else { return UnitRoleHandler.getRoleFor(mr.getKey()).toString(); } default: Function<MechSummary,?> metric = formationType.getReportMetric(colNames.get(columnIndex)); return metric == null? "?" : metric.apply(ms); } } }
if (units.stream().anyMatch(ms -> !isAllowedUnitType(ModelRecord.parseUnitType(ms.getUnitType())))) { return false; || ms.getWeightClass() < minWeightClass || ms.getWeightClass() > maxWeightClass) { return false; .filter(ms -> groupingCriteria.appliesTo(ModelRecord.parseUnitType(ms.getUnitType()))) .collect(Collectors.toList()); if (groupedUnits.size() > 0) { Map<String,List<MechSummary>> groups = groupedUnits.stream() .collect(Collectors.groupingBy(ms -> ms.getChassis())); GROUP_LOOP: for (List<MechSummary> group : groups.values()) { for (int i = 0; i < group.size() - 1; i++) { if (!groupingCriteria.matches(group.get(i), group.get(j))) { groups = groupedUnits.stream() .collect(Collectors.groupingBy(ms -> ms.getName())); break GROUP_LOOP;
ArrayList<MechSummary> allBA = new ArrayList<MechSummary>(); for (MechSummary m : all) { if ((p.tech != TechConstants.T_ALL) && (p.tech != m.getType())) { if (m.getType() != TechConstants.T_CLAN_TW) { continue; if ((m.getType() != TechConstants.T_INTRO_BOXSET) && (m.getType() != TechConstants.T_IS_TW_NON_BOX)) { continue; if (m.getType() != TechConstants.T_INTRO_BOXSET) { continue; if ((m.getType() != TechConstants.T_INTRO_BOXSET) && (m.getType() != TechConstants.T_IS_TW_NON_BOX) && (m.getType() != TechConstants.T_CLAN_TW)) { continue; if ((m.getType() != TechConstants.T_INTRO_BOXSET) && (m.getType() != TechConstants.T_IS_TW_NON_BOX)) { continue; if ((m.getType() != TechConstants.T_INTRO_BOXSET) && (m.getType() != TechConstants.T_IS_TW_NON_BOX) && (m.getType() != TechConstants.T_IS_ADVANCED) && (m.getType() != TechConstants.T_IS_EXPERIMENTAL) && (m.getType() != TechConstants.T_IS_UNOFFICIAL)) { continue;
String allId = QuirksHandler.getUnitId(summary.getChassis(), "all", MechSummary.determineETypeName(summary)); String specificId = QuirksHandler.getUnitId( summary.getChassis(), summary.getModel(), MechSummary.determineETypeName(summary)); List<Entity> entities; if (quirkId.equals(allId) || quirkId.equals(specificId)) { idEntitiesMap.put(quirkId, entities); entities.add(loadEntity(summary.getSourceFile(), summary.getEntryName()));
o.unit.getUnitType(), o.unit.isSupport()); return o.unit.getName(); return ""; return formatter.format(Math.ceil(o.unit.getCost() * o.pct / 100.0));
private long getPurchasePrice(MechSummary ms) { long cost = ms.getCost(); if(ms.getUnitType().equals(UnitType.getTypeName(UnitType.INFANTRY)) || ms.getUnitType().equals(UnitType.getTypeName(UnitType.BATTLE_ARMOR))) { cost = ms.getAlternateCost(); } if(TechConstants.isClan(ms.getType())) { cost *= campaign.getCampaignOptions().getClanPriceModifier(); } return cost; }