use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.
the class GlobalModifierToken method unparse.
@Override
public String[] unparse(LoadContext context, Campaign campaign) {
Changes<CampaignSourceEntry> cseChanges = context.getObjectContext().getListChanges(campaign, ListKey.FILE_GLOBALMOD);
Collection<CampaignSourceEntry> added = cseChanges.getAdded();
if (added == null) {
//empty indicates no token
return null;
}
Set<String> set = new TreeSet<>();
for (CampaignSourceEntry cse : added) {
set.add(cse.getLSTformat());
}
return set.toArray(new String[set.size()]);
}
use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.
the class LicenseToken method parseNonEmptyToken.
@Override
protected ParseResult parseNonEmptyToken(LoadContext context, Campaign campaign, String value) {
if (value.startsWith("FILE=")) {
String fileURI = value.substring(5);
if (fileURI.isEmpty()) {
return new ParseResult.Fail("Cannot have empty FILE in " + getTokenName(), context);
}
CampaignSourceEntry cse = context.getCampaignSourceEntry(campaign, fileURI);
if (cse == null) {
return ParseResult.INTERNAL_ERROR;
}
context.getObjectContext().addToList(campaign, ListKey.LICENSE_FILE, cse);
} else {
context.getObjectContext().addToList(campaign, ListKey.LICENSE, value);
}
return ParseResult.SUCCESS;
}
use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.
the class TestHelper method makeEquipment.
/**
* Make some equipment
* @param input Equipment source line to be parsed
* @return true if OK
*/
public static boolean makeEquipment(final String input) {
loadPlugins();
try {
final CampaignSourceEntry source = createSource(TestHelper.class);
eqLoader.parseLine(Globals.getContext(), null, input, source);
return true;
} catch (Exception e) {
// TODO Deal with Exception?
}
return false;
}
use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.
the class CampaignFeatToken method parseTokenWithSeparator.
@Override
protected ParseResult parseTokenWithSeparator(LoadContext context, Campaign campaign, String value) {
Logging.deprecationPrint("FEAT has been deprecated, use ABILITY: " + "and put CATEGORY: entries in the LST file");
CampaignSourceEntry cse = context.getCampaignSourceEntry(campaign, value);
if (cse == null) {
//Error
return ParseResult.INTERNAL_ERROR;
}
context.getObjectContext().addToList(campaign, ListKey.FILE_FEAT, cse);
return ParseResult.SUCCESS;
}
use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.
the class AddClassSkillsTest method testGetChoicesListWithClassSkill.
/**
* Test method for 'pcgen.core.levelability.LevelAbilityClassSkills.getChoicesList(String, PlayerCharacter)'
*/
@Test
public void testGetChoicesListWithClassSkill() {
CampaignSourceEntry source;
try {
source = new CampaignSourceEntry(new Campaign(), new URI("file:/" + getClass().getName() + ".java"));
} catch (URISyntaxException e) {
throw new UnreachableError(e);
}
String classPCCText = "CLASS:Cleric HD:8 TYPE:Base.PC ABB:Clr\n" + "CLASS:Cleric STARTSKILLPTS:2 CSKILL:KEY_Knowledge (Dungeoneering)";
PCClass po;
try {
po = parsePCClassText(classPCCText, source);
} catch (PersistenceLayerException e) {
throw new UnreachableError(e);
}
getCharacter().incrementClassLevel(1, po, false);
PCTemplate pct = new PCTemplate();
Skill bluff = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Skill.class, "KEY_Bluff");
pct.addToListFor(ListKey.CSKILL, CDOMDirectSingleRef.getRef(bluff));
getCharacter().addTemplate(pct);
Globals.getContext().unconditionallyProcess(po, "ADD", "CLASSSKILLS|2|KEY_Bluff,KEY_Listen,KEY_Knowledge (Arcana)");
assertTrue(Globals.getContext().getReferenceContext().resolveReferences(null));
List<PersistentTransitionChoice<?>> choiceList = po.getListFor(ListKey.ADD);
assertEquals(1, choiceList.size());
TransitionChoice<?> choice = choiceList.get(0);
Collection<?> choiceSet = choice.getChoices().getSet(getCharacter());
assertEquals(3, choiceSet.size());
Set<Object> limitedSet = new HashSet<>();
ClassSkillChoiceActor csca = new ClassSkillChoiceActor(po, 0);
for (Object sc : choiceSet) {
if (csca.allow((Skill) sc, getCharacter(), true)) {
limitedSet.add(sc);
}
}
assertEquals(2, limitedSet.size());
assertEquals(2, choice.getCount().resolve(getCharacter(), ""));
List<String> choiceStrings = new ArrayList<>();
for (Object o : limitedSet) {
choiceStrings.add(o.toString());
}
assertTrue(choiceStrings.contains("Listen"));
assertTrue(choiceStrings.contains("Knowledge (Arcana)"));
}
Aggregations