use of pcgen.cdom.list.CompanionList in project pcgen by PCGen.
the class FollowerLimitFacet method add.
private void add(CharID id, FollowerLimit fo, CDOMObject cdo) {
if (fo == null) {
throw new IllegalArgumentException("Object to add may not be null");
}
CompanionList cl = fo.getCompanionList().get();
Map<FollowerLimit, Set<CDOMObject>> foMap = getConstructingCachedMap(id, cl);
Set<CDOMObject> set = foMap.get(fo);
if (set == null) {
set = new WrappedMapSet<>(IdentityHashMap.class);
foMap.put(fo, set);
}
set.add(cdo);
}
use of pcgen.cdom.list.CompanionList in project pcgen by PCGen.
the class PCGVer2Parser method parseMasterLine.
private void parseMasterLine(final String line) {
final PCGTokenizer tokens;
try {
tokens = new PCGTokenizer(line);
} catch (PCGParseException pcgpex) {
final String msg = LanguageBundle.getFormattedString(//$NON-NLS-1$
"Warnings.PCGenParser.IllegalMaster", line, pcgpex.getMessage());
warnings.add(msg);
return;
}
final Follower aMaster = new Follower(Constants.EMPTY_STRING, Constants.EMPTY_STRING, null);
for (PCGElement element : tokens.getElements()) {
final String tag = element.getName();
if (IOConstants.TAG_MASTER.equals(tag)) {
aMaster.setName(EntityEncoder.decode(element.getText()));
} else if (IOConstants.TAG_TYPE.equals(tag)) {
String cType = EntityEncoder.decode(element.getText());
CompanionList cList = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(CompanionList.class, cType);
if (cList == null) {
Logging.errorPrint("Cannot find CompanionList: " + cType);
} else {
aMaster.setType(cList);
}
} else if (IOConstants.TAG_HITDICE.equals(tag)) {
try {
aMaster.setUsedHD(Integer.parseInt(element.getText()));
} catch (NumberFormatException nfe) {
// nothing we can do about it
}
} else if (IOConstants.TAG_FILE.equals(tag)) {
String inputFileName = EntityEncoder.decode(element.getText());
String masterFileName = makeFilenameAbsolute(inputFileName);
if (masterFileName == null) {
final String msg = LanguageBundle.getFormattedString(//$NON-NLS-1$
"Warnings.PCGenParser.CantFindMaster", inputFileName);
warnings.add(msg);
} else {
aMaster.setFileName(masterFileName);
}
} else if (IOConstants.TAG_ADJUSTMENT.equals(tag)) {
aMaster.setAdjustment(Integer.parseInt(element.getText()));
}
}
if (!Constants.EMPTY_STRING.equals(aMaster.getFileName()) && !Constants.EMPTY_STRING.equals(aMaster.getName()) && !Constants.EMPTY_STRING.equals(aMaster.getType().toString())) {
thePC.setMaster(aMaster);
}
}
Aggregations