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

Class FeatLoader

code/src/java/pcgen/persistence/lst/FeatLoader.java:33–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31import pcgen.util.Logging;
32
33public final class FeatLoader extends AbilityLoader
34{
35 private boolean defaultFeatsLoaded = false;
36
37 @Override
38 public Ability parseLine(LoadContext context, Ability aFeat, String lstLine, SourceEntry source)
39 throws PersistenceLayerException
40 {
41 Ability feat = aFeat;
42
43 AbstractReferenceContext referenceContext = context.getReferenceContext();
44 AbilityCategory featCategory = referenceContext.get(AbilityCategory.class, "FEAT");
45 if (feat == null)
46 {
47 feat = new Ability();
48 int tabLoc = lstLine.indexOf(SystemLoader.TAB_DELIM);
49 String name = tabLoc == -1 ? lstLine : lstLine.substring(0, tabLoc);
50 feat.setName(name.intern());
51 feat.setCDOMCategory(featCategory);
52 context.addStatefulInformation(feat);
53 context.getReferenceContext().importObject(feat);
54 }
55 else
56 {
57 feat.setCDOMCategory(AbilityCategory.FEAT);
58 }
59
60 return super.parseLine(context, feat, lstLine, source);
61 }
62
63 @Override
64 protected void loadLstFile(LoadContext context, CampaignSourceEntry sourceEntry)
65 {
66 super.loadLstFile(context, sourceEntry);
67
68 if (!defaultFeatsLoaded)
69 {
70 loadDefaultFeats(context, sourceEntry);
71 }
72 }
73
74 /**
75 * This method loads the default feats with the first feat source.
76 * @param context
77 * @param firstSource CampaignSourceEntry first loaded by this loader
78 */
79 private void loadDefaultFeats(LoadContext context, CampaignSourceEntry firstSource)
80 {
81 AbstractReferenceContext referenceContext = context.getReferenceContext();
82 AbilityCategory featCategory = referenceContext.get(AbilityCategory.class, "FEAT");
83 Ability wpFeat =
84 referenceContext.getManufacturerId(featCategory).getActiveObject(Constants.INTERNAL_WEAPON_PROF);
85 if (wpFeat == null)
86 {
87
88 /* Add catch-all feat for weapon proficiencies that cannot be granted as part
89 * of a Feat eg. Simple weapons should normally be applied to the Simple
90 * Weapon Proficiency feat, but it does not allow multiples (either all or

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected