Search in sources :

Example 61 with LoadContext

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());
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) Ability(pcgen.core.Ability) PlayerCharacter(pcgen.core.PlayerCharacter) Campaign(pcgen.core.Campaign) FeatLoader(pcgen.persistence.lst.FeatLoader) LoadContext(pcgen.rules.context.LoadContext) URISyntaxException(java.net.URISyntaxException) UnreachableError(pcgen.base.lang.UnreachableError) PCTemplate(pcgen.core.PCTemplate) URI(java.net.URI)

Example 62 with LoadContext

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());
    }
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) PersistenceLayerException(pcgen.persistence.PersistenceLayerException) Skill(pcgen.core.Skill) PlayerCharacter(pcgen.core.PlayerCharacter) Campaign(pcgen.core.Campaign) LoadContext(pcgen.rules.context.LoadContext) PCClassLoader(pcgen.persistence.lst.PCClassLoader) SourceEntry(pcgen.persistence.lst.SourceEntry) CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) URISyntaxException(java.net.URISyntaxException) PCClass(pcgen.core.PCClass) URI(java.net.URI)

Example 63 with LoadContext

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");
}
Also used : LoadContext(pcgen.rules.context.LoadContext) PCClass(pcgen.core.PCClass) Spell(pcgen.core.spell.Spell)

Example 64 with LoadContext

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();
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) Campaign(pcgen.core.Campaign) LoadContext(pcgen.rules.context.LoadContext) URI(java.net.URI)

Example 65 with LoadContext

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);
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) Campaign(pcgen.core.Campaign) Description(pcgen.core.Description) Race(pcgen.core.Race) LoadContext(pcgen.rules.context.LoadContext) PCClassLoader(pcgen.persistence.lst.PCClassLoader) URI(java.net.URI) SizeAdjustment(pcgen.core.SizeAdjustment) FixedSizeFormula(pcgen.cdom.formula.FixedSizeFormula)

Aggregations

LoadContext (pcgen.rules.context.LoadContext)141 PlayerCharacter (pcgen.core.PlayerCharacter)58 BonusObj (pcgen.core.bonus.BonusObj)48 PCClass (pcgen.core.PCClass)32 URI (java.net.URI)25 CampaignSourceEntry (pcgen.persistence.lst.CampaignSourceEntry)25 URISyntaxException (java.net.URISyntaxException)20 Campaign (pcgen.core.Campaign)16 Race (pcgen.core.Race)16 PreParserFactory (pcgen.persistence.lst.prereq.PreParserFactory)16 Equipment (pcgen.core.Equipment)15 UnreachableError (pcgen.base.lang.UnreachableError)14 PersistenceLayerException (pcgen.persistence.PersistenceLayerException)14 PCClassLoader (pcgen.persistence.lst.PCClassLoader)14 Spell (pcgen.core.spell.Spell)13 Ability (pcgen.core.Ability)12 PCTemplate (pcgen.core.PCTemplate)12 SizeAdjustment (pcgen.core.SizeAdjustment)10 FixedSizeFormula (pcgen.cdom.formula.FixedSizeFormula)9 Skill (pcgen.core.Skill)9