/** * Uses the "lance staggered deployment" algorithm to determine individual deployment turns * Not actually implemented currently. * @param botForce The list of entities to process. */ private static void setDeploymentTurnsStaggeredByLance(List<Entity> entityList) { MekHQ.getLogger().warning(AtBDynamicScenarioFactory.class, "setDeploymentTurnsStaggeredByLance", "Deployment Turn - Staggered by Lance not implemented"); }
/** * Attempt to deserialize an instance of a scenario modifier list from the passed-in file * @param xmlNode the node to deserialize * @return Possibly an instance of a scenario modifier list */ public static ScenarioModifierManifest Deserialize(String fileName) { ScenarioModifierManifest resultingList = null; try { JAXBContext context = JAXBContext.newInstance(ScenarioModifierManifest.class); Unmarshaller um = context.createUnmarshaller(); File xmlFile = new File(fileName); if(!xmlFile.exists()) { MekHQ.getLogger().warning(ScenarioModifierManifest.class, "Deserialize", String.format("Specified file %s does not exist", fileName)); return null; } Source inputSource = MekHqXmlUtil.createSafeXmlSource(new FileInputStream(xmlFile)); JAXBElement<ScenarioModifierManifest> templateElement = um.unmarshal(inputSource, ScenarioModifierManifest.class); resultingList = templateElement.getValue(); } catch(Exception e) { MekHQ.getLogger().error(ScenarioModifierManifest.class, "Deserialize", "Error Deserializing Scenario Modifier List", e); } return resultingList; } }
/** * Attempt to deserialize an instance of a scenario modifier from the passed-in file * @param xmlNode the node to deserialize * @return Possibly an instance of a scenario modifier list */ public static AtBScenarioModifier Deserialize(String fileName) { AtBScenarioModifier resultingList = null; try { JAXBContext context = JAXBContext.newInstance(AtBScenarioModifier.class); Unmarshaller um = context.createUnmarshaller(); File xmlFile = new File(fileName); if(!xmlFile.exists()) { MekHQ.getLogger().warning(AtBScenarioModifier.class, "Deserialize", String.format("Specified file %d does not exist", fileName)); return null; } Source inputSource = MekHqXmlUtil.createSafeXmlSource(new FileInputStream(xmlFile)); JAXBElement<AtBScenarioModifier> templateElement = um.unmarshal(inputSource, AtBScenarioModifier.class); resultingList = templateElement.getValue(); } catch(Exception e) { MekHQ.getLogger().error(ScenarioModifierManifest.class, "Deserialize", "Error Deserializing Scenario Modifier", e); } return resultingList; }
/** * Constructs a list of a faction's potential enemies based on common borders. * @param employerName The shortName of the employer faction * @return A list of faction that share a border */ public List<String> getEnemyList(String employerName) { Faction employer = Faction.getFaction(employerName); if (null == employer) { MekHQ.getLogger().warning(getClass(), "getEnemyList(String)", //$NON-NLS-1$ "Unknown faction key: " + employerName); //$NON-NLS-1$ return Collections.emptyList(); } return getEnemyList(Faction.getFaction(employerName)); }
/** * Worker function that adjusts the scenario's unit quality by the indicated amount, * capped between 0 and 5. Only effective for units generated after the adjustment has taken place. * Only capable of being applied to opfor. * @param scenario Scenario to modify. * @param c Working campaign * @param eventRecipient Whose * @param qualityAdjustment */ public static void adjustQuality(AtBDynamicScenario scenario, Campaign c, ForceAlignment eventRecipient, int qualityAdjustment) { if(eventRecipient != ForceAlignment.Opposing) { MekHQ.getLogger().warning(AtBScenarioModifierApplicator.class, "adjustQuality", "Cannot only adjust opfor unit quality"); return; } int currentQuality = scenario.getContract(c).getEnemyQuality(); currentQuality += qualityAdjustment; currentQuality = Math.min(IUnitRating.DRAGOON_ASTAR, currentQuality); currentQuality = Math.max(IUnitRating.DRAGOON_F, currentQuality); scenario.setEffectiveOpforQuality(currentQuality); }
factions.put(rec.getKey(), rec); } else { DefaultMmLogger.getInstance().warning(getClass(), METHOD_NAME, "Faction key not found in " + file.getPath());
protected void addTransportBays(Entity entity) { final List<Map<String, Object>> bays = new ArrayList<>(); for (final Bay bay : entity.getTransportBays()) { if (bay.isQuarters()) { continue; } final BayData bayData = BayData.getBayType(bay); if (null != bayData) { final Map<String, Object> bayRow = new HashMap<>(); bayRow.put("name", bayData.getDisplayName()); if (bayData.isCargoBay()) { bayRow.put("size", bay.getCapacity() + Messages.getString("TROView.tons")); } else { bayRow.put("size", (int) bay.getCapacity()); } bayRow.put("doors", bay.getDoors()); bays.add(bayRow); } else { DefaultMmLogger.getInstance().warning(getClass(), "addBays()", "Could not determine bay type for " + bay.toString()); } } setModelData("bays", bays); }