use of pcgen.rules.context.LoadContext in project pcgen by PCGen.
the class PreWeaponProfTest method testWithFeatThatGrantsBonus.
/**
* Test Preweaponprof with a feat that has a bonus tag
* This test was written to help find the source of bug 1699779
* @throws Exception
*/
public void testWithFeatThatGrantsBonus() throws Exception {
final PlayerCharacter character = getCharacter();
PCTemplate pctls = new PCTemplate();
LoadContext context = Globals.getContext();
context.unconditionallyProcess(pctls, "AUTO", "WEAPONPROF|Longsword");
assertTrue(context.getReferenceContext().resolveReferences(null));
final FeatLoader featLoader = new FeatLoader();
CampaignSourceEntry cse;
try {
cse = new CampaignSourceEntry(new Campaign(), new URI("file:/" + getClass().getName() + ".java"));
} catch (URISyntaxException e) {
throw new UnreachableError(e);
}
int baseHp = character.hitPoints();
Ability bar = new Ability();
final String barStr = "Bar TYPE:General DESC:See Text BONUS:HP|CURRENTMAX|50";
featLoader.parseLine(Globals.getContext(), bar, barStr, cse);
addAbility(AbilityCategory.FEAT, bar);
assertEquals("Character should have 50 bonus hp added.", baseHp + 50, character.hitPoints());
character.addTemplate(pctls);
Ability foo = new Ability();
final String fooStr = "Foo TYPE:General DESC:See Text BONUS:HP|CURRENTMAX|50|PREWEAPONPROF:1,Longsword";
featLoader.parseLine(Globals.getContext(), foo, fooStr, cse);
addAbility(AbilityCategory.FEAT, foo);
assertEquals("Character has the longsword proficiency so the bonus should be added", baseHp + 50 + 50, character.hitPoints());
}
use of pcgen.rules.context.LoadContext in project pcgen by PCGen.
the class PreVarTest method test2857848a.
public void test2857848a() {
LoadContext context = Globals.getContext();
final PCClass spellcaster = new PCClass();
spellcaster.setName("Spellcaster");
context.getReferenceContext().importObject(spellcaster);
Skill concentration = context.getReferenceContext().constructCDOMObject(Skill.class, "Concentration");
context.unconditionallyProcess(spellcaster, "SPELLTYPE", "Arcane");
context.unconditionallyProcess(spellcaster, "SPELLSTAT", "INT");
context.unconditionallyProcess(spellcaster, "CSKILL", "Concentration");
context.unconditionallyProcess(spellcaster, "BONUS", "SKILL|Concentration|5|PREVARGT:BASESPELLSTAT,2");
assertTrue(context.getReferenceContext().resolveReferences(null));
PlayerCharacter character = this.getCharacter();
setPCStat(character, intel, 16);
PCClassLoader loader = new PCClassLoader();
try {
SourceEntry se = new CampaignSourceEntry(new Campaign(), new URI("file://test"));
loader.completeObject(context, se, spellcaster);
assertEquals(0, SkillModifier.modifier(concentration, character).intValue());
character.incrementClassLevel(1, spellcaster);
assertEquals(5, SkillModifier.modifier(concentration, character).intValue());
} catch (URISyntaxException | PersistenceLayerException e) {
fail(e.getMessage());
}
}
use of pcgen.rules.context.LoadContext in project pcgen by PCGen.
the class PreSpellTypeTest method additionalSetUp.
/*
* (non-Javadoc)
*
* @see junit.framework.TestCase#setUp()
*/
@Override
protected void additionalSetUp() throws Exception {
LoadContext context = Globals.getContext();
wiz = context.getReferenceContext().constructCDOMObject(PCClass.class, "Wizard");
BuildUtilities.setFact(wiz, "SpellType", "Arcane");
context.unconditionallyProcess(wiz, "KNOWNSPELLS", "LEVEL=1|LEVEL=2");
context.unconditionallyProcess(wiz.getOriginalClassLevel(1), "CAST", "1,1");
context.unconditionallyProcess(wiz.getOriginalClassLevel(2), "CAST", "2,2,2");
cle = context.getReferenceContext().constructCDOMObject(PCClass.class, "Cleric");
BuildUtilities.setFact(cle, "SpellType", "Divine");
context.unconditionallyProcess(cle, "KNOWNSPELLS", "LEVEL=1|LEVEL=2");
context.unconditionallyProcess(cle.getOriginalClassLevel(1), "CAST", "1,1");
context.unconditionallyProcess(cle.getOriginalClassLevel(2), "CAST", "1,1,1");
Arcaneball = new Spell();
Arcaneball.setName("Arcaneball");
context.getReferenceContext().importObject(Arcaneball);
context.unconditionallyProcess(Arcaneball, "CLASSES", "Wizard=2");
context.unconditionallyProcess(Arcaneball, "TYPE", "Arcane");
lightning = new Spell();
lightning.setName("Lightning Bolt");
context.getReferenceContext().importObject(lightning);
context.unconditionallyProcess(lightning, "CLASSES", "Wizard=2");
context.unconditionallyProcess(lightning, "TYPE", "Arcane");
burning = new Spell();
burning.setName("Burning Hands");
context.getReferenceContext().importObject(burning);
context.unconditionallyProcess(burning, "CLASSES", "Wizard=1");
context.unconditionallyProcess(burning, "TYPE", "Arcane");
heal = new Spell();
heal.setName("Heal");
context.getReferenceContext().importObject(heal);
context.unconditionallyProcess(heal, "CLASSES", "Cleric=2");
context.unconditionallyProcess(heal, "TYPE", "Divine");
cure = new Spell();
cure.setName("Cure Light Wounds");
context.getReferenceContext().importObject(cure);
context.unconditionallyProcess(cure, "CLASSES", "Cleric=1");
context.unconditionallyProcess(cure, "TYPE", "Divine");
}
use of pcgen.rules.context.LoadContext in project pcgen by PCGen.
the class CharacterLevelsFacadeImplTest method additionalSetUp.
@Override
protected void additionalSetUp() throws Exception {
spellcraftSkill = TestHelper.makeSkill("Spellcraft", "Base", intel, false, SkillArmorCheck.NONE);
climbSkill = TestHelper.makeSkill("Climb", "Base", str, false, SkillArmorCheck.YES);
umdSkill = TestHelper.makeSkill("Use Magic Device", "Base", str, false, SkillArmorCheck.NONE);
umdSkill.put(ObjectKey.EXCLUSIVE, true);
LoadContext context = Globals.getContext();
CampaignSourceEntry source = new CampaignSourceEntry(new Campaign(), new URI("file:/" + getClass().getName() + ".java"));
fighterClass = TestHelper.makeClass("Fighter");
String classPCCText = "CLASS:Fighter HD:10 TYPE:Base.PC ABB:Ftr\n" + "CLASS:Fighter STARTSKILLPTS:2 CSKILL:KEY_Climb|KEY_Use Magic Device";
fighterClass = TestHelper.parsePCClassText(classPCCText, source);
context.getReferenceContext().importObject(fighterClass);
classPCCText = "CLASS:Wizard HD:4 TYPE:Base.PC ABB:Wiz\n" + "CLASS:Wizard STARTSKILLPTS:4 CSKILL:KEY_Spellcraft";
wizardClass = TestHelper.parsePCClassText(classPCCText, source);
context.getReferenceContext().importObject(wizardClass);
context.commit();
context.getReferenceContext().buildDerivedObjects();
context.resolveDeferredTokens();
}
use of pcgen.rules.context.LoadContext 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);
}
Aggregations