public boolean hasEdgeRemaining() { return (getOptions().intOption(OptionsConstants.EDGE) > 0); }
private void addAugmentationNotes(List<String> notes) { final List<IOption> options = new ArrayList<>(); for (final Enumeration<IOption> e = inf.getCrew().getOptions().getOptions(); e.hasMoreElements();) { final IOption option = e.nextElement(); if (option.booleanValue()) { options.add(option); } } if (!options.isEmpty()) { notes.add(Messages.getString("TROView.InfantryNote.Augmented")); options.forEach(o -> { notes.add(o.getDisplayableName().replaceAll("\\s+\\(Not Implemn?ented\\)", "") + ": " + o.getDescription().replaceAll("See IO.*", "")); }); } } }
/** * determine if an entity has an ability at a given level. * The entity may gain this ability from different places, not exclusively the crew. * @param name - name of the ability as recorded in the optionsme * @param choice - A string indicating the given level being asked about * @return true if the entity has this ability at the given choice from some source */ public boolean hasAbility(String name, String choice) { if(null != getCrew()) { return getCrew().getOptions().stringOption(name).equals(choice); } return false; }
private void parseAdvantages(Entity entity, String adv) { String[] advantages = adv.split(SEPARATOR_SPACE, -1); for(String curAdv : advantages) { String[] advantageData = curAdv.split(SEPARATOR_COLON, -1); IOption option = entity.getCrew().getOptions().getOption(advantageData[0]); if(null == option) { System.err.println(String.format("Ignoring invalid pilot advantage '%s'", //$NON-NLS-1$ curAdv)); } else { System.out.println(String.format("Adding pilot advantage '%s' to %s", //$NON-NLS-1$ curAdv, entity.getDisplayName())); if(advantageData.length > 1) { option.setValue(advantageData[1]); } else { option.setValue(true); } } } }
public int rollPilotingSkill() { if (getOptions().booleanOption(OptionsConstants.PILOT_APTITUDE_PILOTING)) { return Compute.d6(3, 2); } return Compute.d6(2); }
public int rollGunnerySkill() { if (getOptions().booleanOption(OptionsConstants.PILOT_APTITUDE_GUNNERY)) { return Compute.d6(3, 2); } return Compute.d6(2); }
public void decreaseEdge() { IOption edgeOption = getOptions().getOption(OptionsConstants.EDGE); edgeOption.setValue((Integer) edgeOption.getValue() - 1); }
/** * determine if an entity has an ability that is identified by its presence or absence only. * The entity may gain this ability from different places, not exclusively the crew. * @param name - name of the ability as recorded in the options * @return true if the entity has this ability from some source */ public boolean hasAbility(String name) { if(null != getCrew()) { return getCrew().getOptions().booleanOption(name); } //TODO: look for the ability at the player level return false; }
/** * Worker function that takes the PilotOptions (SPAs, in other words) from the given "old crew" and sets them for a person. * @param p The person whose SPAs to populate * @param oldCrew The entity the SPAs of whose crew we're importing */ private static void populateOptionsFromCrew(Person p, Crew oldCrew) { Enumeration<IOption> optionsEnum = oldCrew.getOptions().getOptions(); while(optionsEnum.hasMoreElements()) { IOption currentOption = (IOption) optionsEnum.nextElement(); p.getOptions().getOption(currentOption.getName()).setValue(currentOption.getValue()); } }
crew.getOptions().getOption(advName) .setValue(value); } catch (Exception e) { crew.getOptions().getOption(edgeName) .setValue(value); } catch (Exception e) { crew.getOptions().getOption(implantName) .setValue(value); } catch (Exception e) {
private void setOptions() { Entity entity = entities.get(0); IOption option; for (final Object newVar : optionComps) { DialogOptionComponent comp = (DialogOptionComponent) newVar; option = comp.getOption(); if ((comp.getValue() == Messages.getString("CustomMechDialog.None"))) { // NON-NLS-$1 entity.getCrew().getOptions().getOption(option.getName()) .setValue("None"); // NON-NLS-$1 } else { entity.getCrew().getOptions().getOption(option.getName()) .setValue(comp.getValue()); } } }
/** * Generates an entity at specific coordinates * Vital statistics: * ID: 1 * Max weapon range: 21 (LRMs, obviously) * Final path coordinates: (10, 10) * Final path facing: straight north * No SPAs * Default crew * @return */ private Entity generateMockEntity(int x, int y) { final Entity mockEntity = Mockito.mock(BipedMech.class); Mockito.when(mockEntity.getMaxWeaponRange()).thenReturn(21); final Crew mockCrew = Mockito.mock(Crew.class); Mockito.when(mockEntity.getCrew()).thenReturn(mockCrew); final PilotOptions mockOptions = Mockito.mock(PilotOptions.class); Mockito.when(mockCrew.getOptions()).thenReturn(mockOptions); Mockito.when(mockOptions.booleanOption(Mockito.anyString())).thenReturn(false); final Coords mockMyCoords = new Coords(x, y); Mockito.when(mockEntity.getPosition()).thenReturn(mockMyCoords); Mockito.when(mockEntity.getHeatCapacity()).thenReturn(20); Mockito.when(mockEntity.getHeat()).thenReturn(0); return mockEntity; }
Mockito.when(mockCrew.getOptions()).thenReturn(mockOptions); Mockito.when(mockOptions.booleanOption(Mockito.anyString())).thenReturn(false);
Mockito.when(mockCrew.getOptions()).thenReturn(mockOptions); Mockito.when(mockOptions.booleanOption(Mockito.any(String.class))).thenReturn(false); Mockito.when(mockPath.getFinalCoords()).thenReturn(new Coords(0, 0));
for (Enumeration<IOptionGroup> advGroups = pilot.getOptions().getGroups(); advGroups.hasMoreElements();) { IOptionGroup advGroup = advGroups.nextElement(); if (pilot.countOptions(advGroup.getKey()) > 0) {
Mockito.when(mockCrew.getOptions()).thenReturn(mockOptions); Mockito.when(mockOptions.booleanOption(Mockito.anyString())).thenReturn(false);
IOption edgeOption = entity.getCrew().getOptions().getOption(OptionsConstants.EDGE); edgeOption.setValue((Integer) edge);
for (Enumeration<IOptionGroup> advGroups = en.getCrew().getOptions().getGroups(); advGroups .hasMoreElements();) { if (i >= (N_ADV - 1)) {
for (String aug : augmentations) { try { t.getCrew().getOptions().getOption(aug).setValue(true); } catch (NullPointerException ex) { throw new EntityLoadingException("Could not locate pilot option " + aug);
pilot.setPortraitCategory(crew.getPortraitCategory(0), 0); pilot.setPortraitFileName(crew.getPortraitFileName(0), 0); pilot.setOptions(crew.getOptions());