private static void createAerospaceSuperioritySquadron() { FormationType ft = new FormationType("Aerospace Superiority Squadron"); ft.allowedUnitTypes = FLAG_FIGHTER; ft.otherCriteria.add(new PercentConstraint(0.51, ms -> EnumSet.of(UnitRole.INTERCEPTOR, UnitRole.FAST_DOGFIGHTER).contains(UnitRoleHandler.getRoleFor(ms)), "Interceptor/Fast Dogfighter")); ft.groupingCriteria = new GroupingConstraint(FLAG_FIGHTER, 2, 0, ms -> true, (ms0, ms1) -> ms0.getChassis().equals(ms1.getChassis()), "Same chassis"); allFormationTypes.put(ft.name, ft); }
private static void createStrikeSquadron() { FormationType ft = new FormationType("Strike Squadron"); ft.allowedUnitTypes = FLAG_FIGHTER; ft.otherCriteria.add(new PercentConstraint(0.51, ms -> EnumSet.of(UnitRole.ATTACK_FIGHTER, UnitRole.DOGFIGHTER).contains(UnitRoleHandler.getRoleFor(ms)), "Attack, Dogfighter")); ft.groupingCriteria = new GroupingConstraint(FLAG_FIGHTER, 2, 0, ms -> true, (ms0, ms1) -> ms0.getChassis().equals(ms1.getChassis()), "Same chassis"); allFormationTypes.put(ft.name, ft); }
private static void createInterceptorSquadron() { FormationType ft = new FormationType("Interceptor Squadron"); ft.allowedUnitTypes = FLAG_FIGHTER; ft.otherCriteria.add(new PercentConstraint(0.51, ms -> UnitRoleHandler.getRoleFor(ms).equals(UnitRole.INTERCEPTOR), "Interceptor")); ft.groupingCriteria = new GroupingConstraint(FLAG_FIGHTER, 2, 0, ms -> true, (ms0, ms1) -> ms0.getChassis().equals(ms1.getChassis()), "Same chassis"); allFormationTypes.put(ft.name, ft); }
private static void createTransportSquadron() { FormationType ft = new FormationType("Transport Squadron"); ft.allowedUnitTypes = FLAG_FIGHTER | FLAG_SMALL_CRAFT | FLAG_DROPSHIP; ft.otherCriteria.add(new PercentConstraint(0.5, ms -> UnitRoleHandler.getRoleFor(ms).equals(UnitRole.TRANSPORT), "Transport")); ft.groupingCriteria = new GroupingConstraint(FLAG_FIGHTER, 2, Integer.MAX_VALUE, ms -> true, (ms0, ms1) -> ms0.getChassis().equals(ms1.getChassis()), "Same chassis"); allFormationTypes.put(ft.name, ft); }
private static void createFireSupportSquadron() { FormationType ft = new FormationType("Fire Support Squadron"); ft.allowedUnitTypes = FLAG_FIGHTER; ft.mainCriteria = ms -> EnumSet.of(UnitRole.FIRE_SUPPORT, UnitRole.DOGFIGHTER).contains(UnitRoleHandler.getRoleFor(ms)); ft.mainDescription = "Fire Support, Dogfighter"; ft.otherCriteria.add(new PercentConstraint(0.5, ms -> UnitRoleHandler.getRoleFor(ms).equals(UnitRole.FIRE_SUPPORT), "Fire Support")); ft.groupingCriteria = new GroupingConstraint(FLAG_FIGHTER, 2, 0, ms -> true, (ms0, ms1) -> ms0.getChassis().equals(ms1.getChassis()), "Same chassis"); allFormationTypes.put(ft.name, ft); }
private static void createEWSquadron() { FormationType ft = new FormationType("Electronic Warfare Squadron"); ft.allowedUnitTypes = FLAG_FIGHTER; ft.otherCriteria.add(new PercentConstraint(0.51, ms -> ms.getEquipmentNames().stream().map(en -> EquipmentType.get(en)) .anyMatch(et -> et instanceof TAGWeapon || (et instanceof MiscType && (((MiscType)et).hasFlag(MiscType.F_BAP) || ((MiscType)et).hasFlag(MiscType.F_ECM)))), "Probe, ECM, TAG")); ft.groupingCriteria = new GroupingConstraint(FLAG_FIGHTER, 2, 0, ms -> true, (ms0, ms1) -> ms0.getChassis().equals(ms1.getChassis()), "Same chassis"); ft.reportMetrics.put("Probe/ECM/TAG", ms -> ft.otherCriteria.get(0).criterion.test(ms)); allFormationTypes.put(ft.name, ft); }
public static void main(String[] args) { Parameters p = new Parameters(); p.mechs = 4; p.tanks = 4; p.infantry = 0; p.ba = 4; p.maxBV = 8000; p.minBV = 7600; p.minYear = 3050; p.maxYear = 3055; p.tech = TechConstants.T_IS_TW_NON_BOX; p.canon = true; p.padWithInfantry = true; ArrayList<MechSummary> units = generateArmy(p); int totalBV = 0; for (MechSummary m : units) { totalBV += m.getBV(); System.out.print(m.getChassis()); System.out.print(" "); System.out.print(m.getModel()); System.out.print(" "); System.out.println(m.getBV()); } System.out.print("Total: "); System.out.println(totalBV); }
/** * Helper function used by some grouping constraints to compare units. Units are considered to match * if they are the same model, but omnis can match with different configurations. This is used primarily * for ground units; aerospace units match based on chassis. * * @param ms0 * @param ms1 * @return Whether the two units are considered the same for grouping considerations. */ private static boolean checkUnitMatch(final MechSummary ms0, final MechSummary ms1) { final ModelRecord mRec = RATGenerator.getInstance().getModelRecord(ms0.getName()); if (null != mRec && mRec.isOmni()) { return ms0.getChassis().equals(ms1.getChassis()); } else { return ms0.getName().equals(ms1.getName()); } }
private void exportList(int connId, String path) { try { PrintWriter pw1 = new PrintWriter(new FileWriter(path)); MechSummary[] msums = MechSummaryCache.getInstance().getAllMechs(); for (MechSummary ms1 : msums) { pw1.println(ms1.getChassis() + ", " + ms1.getModel() + ", " + ms1.getBV()); } pw1.flush(); pw1.close(); server.sendServerChat(server.getPlayer(connId).getName() + " has exported a unit list."); } catch (Exception e) { server.sendServerChat(connId, "/exportlist: execution failed"); server.sendServerChat(connId, e.toString()); } } }
String allId = QuirksHandler.getUnitId(summary.getChassis(), "all", MechSummary.determineETypeName(summary)); String specificId = QuirksHandler.getUnitId( summary.getChassis(), summary.getModel(), MechSummary.determineETypeName(summary)); List<Entity> entities;
@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; } } }
w.write(unit.getUnitSubType()); w.write(","); w.write(unit.getChassis()); w.write(","); w.write(unit.getModel()); w.write(Integer.toString(unit.getJumpMp())); } else { w.write(unit.getChassis() + (unit.getModel().equals("") ? "|" : " " + unit.getModel() + "|"));
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++) {
String unitId = QuirksHandler.getUnitId(summary.getChassis(), summary.getModel(), ""); String unitIdNoModel = QuirksHandler.getUnitId( summary.getChassis(), "all", ""); summary.getChassis(), QuirksHandler.getModel(quirkId), MechSummary.determineETypeName(summary));
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 "?"; }
for(MechSummary summary : MechSummaryCache.getInstance().getAllMechs()) { if(!en.getChassis().equalsIgnoreCase(summary.getChassis()) || en.getModel().equalsIgnoreCase(summary.getModel()) || summary.getTons() != en.getWeight()
ms = table.generateUnit(u -> fd.getModels().contains(u.getName())); } else if (!fd.getChassis().isEmpty()) { ms = table.generateUnit(u -> fd.getChassis().contains(u.getChassis())); } else { ms = table.generateUnit();
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 ModelRecord(MechSummary ms) { this(ms.getChassis(), ms.getModel()); mechSummary = ms; unitType = parseUnitType(ms.getUnitType());
return ms.getChassis();