use of pcgen.rules.context.AbstractReferenceContext in project pcgen by PCGen.
the class SizeFacetTest method staticSetUp.
private static synchronized void staticSetUp() {
if (!staticDone) {
SettingsHandler.getGame().clearLoadContext();
AbstractReferenceContext ref = Globals.getContext().getReferenceContext();
t = BuildUtilities.createSize("Tiny", 0);
ref.importObject(t);
s = BuildUtilities.createSize("Small", 1);
ref.importObject(s);
m = BuildUtilities.createSize("Medium", 2);
m.put(ObjectKey.IS_DEFAULT_SIZE, true);
ref.importObject(m);
l = BuildUtilities.createSize("Large", 3);
ref.importObject(l);
h = BuildUtilities.createSize("Huge", 4);
ref.importObject(h);
staticDone = true;
}
}
use of pcgen.rules.context.AbstractReferenceContext in project pcgen by PCGen.
the class CDOMControlLoader method subParse.
private <CC extends Loadable> boolean subParse(LoadContext context, CDOMSubLineLoader<CC> loader, String line) throws PersistenceLayerException {
int tabLoc = line.indexOf(SystemLoader.TAB_DELIM);
String lineIdentifier;
if (tabLoc == -1) {
lineIdentifier = line;
} else {
lineIdentifier = line.substring(0, tabLoc);
}
int colonLoc = lineIdentifier.indexOf(':');
if (colonLoc == -1) {
Logging.errorPrint("First token on line had no colon: " + line, context);
return false;
}
String name = lineIdentifier.substring(colonLoc + 1);
if ((name == null) || name.isEmpty()) {
Logging.errorPrint("First token on line had no content: " + line, context);
return false;
}
AbstractReferenceContext refContext = context.getReferenceContext();
CC obj = refContext.constructNowIfNecessary(loader.getLoadedClass(), name.replace('|', ' ').replace(',', ' '));
return loader.parseLine(context, obj, line);
}
use of pcgen.rules.context.AbstractReferenceContext in project pcgen by PCGen.
the class AbstractCharacterUsingTestCase 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();
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);
universal = ref.constructCDOMObject(Language.class, "Universal");
other = ref.constructCDOMObject(Language.class, "Other");
SourceFileLoader.createLangBonusObject(Globals.getContext());
}
use of pcgen.rules.context.AbstractReferenceContext in project pcgen by PCGen.
the class WieldCategory method adjustForSize.
/**
* Get the WieldCategory adjusted for the size difference between the weapon
* and the PC. This uses the 3.5 equipment sizes.
*
* @param pc
* Player character to get the weild category for.
* @param eq
* Equipment to get the weild category for.
* @return The ajusted WieldCategory
*/
public WieldCategory adjustForSize(final PlayerCharacter pc, final Equipment eq) {
if (pc == null || eq == null || eq.get(ObjectKey.WIELD) == null) {
return this;
}
// Check if we have a bonus that changes the weapons effective size
// for wield purposes.
SizeAdjustment oldEqSa = eq.getSizeAdjustment();
if (pc.sizeInt() != eq.sizeInt()) {
int aBump = 0;
aBump += (int) pc.getTotalBonusTo("WIELDCATEGORY", eq.getWieldName());
aBump += (int) pc.getTotalBonusTo("WIELDCATEGORY", "ALL");
// loops for each equipment type
int modWield = 0;
for (String eqType : eq.typeList()) {
final StringBuilder sB = new StringBuilder("WEAPONPROF=TYPE.");
sB.append(eqType);
// get the type bonus (ex TYPE.MARTIAL)
final int i = (int) pc.getTotalBonusTo(sB.toString(), "WIELDCATEGORY");
// get the highest bonus
if (i < modWield) {
modWield = i;
}
}
aBump += modWield;
if (aBump != 0) {
final int newSizeInt = eq.sizeInt() + aBump;
AbstractReferenceContext ref = Globals.getContext().getReferenceContext();
SizeAdjustment sadj = ref.getSortedList(SizeAdjustment.class, IntegerKey.SIZEORDER).get(newSizeInt);
eq.put(ObjectKey.SIZE, CDOMDirectSingleRef.getRef(sadj));
}
}
WieldCategory pcWCat = getSwitch(pc, eq);
eq.put(ObjectKey.SIZE, CDOMDirectSingleRef.getRef(oldEqSa));
return pcWCat;
}
use of pcgen.rules.context.AbstractReferenceContext in project pcgen by PCGen.
the class LockedStat method getDescription.
@Override
public String getDescription() {
AbstractReferenceContext rc = Globals.getContext().getReferenceContext();
final PCStat pcstat = rc.silentlyGetConstructedCDOMObject(PCStat.class, getBonusInfo());
if (pcstat != null) {
return pcstat.getName() + " (locked)";
}
return super.getDescription();
}
Aggregations