Search in sources :

Example 36 with Campaign

use of pcgen.core.Campaign 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 37 with Campaign

use of pcgen.core.Campaign 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 38 with Campaign

use of pcgen.core.Campaign 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 39 with Campaign

use of pcgen.core.Campaign 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)

Example 40 with Campaign

use of pcgen.core.Campaign in project pcgen by PCGen.

the class PCRacialHDSizeTermEvaluatorTest 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"));
    LoadContext context = Globals.getContext();
    PCClassLoader classLoader = new PCClassLoader();
    // Create the humanoid monster class
    final String humanoidClassLine = "CLASS:Humanoid	KEY:KEY_Humanoid	HD:8	TYPE:Monster	CLASSTYPE:Monster	" + "STARTSKILLPTS:2	MODTOSKILLS:YES";
    humanoidClass = classLoader.parseLine(context, null, humanoidClassLine, source);
    context.getReferenceContext().importObject(humanoidClass);
    // Create the pc class
    final String pcClassLine = "CLASS:TestPCClass	TYPE:PC		HD:10";
    pcClass = classLoader.parseLine(context, null, pcClassLine, source);
    context.getReferenceContext().importObject(pcClass);
    CDOMDirectSingleRef<SizeAdjustment> mediumRef = CDOMDirectSingleRef.getRef(medium);
    // Create the BugBear race
    bugbearRace.setName("Bugbear");
    bugbearRace.put(StringKey.KEY_NAME, "KEY_Bugbear");
    bugbearRace.put(FormulaKey.SIZE, new FixedSizeFormula(mediumRef));
    bugbearRace.addToListFor(ListKey.HITDICE_ADVANCEMENT, Integer.MAX_VALUE);
    bugbearRace.put(ObjectKey.MONSTER_CLASS, new LevelCommandFactory(CDOMDirectSingleRef.getRef(humanoidClass), FormulaFactory.getFormulaFor(3)));
    context.getReferenceContext().importObject(bugbearRace);
    // Create the human race
    humanRace.setName("Human");
    humanRace.put(StringKey.KEY_NAME, "KEY_Human");
    humanRace.put(FormulaKey.SIZE, new FixedSizeFormula(mediumRef));
    context.getReferenceContext().importObject(humanRace);
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) Campaign(pcgen.core.Campaign) Description(pcgen.core.Description) LevelCommandFactory(pcgen.cdom.content.LevelCommandFactory) LoadContext(pcgen.rules.context.LoadContext) PCClassLoader(pcgen.persistence.lst.PCClassLoader) URI(java.net.URI) SizeAdjustment(pcgen.core.SizeAdjustment) FixedSizeFormula(pcgen.cdom.formula.FixedSizeFormula)

Aggregations

Campaign (pcgen.core.Campaign)84 URI (java.net.URI)49 CampaignSourceEntry (pcgen.persistence.lst.CampaignSourceEntry)44 URISyntaxException (java.net.URISyntaxException)17 BeforeClass (org.junit.BeforeClass)16 LoadContext (pcgen.rules.context.LoadContext)16 ArrayList (java.util.ArrayList)14 PlayerCharacter (pcgen.core.PlayerCharacter)11 PersistenceLayerException (pcgen.persistence.PersistenceLayerException)11 File (java.io.File)10 PCClass (pcgen.core.PCClass)10 PCClassLoader (pcgen.persistence.lst.PCClassLoader)10 UnreachableError (pcgen.base.lang.UnreachableError)9 Ability (pcgen.core.Ability)9 GameMode (pcgen.core.GameMode)7 SourceEntry (pcgen.persistence.lst.SourceEntry)7 Test (org.junit.Test)6 HashSet (java.util.HashSet)5 CampaignFacade (pcgen.facade.core.CampaignFacade)5 PCGFile (pcgen.io.PCGFile)5