@Override public List<MechSummary> generate(int count, String faction, int unitType, int weightClass, int year, int quality, Predicate<MechSummary> filter) { RAT rat = findRAT(faction, unitType, weightClass, year, quality); if (rat != null) { if (unitType == UnitType.TANK) { filter = filter.and(ms -> ms.getUnitType().equals("Tank")); } else if (unitType == UnitType.VTOL) { filter = filter.and(ms -> ms.getUnitType().equals("VTOL")); } return RandomUnitGenerator.getInstance().generate(count, rat.ratName, filter); } return new ArrayList<MechSummary>(); }
public static String determineETypeName(MechSummary ms) { if (ms.getUnitType().equals("BattleArmor")) { return Entity.getEntityMajorTypeName(Entity.ETYPE_INFANTRY); } else if (ms.getUnitType().equals("Infantry")) { return Entity.getEntityMajorTypeName(Entity.ETYPE_INFANTRY); } else if (ms.getUnitType().equals("VTOL")) { return Entity.getEntityMajorTypeName(Entity.ETYPE_VTOL); } else if (ms.getUnitType().equals("Naval")) { return Entity.getEntityMajorTypeName(Entity.ETYPE_TANK); } else if (ms.getUnitType().equals("Gun Emplacement")) { return Entity.getEntityMajorTypeName(Entity.ETYPE_TANK); } else if (ms.getUnitType().equals("Tank")) { return Entity.getEntityMajorTypeName(Entity.ETYPE_TANK); } else if (ms.getUnitType().equals("Mek")) { return Entity.getEntityMajorTypeName(Entity.ETYPE_MECH); } else if (ms.getUnitType().equals("ProtoMek")) { return Entity.getEntityMajorTypeName(Entity.ETYPE_PROTOMECH); } else if (ms.getUnitType().equals("Space Station")) { return Entity.getEntityMajorTypeName(Entity.ETYPE_AERO); } else if (ms.getUnitType().equals("Jumpship")) { return Entity.getEntityMajorTypeName(Entity.ETYPE_AERO); } else if (ms.getUnitType().equals("Dropship")) { return Entity.getEntityMajorTypeName(Entity.ETYPE_AERO); } else if (ms.getUnitType().equals("Small Craft")) { return Entity.getEntityMajorTypeName(Entity.ETYPE_AERO); } else if (ms.getUnitType().equals("Conventional Fighter")) { return Entity.getEntityMajorTypeName(Entity.ETYPE_AERO); } else if (ms.getUnitType().equals("Aero")) { return Entity.getEntityMajorTypeName(Entity.ETYPE_AERO); } else if (ms.getUnitType().equals("Unknown")) {
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()); }
private static void createUrbanLance() { FormationType ft = new FormationType("Urban"); ft.allowedUnitTypes = FLAG_GROUND; ft.idealRole = UnitRole.AMBUSHER; ft.otherCriteria.add(new PercentConstraint(0.5, ms -> ms.getJumpMp() > 0 || ms.getUnitType().equals(UnitType.getTypeName(UnitType.INFANTRY)) || ms.getUnitType().equals(UnitType.getTypeName(UnitType.BATTLE_ARMOR)), "Jump 1+ or Infantry/BA")); ft.otherCriteria.add(new PercentConstraint(0.5, ms -> ms.getWalkMp() <= 4, "Walk/Cruise <= 4")); allFormationTypes.put(ft.name, ft); }
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; }
Map<Integer,Integer> failedByType = new HashMap<>(); for (int i = 0; i < ms.length; i++) { int unitType = UnitType.determineUnitTypeCode(ms[i].getUnitType()); if (unitType != UnitType.GUN_EMPLACEMENT) { Entity entity = loadEntity(ms[i].getSourceFile(), ms[i]
if (units.stream().anyMatch(ms -> !isAllowedUnitType(ModelRecord.parseUnitType(ms.getUnitType())))) { return false; .filter(ms -> groupingCriteria.appliesTo(ModelRecord.parseUnitType(ms.getUnitType()))) .collect(Collectors.toList()); if (groupedUnits.size() > 0) {
officialUnitList).getAllMechs(); for (MechSummary unit : units) { String unitType = unit.getUnitType(); if (unitType.equalsIgnoreCase("mek")) { unitType = "'Mech";
o.unit.getUnitType(), o.unit.isSupport());
@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); } } }
fout.write(csvLine.toString()); for (MechSummary mech : mechs){ if (mech.getUnitType().equals("Gun Emplacement")){ continue; csvLine.append(mech.getUnitType() + "-" + (mech.getUnitSubType() + ",")); if (mech.getUnitType().equals("Mek")){ csvLine.append(Mech.COCKPIT_STRING[mech.getCockpitType()]+ ","); } else
&& !m.getUnitType().equals( UnitType.getTypeName(UnitType.INFANTRY))) { continue; if (((!m.getUnitType().equals(UnitType.getTypeName(UnitType.INFANTRY))) && (!m.getUnitType().equals(UnitType.getTypeName(UnitType.PROTOMEK))) && (!m.getUnitType().equals(UnitType.getTypeName(UnitType.BATTLE_ARMOR)))) && (p.advancedSearchFilter != null && !MechSearchFilter.isMatch(m, p.advancedSearchFilter))) if (m.getUnitType().equals(UnitType.getTypeName(UnitType.MEK))) { allMechs.add(m); } else if (m.getUnitType() .equals(UnitType.getTypeName(UnitType.TANK)) || m.getUnitType().equals( UnitType.getTypeName(UnitType.VTOL))) { allTanks.add(m); } else if (m.getUnitType().equals( UnitType.getTypeName(UnitType.BATTLE_ARMOR))) { allBA.add(m); } else if (m.getUnitType().equals( UnitType.getTypeName(UnitType.INFANTRY))) { allInfantry.add(m);
/** * Generates a tank entity, either artillery or normal. * @param params Unit generation parameters. * @param skill skill level * @param artillery whether or not the unit generated should be artillery * @return Entity or null if unable to generate. */ public static Entity getTankEntity(UnitGeneratorParameters params, int skill, boolean artillery, Campaign campaign) { MechSummary ms = null; if(artillery) { params.getMissionRoles().add(MissionRole.ARTILLERY); } if (campaign.getCampaignOptions().getOpforUsesVTOLs()) { params.getMovementModes().addAll(IUnitGenerator.MIXED_TANK_VTOL); ms = campaign.getUnitGenerator().generate(params); } else { params.setFilter(v -> !v.getUnitType().equals("VTOL")); ms = campaign.getUnitGenerator().generate(params); } if (ms == null) { return null; } return createEntityWithCrew(params.getFaction(), skill, campaign, ms); }
ms = campaign.getUnitGenerator() .generate(faction, unitType, weightClass, campaign.getCalendar() .get(Calendar.YEAR), quality, v -> !v.getUnitType().equals("VTOL"));
|| (!checkSupportVee && mech.getUnitType().equals(UnitType.getTypeName(nUnit))) || (checkSupportVee && mech.isSupport()))
public ModelRecord(MechSummary ms) { this(ms.getChassis(), ms.getModel()); mechSummary = ms; unitType = parseUnitType(ms.getUnitType()); introYear = ms.getYear(); if (unitType == UnitType.MEK) { (ms.getUnitType().equals("Mek") || ms.getUnitType().equals("Tank") || ms.getUnitType().equals("BattleArmor") || ms.getUnitType().equals("Infantry") || ms.getUnitType().equals("ProtoMek") || ms.getUnitType().equals("Naval") || ms.getUnitType().equals("Gun Emplacement"))) { flak = flakBV / totalBV; longRange = lrBV / totalBV;
@Override public boolean include(Entry<? extends MechTableModel, ? extends Integer> entry) { MechTableModel mechModel = entry.getModel(); MechSummary mech = mechModel.getMechSummary(entry.getIdentifier()); ITechnology tech = UnitTechProgression.getProgression(mech, campaign.getTechFaction(), true); if ( /*year limits*/ (!campaign.getCampaignOptions().limitByYear() || mech.getYear() <= year) && /*Clan/IS limits*/ (campaign.getCampaignOptions().allowClanPurchases() || !TechConstants.isClan(mech.getType())) && (campaign.getCampaignOptions().allowISPurchases() || TechConstants.isClan(mech.getType())) && /* Canon */ (mech.isCanon() || !campaign.getCampaignOptions().allowCanonOnly()) && /* Weight */ (mech.getWeightClass() == nClass || nClass == EntityWeightClass.SIZE) && /* Technology Level */ (null != tech) && campaign.isLegal(tech) && /*Unit type*/ (nUnit == UnitType.SIZE || mech.getUnitType().equals(UnitType.getTypeName(nUnit))) && (searchFilter==null || MechSearchFilter.isMatch(mech, searchFilter))) { if(txtFilter.getText().length() > 0) { String text = txtFilter.getText(); return mech.getName().toLowerCase().contains(text.toLowerCase()); } return true; } return false; } };
|| en.getModel().equalsIgnoreCase(summary.getModel()) || summary.getTons() != en.getWeight() || !summary.getUnitType().equals(UnitType.determineUnitType(en))) { continue;
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); } } } }
if ((opts != null) && ms.getUnitType().equals("BattleArmor")) { if (opts.booleanOption(OptionsConstants.ADVANCED_TACOPS_BA_WEIGHT)) { return ms.getTOweight();