use of pcgen.core.GameMode in project pcgen by PCGen.
the class ACTokenTest method setUp.
/*
* @see TestCase#setUp()
*/
@Override
protected void setUp() throws Exception {
super.setUp();
LoadContext context = Globals.getContext();
PlayerCharacter character = getCharacter();
setPCStat(character, dex, 14);
dex.removeListFor(ListKey.BONUS);
BonusObj aBonus = Bonus.newBonus(context, "COMBAT|AC|10|TYPE=Base");
if (aBonus != null) {
dex.addToListFor(ListKey.BONUS, aBonus);
}
// Ignoring max dex
aBonus = Bonus.newBonus(context, "COMBAT|AC|DEX|TYPE=Ability");
if (aBonus != null) {
dex.addToListFor(ListKey.BONUS, aBonus);
}
EquipSet def = new EquipSet("0.1", "Default");
character.addEquipSet(def);
character.setCalcEquipmentList();
character.calcActiveBonuses();
// Create non magic armor
chainShirt = new Equipment();
chainShirt.setName("Chain Shirt");
chainShirt.put(StringKey.KEY_NAME, "KEY_Chain_Shirt");
TestHelper.addType(chainShirt, "Armor.Light.Suit.Standard");
chainShirt.put(IntegerKey.AC_CHECK, -2);
aBonus = Bonus.newBonus(context, "COMBAT|AC|4|TYPE=Armor.REPLACE");
if (aBonus != null) {
chainShirt.addToListFor(ListKey.BONUS, aBonus);
}
// Create magic armor enhancement
masterwork = new EquipmentModifier();
masterwork.setName("Masterwork");
masterwork.put(StringKey.KEY_NAME, "MWORKA");
TestHelper.addType(masterwork, "Armor.Shield");
masterwork.addToListFor(ListKey.ITEM_TYPES, "Masterwork");
aBonus = Bonus.newBonus(context, "EQMARMOR|ACCHECK|1|TYPE=Enhancement");
if (aBonus != null) {
masterwork.addToListFor(ListKey.BONUS, aBonus);
}
context.getReferenceContext().importObject(masterwork);
plus1 = new EquipmentModifier();
plus1.setName("Plus 1 Enhancement");
plus1.put(StringKey.KEY_NAME, "PLUS1A");
TestHelper.addType(plus1, "Armor.Shield");
plus1.put(IntegerKey.PLUS, 1);
plus1.addToListFor(ListKey.ITEM_TYPES, "Enhancement");
plus1.addToListFor(ListKey.ITEM_TYPES, "Magic");
plus1.addToListFor(ListKey.ITEM_TYPES, "Plus1");
aBonus = Bonus.newBonus(context, "COMBAT|AC|1|TYPE=Armor.REPLACE");
if (aBonus != null) {
plus1.addToListFor(ListKey.BONUS, aBonus);
}
Globals.getContext().getReferenceContext().importObject(plus1);
// Load AC definitions - but only once
final GameMode gamemode = SettingsHandler.getGame();
if (!gamemode.isValidACType("Total")) {
gamemode.addACAdds("Total", Collections.singletonList(new ACControl("TOTAL")));
gamemode.addACAdds("Armor", Collections.singletonList(new ACControl("Armor")));
gamemode.addACAdds("Ability", Collections.singletonList(new ACControl("Ability")));
}
}
use of pcgen.core.GameMode 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.GameMode 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");
}
use of pcgen.core.GameMode in project pcgen by PCGen.
the class AbstractQualifierTokenTestCase method getPrimaryContext.
@Override
protected LoadContext getPrimaryContext() {
GameMode game = SettingsHandler.getGame();
game.clearLoadContext();
return game.getContext();
}
use of pcgen.core.GameMode in project pcgen by PCGen.
the class PreAlignParser 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);
String[] alignments = formula.split(",");
final GameMode gm = SettingsHandler.getGame();
if (gm == null) {
prereq.setKey("");
prereq.setOperator(PrerequisiteOperator.EQ);
return prereq;
}
if (Globals.getContext().getReferenceContext().getConstructedObjectCount(PCAlignment.class) == 0) {
// There are no alignments for this game mode, so we
// do not do prereqs.
prereq.setKey("");
prereq.setOperator(PrerequisiteOperator.EQ);
} else {
if (alignments.length == 1) {
prereq.setKey(formula);
prereq.setOperator(PrerequisiteOperator.EQ);
} else {
prereq.setKind(null);
prereq.setOperator(PrerequisiteOperator.GTEQ);
prereq.setOperand("1");
for (String alignment : alignments) {
Prerequisite subreq = new Prerequisite();
subreq.setKind("align");
subreq.setKey(alignment);
subreq.setOperator(PrerequisiteOperator.EQ);
prereq.addPrerequisite(subreq);
}
}
}
if (invertResult) {
prereq.setOperator(prereq.getOperator().invert());
}
return prereq;
}
Aggregations