use of pcgen.core.SizeAdjustment in project pcgen by PCGen.
the class PreSizeParser method parse.
/**
* Parse the pre req list
*
* @param kind The kind of the prerequisite (less the "PRE" prefix)
* @param formula The body of the prerequisite.
* @param invertResult Whether the prerequisite should invert the result.
* @param overrideQualify
* if set true, this prerequisite will be enforced in spite
* of any "QUALIFY" tag that may be present.
* @return PreReq
* @throws PersistenceLayerException
*/
@Override
public Prerequisite parse(String kind, String formula, boolean invertResult, boolean overrideQualify) throws PersistenceLayerException {
Prerequisite prereq = super.parse(kind, formula, invertResult, overrideQualify);
try {
prereq.setKind("size");
// Get the comparator type SIZEGTEQ, BSIZE, SIZENEQ etc.
String compType = kind.substring(4);
if (compType.isEmpty()) {
compType = "gteq";
}
prereq.setOperator(compType);
String abb = formula.substring(0, 1);
LoadContext context = Globals.getContext();
CDOMSingleRef<SizeAdjustment> ref = context.getReferenceContext().getCDOMReference(SizeAdjustment.class, abb);
context.forgetMeNot(ref);
prereq.setOperand(formula);
if (invertResult) {
prereq.setOperator(prereq.getOperator().invert());
}
} catch (PrerequisiteException pe) {
throw new PersistenceLayerException("Unable to parse the prerequisite :'" + kind + ':' + formula + "'. " + pe.getLocalizedMessage());
}
return prereq;
}
use of pcgen.core.SizeAdjustment in project pcgen by PCGen.
the class SizeToken method parseNonEmptyToken.
@Override
public ParseResult parseNonEmptyToken(LoadContext context, Race race, String value) {
CDOMSingleRef<SizeAdjustment> size = context.getReferenceContext().getCDOMReference(SizeAdjustment.class, value);
Formula sizeFormula = new FixedSizeFormula(size);
context.getObjectContext().put(race, FormulaKey.SIZE, sizeFormula);
return ParseResult.SUCCESS;
}
use of pcgen.core.SizeAdjustment 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.SizeAdjustment in project pcgen by PCGen.
the class BuildUtilities method createSize.
public static SizeAdjustment createSize(String name, int order) {
final String abb = name.substring(0, 1);
final SizeAdjustment sa = new SizeAdjustment();
sa.setName(name);
sa.setKeyName(abb);
sa.put(IntegerKey.SIZEORDER, order);
Globals.getContext().getReferenceContext().importObject(sa);
return sa;
}
use of pcgen.core.SizeAdjustment in project pcgen by PCGen.
the class BaseSizeTokenTest method setUp.
@Override
public void setUp() throws PersistenceLayerException, URISyntaxException {
super.setUp();
TokenRegistration.register(BASESIZE_TOKEN);
SizeAdjustment ps = BuildUtilities.createSize("Small", 0);
primaryContext.getReferenceContext().importObject(ps);
SizeAdjustment ss = BuildUtilities.createSize("Small", 0);
secondaryContext.getReferenceContext().importObject(ss);
}
Aggregations