use of pcgen.core.SizeAdjustment in project pcgen by PCGen.
the class TestHelper method makeSizeAdjustments.
/**
* Make some size adjustments
*/
public static void makeSizeAdjustments() {
final String sizes = "Fine|Diminutive|Tiny|Small|Medium|Large|Huge|Gargantuan|Colossal";
final StringTokenizer aTok = new StringTokenizer(sizes, "|");
GameMode gamemode = SystemCollections.getGameModeNamed("3.5");
if (gamemode == null) {
gamemode = new GameMode("3.5");
SystemCollections.addToGameModeList(gamemode);
GameModeFileLoader.addDefaultTabInfo(gamemode);
}
SettingsHandler.setGame("3.5");
int count = 0;
while (aTok.hasMoreTokens()) {
SizeAdjustment sa = BuildUtilities.createSize(aTok.nextToken(), count++);
Globals.getContext().getReferenceContext().importObject(sa);
}
Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(SizeAdjustment.class, "M").put(ObjectKey.IS_DEFAULT_SIZE, true);
}
use of pcgen.core.SizeAdjustment in project pcgen by PCGen.
the class PreBaseSizeParser 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("basesize");
// Get the comparator type BASESIZEGTEQ, BASESIZE, BASESIZENEQ etc.
String compType = kind.substring(8);
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(abb);
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 PCTLTermEvaluatorTest 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"));
// Create the humanoid class
String classDef = "CLASS:Humanoid KEY:KEY_Humanoid HD:8 CLASSTYPE:Monster STARTSKILLPTS:1 " + "MODTOSKILLS:NO MONSKILL:6+INT MONNONSKILLHD:1|PRESIZELTEQ:M " + "MONNONSKILLHD:2|PRESIZEEQ:L";
PCClassLoader classLoader = new PCClassLoader();
LoadContext context = Globals.getContext();
humanoidClass = classLoader.parseLine(context, null, classDef, source);
Globals.getContext().getReferenceContext().importObject(humanoidClass);
// Create the BugBear race
bugbearRace = new Race();
bugbearRace.setName("Bugbear");
bugbearRace.put(StringKey.KEY_NAME, "KEY_Bugbear");
CDOMDirectSingleRef<SizeAdjustment> mediumRef = CDOMDirectSingleRef.getRef(medium);
bugbearRace.put(FormulaKey.SIZE, new FixedSizeFormula(mediumRef));
bugbearRace.addToListFor(ListKey.HITDICE_ADVANCEMENT, Integer.MAX_VALUE);
bugbearRace.put(IntegerKey.INITIAL_SKILL_MULT, 1);
Globals.getContext().getReferenceContext().importObject(bugbearRace);
}
use of pcgen.core.SizeAdjustment 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.SizeAdjustment in project pcgen by PCGen.
the class SizeTokenTest method setUp.
@Override
@Before
public void setUp() throws PersistenceLayerException, URISyntaxException {
super.setUp();
SizeAdjustment ps = BuildUtilities.createSize("Small", 0);
primaryContext.getReferenceContext().importObject(ps);
SizeAdjustment pm = BuildUtilities.createSize("Medium", 1);
primaryContext.getReferenceContext().importObject(pm);
SizeAdjustment ss = BuildUtilities.createSize("Small", 0);
secondaryContext.getReferenceContext().importObject(ss);
SizeAdjustment sm = BuildUtilities.createSize("Medium", 1);
secondaryContext.getReferenceContext().importObject(sm);
}
Aggregations