use of pcgen.core.Description in project pcgen by PCGen.
the class PCRacialHDSizeTermEvaluatorTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
Campaign customCampaign = new Campaign();
customCampaign.setName("Unit Test");
customCampaign.setName("KEY_Unit Test");
customCampaign.addToListFor(ListKey.DESCRIPTION, new Description("Unit Test data"));
CampaignSourceEntry source = new CampaignSourceEntry(customCampaign, new URI("file:/" + getClass().getName() + ".java"));
LoadContext context = Globals.getContext();
PCClassLoader classLoader = new PCClassLoader();
// Create the humanoid monster class
final String humanoidClassLine = "CLASS:Humanoid KEY:KEY_Humanoid HD:8 TYPE:Monster CLASSTYPE:Monster " + "STARTSKILLPTS:2 MODTOSKILLS:YES";
humanoidClass = classLoader.parseLine(context, null, humanoidClassLine, source);
context.getReferenceContext().importObject(humanoidClass);
// Create the pc class
final String pcClassLine = "CLASS:TestPCClass TYPE:PC HD:10";
pcClass = classLoader.parseLine(context, null, pcClassLine, source);
context.getReferenceContext().importObject(pcClass);
CDOMDirectSingleRef<SizeAdjustment> mediumRef = CDOMDirectSingleRef.getRef(medium);
// Create the BugBear race
bugbearRace.setName("Bugbear");
bugbearRace.put(StringKey.KEY_NAME, "KEY_Bugbear");
bugbearRace.put(FormulaKey.SIZE, new FixedSizeFormula(mediumRef));
bugbearRace.addToListFor(ListKey.HITDICE_ADVANCEMENT, Integer.MAX_VALUE);
bugbearRace.put(ObjectKey.MONSTER_CLASS, new LevelCommandFactory(CDOMDirectSingleRef.getRef(humanoidClass), FormulaFactory.getFormulaFor(3)));
context.getReferenceContext().importObject(bugbearRace);
// Create the human race
humanRace.setName("Human");
humanRace.put(StringKey.KEY_NAME, "KEY_Human");
humanRace.put(FormulaKey.SIZE, new FixedSizeFormula(mediumRef));
context.getReferenceContext().importObject(humanRace);
}
use of pcgen.core.Description in project pcgen by PCGen.
the class ClassLevelCommandTest method setUp.
/**
* @throws Exception
* @see pcgen.AbstractCharacterTestCase#setUp()
*/
@Override
protected void setUp() throws Exception {
super.setUp();
Campaign customCampaign = new Campaign();
customCampaign.setName("Unit Test");
customCampaign.setName("KEY_Unit Test");
customCampaign.addToListFor(ListKey.DESCRIPTION, new Description("Unit Test data"));
// Create the monseter class type
GameMode gamemode = SettingsHandler.getGame();
gamemode.addClassType("Monster CRFORMULA:0 ISMONSTER:YES XPPENALTY:NO");
gamemode.setSkillMultiplierLevels("4");
gamemode.setMaxNonEpicLevel(20);
CDOMDirectSingleRef<SizeAdjustment> mediumRef = CDOMDirectSingleRef.getRef(medium);
// Create the Nymph race
nymphRace = new Race();
nymphRace.setName("Nymph");
nymphRace.addToListFor(ListKey.HITDICE_ADVANCEMENT, Integer.MAX_VALUE);
nymphRace.put(FormulaKey.SIZE, new FixedSizeFormula(mediumRef));
Globals.getContext().getReferenceContext().importObject(nymphRace);
// Create the humanoid class
humanoidClass = new PCClass();
humanoidClass.setName("Humanoid");
humanoidClass.addToListFor(ListKey.TYPE, Type.getConstant("Monster"));
Globals.getContext().getReferenceContext().importObject(humanoidClass);
nymphClass = new PCClass();
nymphClass.setName("Nymph");
nymphClass.addToListFor(ListKey.TYPE, Type.getConstant("Monster"));
Globals.getContext().getReferenceContext().importObject(nymphClass);
megaCasterClass = new PCClass();
megaCasterClass.setName("MegaCaster");
BuildUtilities.setFact(megaCasterClass, "SpellType", "Arcane");
Globals.getContext().unconditionallyProcess(megaCasterClass, "SPELLSTAT", "CHA");
megaCasterClass.put(ObjectKey.SPELLBOOK, false);
megaCasterClass.put(ObjectKey.MEMORIZE_SPELLS, false);
Globals.getContext().getReferenceContext().importObject(megaCasterClass);
}
use of pcgen.core.Description in project pcgen by PCGen.
the class DescLst method unparse.
@Override
public String[] unparse(LoadContext context, CDOMObject obj) {
PatternChanges<Description> changes = context.getObjectContext().getListPatternChanges(obj, ListKey.DESCRIPTION);
if (changes == null || changes.isEmpty()) {
return null;
}
List<String> list = new ArrayList<>();
Collection<String> removedItems = changes.getRemoved();
if (changes.includesGlobalClear()) {
if (removedItems != null && !removedItems.isEmpty()) {
context.addWriteMessage("Non-sensical relationship in " + getTokenName() + ": global .CLEAR and local .CLEAR. performed");
return null;
}
list.add(Constants.LST_DOT_CLEAR);
}
if (removedItems != null && !removedItems.isEmpty()) {
for (String d : removedItems) {
list.add(Constants.LST_DOT_CLEAR_DOT + d);
}
}
Collection<Description> addedItems = changes.getAdded();
if (addedItems != null) {
for (Description d : addedItems) {
list.add(d.getPCCText());
}
}
if (list.isEmpty()) {
return null;
}
return list.toArray(new String[list.size()]);
}
use of pcgen.core.Description in project pcgen by PCGen.
the class DescLst method parseTokenWithSeparator.
@Override
protected ParseResult parseTokenWithSeparator(LoadContext context, CDOMObject obj, String aDesc) {
if (Constants.LST_DOT_CLEAR.equals(aDesc)) {
context.getObjectContext().removeList(obj, ListKey.DESCRIPTION);
return ParseResult.SUCCESS;
}
if (aDesc.startsWith(Constants.LST_DOT_CLEAR_DOT)) {
context.getObjectContext().removePatternFromList(obj, ListKey.DESCRIPTION, aDesc.substring(7));
return ParseResult.SUCCESS;
}
StringTokenizer tok = new StringTokenizer(aDesc, Constants.PIPE);
String descString = tok.nextToken();
if (looksLikeAPrerequisite(descString)) {
return new ParseResult.Fail(getTokenName() + " encountered only a PRExxx: " + aDesc, context);
}
String ds = EntityEncoder.decode(descString);
if (!StringUtil.hasBalancedParens(ds)) {
return new ParseResult.Fail(getTokenName() + " encountered imbalanced Parenthesis: " + aDesc, context);
}
ParseResult pr = checkForInvalidXMLChars(ds);
if (!pr.passed()) {
return pr;
}
Description desc = new Description(ds);
if (tok.hasMoreTokens()) {
String token = tok.nextToken();
while (true) {
if (Constants.LST_DOT_CLEAR.equals(token)) {
return new ParseResult.Fail(getTokenName() + " tag confused by '.CLEAR' as a " + "middle token: " + aDesc, context);
} else if (looksLikeAPrerequisite(token)) {
break;
} else {
desc.addVariable(token);
}
if (!tok.hasMoreTokens()) {
// No prereqs, so we're done
context.getObjectContext().addToList(obj, ListKey.DESCRIPTION, desc);
return ParseResult.SUCCESS;
}
token = tok.nextToken();
}
while (true) {
Prerequisite prereq = getPrerequisite(token);
if (prereq == null) {
return new ParseResult.Fail(" (Did you put Abilities after the " + "PRExxx tags in " + getTokenName() + ":?)", context);
}
desc.addPrerequisite(prereq);
if (!tok.hasMoreTokens()) {
break;
}
token = tok.nextToken();
}
}
context.getObjectContext().addToList(obj, ListKey.DESCRIPTION, desc);
return ParseResult.SUCCESS;
}
use of pcgen.core.Description in project pcgen by PCGen.
the class Gui2InfoFactoryTest method testGetHTMLInfoTempBonus.
/**
* Verify getHTMLInfo for a temporary bonus.
*/
public void testGetHTMLInfoTempBonus() {
PlayerCharacter pc = getCharacter();
Gui2InfoFactory infoFactory = new Gui2InfoFactory(pc);
Ability tbAbility = TestHelper.makeAbility("Combat expertise", AbilityCategory.FEAT, "General");
tbAbility.put(ObjectKey.MULTIPLE_ALLOWED, Boolean.FALSE);
final Description desc = new Description("CE Desc");
tbAbility.addToListFor(ListKey.DESCRIPTION, desc);
Globals.getContext().commit();
addAbility(AbilityCategory.FEAT, tbAbility);
TempBonusFacadeImpl tbf = new TempBonusFacadeImpl(tbAbility);
assertEquals("Unexpected temp bonus result", "<html><b><font size=+1>Combat expertise</font></b> (Ability)<br>" + "<b>Desc:</b> CE Desc<br><b>Source:</b> </html>", infoFactory.getHTMLInfo(tbf));
}
Aggregations