use of pcgen.rules.context.AbstractReferenceContext in project pcgen by PCGen.
the class AbstractJunit4CharacterTestCase method setUp.
/**
* Sets up the absolute minimum amount of data to create a PlayerCharacter
* Object.
* @throws Exception
*/
@Before
public void setUp() throws Exception {
TestHelper.loadPlugins();
final GameMode gamemode = new GameMode("3.5");
gamemode.setBonusFeatLevels("3|3");
gamemode.setAlignmentText("Alignment");
final LevelInfo levelInfo = new LevelInfo();
levelInfo.setLevelString("LEVEL");
levelInfo.setMaxClassSkillString("LEVEL+3");
levelInfo.setMaxCrossClassSkillString("(LEVEL+3)/2");
gamemode.addLevelInfo("Normal", levelInfo);
gamemode.addXPTableName("Normal");
gamemode.setDefaultXPTableName("Normal");
LoadInfo loadable = gamemode.getModeContext().getReferenceContext().constructNowIfNecessary(LoadInfo.class, gamemode.getName());
loadable.addLoadScoreValue(0, BigDecimal.ONE);
GameModeFileLoader.addDefaultTabInfo(gamemode);
SystemCollections.addToGameModeList(gamemode);
SettingsHandler.setGame("3.5");
Globals.setUseGUI(false);
Globals.emptyLists();
str = BuildUtilities.createStat("Strength", "STR");
str.put(VariableKey.getConstant("LOADSCORE"), FormulaFactory.getFormulaFor("STRSCORE"));
str.put(VariableKey.getConstant("OFFHANDLIGHTBONUS"), FormulaFactory.getFormulaFor(2));
str.put(FormulaKey.STAT_MOD, FormulaFactory.getFormulaFor("floor(SCORE/2)-5"));
str.put(VariableKey.getConstant("MAXLEVELSTAT=" + str.getKeyName()), FormulaFactory.getFormulaFor(str.getKeyName() + "SCORE-10"));
dex = BuildUtilities.createStat("Dexterity", "DEX");
dex.put(FormulaKey.STAT_MOD, FormulaFactory.getFormulaFor("floor(SCORE/2)-5"));
dex.put(VariableKey.getConstant("MAXLEVELSTAT=" + dex.getKeyName()), FormulaFactory.getFormulaFor(dex.getKeyName() + "SCORE-10"));
PCStat con = BuildUtilities.createStat("Constitution", "CON");
con.put(FormulaKey.STAT_MOD, FormulaFactory.getFormulaFor("floor(SCORE/2)-5"));
con.put(VariableKey.getConstant("MAXLEVELSTAT=" + con.getKeyName()), FormulaFactory.getFormulaFor(con.getKeyName() + "SCORE-10"));
intel = BuildUtilities.createStat("Intelligence", "INT");
intel.put(FormulaKey.STAT_MOD, FormulaFactory.getFormulaFor("floor(SCORE/2)-5"));
intel.put(VariableKey.getConstant("MAXLEVELSTAT=" + intel.getKeyName()), FormulaFactory.getFormulaFor(intel.getKeyName() + "SCORE-10"));
wis = BuildUtilities.createStat("Wisdom", "WIS");
wis.put(FormulaKey.STAT_MOD, FormulaFactory.getFormulaFor("floor(SCORE/2)-5"));
wis.put(VariableKey.getConstant("MAXLEVELSTAT=" + wis.getKeyName()), FormulaFactory.getFormulaFor(wis.getKeyName() + "SCORE-10"));
cha = BuildUtilities.createStat("Charisma", "CHA");
cha.put(FormulaKey.STAT_MOD, FormulaFactory.getFormulaFor("floor(SCORE/2)-5"));
cha.put(VariableKey.getConstant("MAXLEVELSTAT=" + cha.getKeyName()), FormulaFactory.getFormulaFor(cha.getKeyName() + "SCORE-10"));
gamemode.setBonusFeatLevels("3|3");
SettingsHandler.setGame("3.5");
LoadContext context = Globals.getContext();
AbstractReferenceContext ref = context.getReferenceContext();
lg = BuildUtilities.createAlignment("Lawful Good", "LG");
ref.importObject(lg);
ln = BuildUtilities.createAlignment("Lawful Neutral", "LN");
ref.importObject(ln);
le = BuildUtilities.createAlignment("Lawful Evil", "LE");
ref.importObject(le);
ng = BuildUtilities.createAlignment("Neutral Good", "NG");
ref.importObject(ng);
tn = BuildUtilities.createAlignment("True Neutral", "TN");
ref.importObject(tn);
ne = BuildUtilities.createAlignment("Neutral Evil", "NE");
ref.importObject(ne);
cg = BuildUtilities.createAlignment("Chaotic Good", "CG");
ref.importObject(cg);
cn = BuildUtilities.createAlignment("Chaotic Neutral", "CN");
ref.importObject(cn);
ce = BuildUtilities.createAlignment("Chaotic Evil", "CE");
ref.importObject(ce);
ref.importObject(BuildUtilities.createAlignment("None", "NONE"));
ref.importObject(BuildUtilities.createAlignment("Deity's", "Deity"));
GameModeFileLoader.addDefaultWieldCategories(context);
ref.importObject(str);
ref.importObject(dex);
ref.importObject(con);
ref.importObject(intel);
ref.importObject(wis);
ref.importObject(cha);
ref.constructCDOMObject(Language.class, "All Language For Test");
BuildUtilities.createFact(context, "ClassType", PCClass.class);
FactDefinition<?, String> fd = BuildUtilities.createFact(context, "SpellType", PCClass.class);
fd.setSelectable(true);
fine = BuildUtilities.createSize("Fine", 0);
diminutive = BuildUtilities.createSize("Diminutive", 1);
tiny = BuildUtilities.createSize("Tiny", 2);
small = BuildUtilities.createSize("Small", 3);
medium = BuildUtilities.createSize("Medium", 4);
medium.put(ObjectKey.IS_DEFAULT_SIZE, true);
large = BuildUtilities.createSize("Large", 5);
huge = BuildUtilities.createSize("Huge", 6);
gargantuan = BuildUtilities.createSize("Gargantuan", 7);
colossal = BuildUtilities.createSize("Colossal", 8);
SourceFileLoader.createLangBonusObject(context);
GameModeFileLoader.addDefaultUnitSet(SettingsHandler.getGame());
SettingsHandler.getGame().selectDefaultUnitSet();
ref.importObject(AbilityCategory.FEAT);
SourceFileLoader.processFactDefinitions(context);
additionalSetUp();
if (!ref.resolveReferences(null)) {
fail("Unconstructed References");
}
context.resolvePostValidationTokens();
context.resolvePostDeferredTokens();
context.loadCampaignFacets();
character = new PlayerCharacter();
}
use of pcgen.rules.context.AbstractReferenceContext in project pcgen by PCGen.
the class Alignment method createAllAlignments.
public static void createAllAlignments() {
AbstractReferenceContext ref = Globals.getContext().getReferenceContext();
ref.importObject(BuildUtilities.createAlignment("Lawful Good", "LG"));
ref.importObject(BuildUtilities.createAlignment("Lawful Neutral", "LN"));
ref.importObject(BuildUtilities.createAlignment("Lawful Evil", "LE"));
ref.importObject(BuildUtilities.createAlignment("Neutral Good", "NG"));
ref.importObject(BuildUtilities.createAlignment("True Neutral", "TN"));
ref.importObject(BuildUtilities.createAlignment("Neutral Evil", "NE"));
ref.importObject(BuildUtilities.createAlignment("Chaotic Good", "CG"));
ref.importObject(BuildUtilities.createAlignment("Chaotic Neutral", "CN"));
ref.importObject(BuildUtilities.createAlignment("Chaotic Evil", "CE"));
ref.importObject(BuildUtilities.createAlignment("None", "NONE"));
ref.importObject(BuildUtilities.createAlignment("Deity's", "Deity"));
}
use of pcgen.rules.context.AbstractReferenceContext in project pcgen by PCGen.
the class PreBaseSizeTester method passes.
/**
* @see pcgen.core.prereq.PrerequisiteTest#passes(pcgen.core.PlayerCharacter)
*/
@Override
public int passes(final Prerequisite prereq, final CharacterDisplay display, CDOMObject source) throws PrerequisiteException {
int runningTotal = 0;
if ((display.getRace() != null) && !display.getRace().equals(Globals.s_EMPTYRACE)) {
AbstractReferenceContext ref = Globals.getContext().getReferenceContext();
SizeAdjustment sa = ref.silentlyGetConstructedCDOMObject(SizeAdjustment.class, prereq.getOperand());
int targetSize = sa.get(IntegerKey.SIZEORDER);
runningTotal = prereq.getOperator().compare(display.racialSizeInt(), targetSize);
}
return countedTotal(prereq, runningTotal);
}
use of pcgen.rules.context.AbstractReferenceContext in project pcgen by PCGen.
the class EvaluatorFactoryTest method initGameModes.
/**
* Initialise the data and game modes - does the parsing of the data, so
* the plugins must be loaded before this method is called.
*
* @deprecated This is calling Persistence Manager, so it should no longer be used
* CODE-1888
*/
@Deprecated
public static void initGameModes() {
//$NON-NLS-1$
SettingsHandler.setGame(SettingsHandler.getPCGenOption("game", "35e"));
SettingsHandler.game.clearLoadContext();
Globals.createEmptyRace();
AbstractReferenceContext rc = Globals.getContext().getReferenceContext();
PCStat str = rc.constructCDOMObject(PCStat.class, "Strength");
str.setKeyName("STR");
rc.reassociateKey("STR", str);
PCStat intel = rc.constructCDOMObject(PCStat.class, "Intelligence");
intel.setKeyName("INT");
rc.reassociateKey("INT", intel);
PCStat dex = rc.constructCDOMObject(PCStat.class, "Dexterity");
dex.setKeyName("DEX");
rc.reassociateKey("DEX", dex);
PCStat wis = rc.constructCDOMObject(PCStat.class, "Wisdom");
wis.setKeyName("WIS");
rc.reassociateKey("WIS", wis);
PCStat con = rc.constructCDOMObject(PCStat.class, "Constitution");
con.setKeyName("CON");
rc.reassociateKey("CON", con);
PCStat cha = rc.constructCDOMObject(PCStat.class, "Charisma");
cha.setKeyName("CHA");
rc.reassociateKey("CHA", cha);
//$NON-NLS-1$
SettingsHandler.validateBonuses = SettingsHandler.getPCGenOption("validateBonuses", false);
}
use of pcgen.rules.context.AbstractReferenceContext in project pcgen by PCGen.
the class AbstractQualifierTokenTestCase method setUpPC.
protected void setUpPC() throws PersistenceLayerException {
TokenRegistration.register(AUTO_LANG_TOKEN);
TokenRegistration.register(ABILITY_VISIBLE_TOKEN);
TokenRegistration.register(AUTO_TOKEN);
TokenRegistration.register(CHOOSE_TOKEN);
TokenRegistration.register(CHOOSE_LANG_TOKEN);
TokenRegistration.register(ABILITY_MULT_TOKEN);
TokenRegistration.register(EQUIP_TYPE_TOKEN);
TokenRegistration.register(EQUIP_PROFICIENCY_TOKEN);
TokenRegistration.register(LANGBONUS_PRIM);
TokenRegistration.register(PC_QUAL);
Globals.createEmptyRace();
Globals.setUseGUI(false);
Globals.emptyLists();
resetContext();
GameMode gamemode = SettingsHandler.getGame();
str = BuildUtilities.createStat("Strength", "STR");
str.put(VariableKey.getConstant("LOADSCORE"), FormulaFactory.getFormulaFor("STRSCORE"));
str.put(VariableKey.getConstant("OFFHANDLIGHTBONUS"), FormulaFactory.getFormulaFor(2));
dex = BuildUtilities.createStat("Dexterity", "DEX");
PCStat con = BuildUtilities.createStat("Constitution", "CON");
intel = BuildUtilities.createStat("Intelligence", "INT");
wis = BuildUtilities.createStat("Wisdom", "WIS");
cha = BuildUtilities.createStat("Charisma", "CHA");
AbstractReferenceContext ref = Globals.getContext().getReferenceContext();
lg = BuildUtilities.createAlignment("Lawful Good", "LG");
ref.importObject(lg);
ln = BuildUtilities.createAlignment("Lawful Neutral", "LN");
ref.importObject(ln);
le = BuildUtilities.createAlignment("Lawful Evil", "LE");
ref.importObject(le);
ng = BuildUtilities.createAlignment("Neutral Good", "NG");
ref.importObject(ng);
tn = BuildUtilities.createAlignment("True Neutral", "TN");
ref.importObject(tn);
ne = BuildUtilities.createAlignment("Neutral Evil", "NE");
ref.importObject(ne);
cg = BuildUtilities.createAlignment("Chaotic Good", "CG");
ref.importObject(cg);
cn = BuildUtilities.createAlignment("Chaotic Neutral", "CN");
ref.importObject(cn);
ce = BuildUtilities.createAlignment("Chaotic Evil", "CE");
ref.importObject(ce);
ref.importObject(BuildUtilities.createAlignment("None", "NONE"));
ref.importObject(BuildUtilities.createAlignment("Deity's", "Deity"));
gamemode.setBonusFeatLevels("3|3");
SettingsHandler.setGame("3.5");
ref.importObject(str);
ref.importObject(dex);
ref.importObject(con);
ref.importObject(intel);
ref.importObject(wis);
ref.importObject(cha);
fine = BuildUtilities.createSize("Fine", 0);
diminutive = BuildUtilities.createSize("Diminutive", 1);
tiny = BuildUtilities.createSize("Tiny", 2);
small = BuildUtilities.createSize("Small", 3);
medium = BuildUtilities.createSize("Medium", 4);
medium.put(ObjectKey.IS_DEFAULT_SIZE, true);
large = BuildUtilities.createSize("Large", 5);
huge = BuildUtilities.createSize("Huge", 6);
gargantuan = BuildUtilities.createSize("Gargantuan", 7);
colossal = BuildUtilities.createSize("Colossal", 8);
SourceFileLoader.createLangBonusObject(Globals.getContext());
ref.constructNowIfNecessary(Language.class, "DummyLanguage");
}
Aggregations