use of pcgen.cdom.base.CategorizedChooseInformation in project pcgen by PCGen.
the class ChooseFeatToken method parseTokenWithSeparator.
protected ParseResult parseTokenWithSeparator(LoadContext context, ReferenceManufacturer<Ability> rm, CDOMObject obj, String value) {
int pipeLoc = value.lastIndexOf('|');
String activeValue;
String title;
if (pipeLoc == -1) {
activeValue = value;
title = getDefaultTitle();
} else {
String titleString = value.substring(pipeLoc + 1);
if (titleString.startsWith("TITLE=")) {
title = titleString.substring(6);
if (title.startsWith("\"")) {
title = title.substring(1, title.length() - 1);
}
activeValue = value.substring(0, pipeLoc);
if (title == null || title.isEmpty()) {
return new ParseResult.Fail(getParentToken() + Constants.COLON + getTokenName() + " had TITLE= but no title: " + value, context);
}
} else {
activeValue = value;
title = getDefaultTitle();
}
}
PrimitiveCollection<Ability> coll = context.getChoiceSet(rm, activeValue);
if (coll == null) {
return ParseResult.INTERNAL_ERROR;
}
if (!coll.getGroupingState().isValid()) {
ComplexParseResult cpr = new ComplexParseResult();
cpr.addErrorMessage("Invalid combination of objects was used in: " + activeValue);
cpr.addErrorMessage(" Check that ALL is not combined");
cpr.addErrorMessage(" Check that a key is not joined with AND (,)");
return cpr;
}
PrimitiveChoiceSet<Ability> pcs = new CollectionToChoiceSet<>(coll);
//Tricky for compatibility...
CategorizedChooseInformation<Ability> tc = new CategorizedChooseInformation<>("ABILITY", CDOMDirectSingleRef.getRef(AbilityCategory.FEAT), pcs, Ability.class);
tc.setTitle(title);
tc.setChoiceActor(this);
context.getObjectContext().put(obj, ObjectKey.CHOOSE_INFO, tc);
return ParseResult.SUCCESS;
}
use of pcgen.cdom.base.CategorizedChooseInformation in project pcgen by PCGen.
the class AbilityToken method parseTokenWithSeparator.
protected ParseResult parseTokenWithSeparator(LoadContext context, ReferenceManufacturer<Ability> rm, CDOMSingleRef<AbilityCategory> acRef, CDOMObject obj, String value) {
int pipeLoc = value.lastIndexOf('|');
String activeValue;
String title;
if (pipeLoc == -1) {
activeValue = value;
title = getDefaultTitle();
} else {
String titleString = value.substring(pipeLoc + 1);
if (titleString.startsWith("TITLE=")) {
title = titleString.substring(6);
if (title.startsWith("\"")) {
title = title.substring(1, title.length() - 1);
}
activeValue = value.substring(0, pipeLoc);
if (title == null || title.isEmpty()) {
return new ParseResult.Fail(getParentToken() + Constants.COLON + getTokenName() + " had TITLE= but no title: " + value, context);
}
} else {
activeValue = value;
title = getDefaultTitle();
}
}
PrimitiveCollection<Ability> coll = context.getChoiceSet(rm, activeValue);
if (coll == null) {
return ParseResult.INTERNAL_ERROR;
}
if (!coll.getGroupingState().isValid()) {
ComplexParseResult cpr = new ComplexParseResult();
cpr.addErrorMessage("Invalid combination of objects was used in: " + activeValue);
cpr.addErrorMessage(" Check that ALL is not combined");
cpr.addErrorMessage(" Check that a key is not joined with AND (,)");
return cpr;
}
PrimitiveChoiceSet<Ability> pcs = new CollectionToChoiceSet<>(coll);
CategorizedChooseInformation<Ability> tc = new CategorizedChooseInformation<>(getTokenName(), acRef, pcs, Ability.class);
tc.setTitle(title);
tc.setChoiceActor(this);
context.getObjectContext().put(obj, ObjectKey.CHOOSE_INFO, tc);
return ParseResult.SUCCESS;
}
Aggregations