MCPcopy Create free account
hub / github.com/PCGen/pcgen / parseFeatLine

Method parseFeatLine

code/src/java/pcgen/io/PCGVer2Parser.java:2584–2637  ·  view source on GitHub ↗
(final String line)

Source from the content-addressed store, hash-verified

2582 * ###############################################################
2583 */
2584 private void parseFeatLine(final String line)
2585 {
2586 final PCGTokenizer tokens;
2587
2588 try
2589 {
2590 tokens = new PCGTokenizer(line);
2591 }
2592 catch (PCGParseException pcgpex)
2593 {
2594 final String msg = LanguageBundle.getFormattedString("Warnings.PCGenParser.IllegalFeat", //$NON-NLS-1$
2595 line, pcgpex.getMessage());
2596 warnings.add(msg);
2597
2598 return;
2599 }
2600
2601 final Iterator<PCGElement> it = tokens.getElements().iterator();
2602
2603 // the first element defines the Ability key name
2604 if (it.hasNext())
2605 {
2606 final PCGElement element = it.next();
2607
2608 final String abilityKey = EntityEncoder.decode(element.getText());
2609
2610 /* First, check to see if the PC already has this ability. If so,
2611 * then we just need to mod it. Otherwise we need to create a new
2612 * one and add it using non-aggregate (when using aggregate, we
2613 * get clones of the PCs actual feats, which don't get saved or
2614 * preserved) */
2615 Ability anAbility = Globals.getContext().getReferenceContext().getManufacturerId(AbilityCategory.FEAT)
2616 .getActiveObject(abilityKey);
2617 if (anAbility == null)
2618 {
2619 final String msg =
2620 LanguageBundle.getFormattedString(
2621 "Warnings.PCGenParser.CouldntAddAbility", //$NON-NLS-1$
2622 abilityKey);
2623 warnings.add(msg);
2624
2625 return;
2626 }
2627
2628 CNAbility pcAbility = CNAbilityFactory.getCNAbility(AbilityCategory.FEAT, Nature.NORMAL, anAbility);
2629 if (!anAbility.getSafe(ObjectKey.MULTIPLE_ALLOWED))
2630 {
2631 thePC.addAbility(new CNAbilitySelection(pcAbility), UserSelection.getInstance(),
2632 UserSelection.getInstance());
2633 }
2634 parseFeatsHandleAppliedToAndSaveTags(it, pcAbility);
2635 featsPresent = true;
2636 }
2637 }
2638
2639 private void parseFeatPoolLine(final String line)
2640 {

Callers 2

parseCachedLinesMethod · 0.95

Calls 15

getFormattedStringMethod · 0.95
getElementsMethod · 0.95
decodeMethod · 0.95
getTextMethod · 0.95
getContextMethod · 0.95
getCNAbilityMethod · 0.95
getInstanceMethod · 0.95
getSafeMethod · 0.80
getMessageMethod · 0.65
addMethod · 0.65
getActiveObjectMethod · 0.65

Tested by

no test coverage detected