Search in sources :

Example 1 with FeatLoader

use of pcgen.persistence.lst.FeatLoader in project pcgen by PCGen.

the class PreShieldProfTest method testWithFeatThatGrantsBonus.

/**
	 * Test PREPROFWITHSHIELD with a feat that has a bonus tag
	 * 
	 * @throws Exception the exception
	 */
public void testWithFeatThatGrantsBonus() throws Exception {
    final PlayerCharacter character = getCharacter();
    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());
    final Ability martialProf = TestHelper.makeAbility("Shield Proficiency (Single)", "FEAT", "General");
    Globals.getContext().unconditionallyProcess(martialProf, "AUTO", "SHIELDPROF|Full Plate");
    assertTrue(Globals.getContext().getReferenceContext().resolveReferences(null));
    AbstractCharacterTestCase.applyAbility(character, AbilityCategory.FEAT, martialProf, null);
    Ability foo = new Ability();
    final String fooStr = "Foo	TYPE:General	DESC:See Text	BONUS:HP|CURRENTMAX|50|PREPROFWITHSHIELD:1,Full Plate";
    featLoader.parseLine(Globals.getContext(), foo, fooStr, cse);
    addAbility(AbilityCategory.FEAT, foo);
    assertEquals("Character has the Full Plate 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) URISyntaxException(java.net.URISyntaxException) UnreachableError(pcgen.base.lang.UnreachableError) URI(java.net.URI)

Example 2 with FeatLoader

use of pcgen.persistence.lst.FeatLoader 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 3 with FeatLoader

use of pcgen.persistence.lst.FeatLoader in project pcgen by PCGen.

the class PCClassTest method testGetHighestLevelSpell.

/**
	 * Test the function of the getHighestLevelSpell method.
	 * @throws PersistenceLayerException
	 */
public void testGetHighestLevelSpell() throws PersistenceLayerException {
    LoadContext context = Globals.getContext();
    PCClass megaCasterClass = new PCClass();
    megaCasterClass.setName("MegaCaster");
    BuildUtilities.setFact(megaCasterClass, "SpellType", "Arcane");
    context.unconditionallyProcess(megaCasterClass, "SPELLSTAT", "CHA");
    megaCasterClass.put(ObjectKey.SPELLBOOK, false);
    megaCasterClass.put(ObjectKey.MEMORIZE_SPELLS, false);
    context.unconditionallyProcess(megaCasterClass.getOriginalClassLevel(1), "KNOWN", "4,2,2,3,4,5");
    context.unconditionallyProcess(megaCasterClass.getOriginalClassLevel(1), "CAST", "3,1,2,3,4,5");
    context.unconditionallyProcess(megaCasterClass.getOriginalClassLevel(2), "KNOWN", "4,2,2,3,4,5,6,7,8,9,10");
    context.unconditionallyProcess(megaCasterClass.getOriginalClassLevel(2), "CAST", "3,1,2,3,4,5,6,7,8,9,10");
    Globals.getContext().getReferenceContext().importObject(megaCasterClass);
    final PlayerCharacter character = getCharacter();
    assertEquals("Highest spell level for class", 10, character.getSpellSupport(megaCasterClass).getHighestLevelSpell());
    character.incrementClassLevel(1, megaCasterClass);
    PCClass charClass = character.getClassKeyed(megaCasterClass.getKeyName());
    assertEquals("Highest spell level for character's class", 10, character.getSpellSupport(charClass).getHighestLevelSpell());
    String sbook = Globals.getDefaultSpellBook();
    String cast = character.getSpellSupport(charClass).getCastForLevel(10, sbook, true, false, character) + character.getSpellSupport(charClass).getBonusCastForLevelString(10, sbook, character);
    assertEquals("Should not be able to cast 10th level spells at 1st level", "0", cast);
    cast = character.getSpellSupport(charClass).getCastForLevel(5, sbook, true, false, character) + character.getSpellSupport(charClass).getBonusCastForLevelString(5, sbook, character);
    assertEquals("Should be able to cast 5th level spells at 1st level", "5", cast);
    Ability casterFeat = new Ability();
    FeatLoader featLoader = new FeatLoader();
    CampaignSourceEntry source;
    try {
        source = new CampaignSourceEntry(new Campaign(), new URI("file:/" + getClass().getName() + ".java"));
    } catch (URISyntaxException e) {
        throw new UnreachableError(e);
    }
    featLoader.parseLine(Globals.getContext(), casterFeat, "CasterBoost	TYPE:General	BONUS:SPELLCAST|CLASS=MegaCaster;LEVEL=11|1", source);
    casterFeat.setCDOMCategory(AbilityCategory.FEAT);
    context.getReferenceContext().importObject(casterFeat);
    AbstractCharacterTestCase.applyAbility(character, AbilityCategory.FEAT, casterFeat, null);
    cast = character.getSpellSupport(charClass).getCastForLevel(11, sbook, true, false, character) + character.getSpellSupport(charClass).getBonusCastForLevelString(11, sbook, character);
    assertEquals("Should be able to cast 11th level spells with feat", "1", cast);
    assertEquals("Should be able to cast 11th level spells with feat", 11, character.getSpellSupport(charClass).getHighestLevelSpell(character));
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) FeatLoader(pcgen.persistence.lst.FeatLoader) LoadContext(pcgen.rules.context.LoadContext) URISyntaxException(java.net.URISyntaxException) UnreachableError(pcgen.base.lang.UnreachableError) URI(java.net.URI)

Example 4 with FeatLoader

use of pcgen.persistence.lst.FeatLoader in project pcgen by PCGen.

the class PreArmorProfTest 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 the exception
	 */
public void testWithFeatThatGrantsBonus() throws Exception {
    final PlayerCharacter character = getCharacter();
    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());
    final Ability martialProf = TestHelper.makeAbility("Shield Proficiency (Single)", "FEAT", "General");
    Globals.getContext().unconditionallyProcess(martialProf, "AUTO", "ARMORPROF|Full Plate");
    assertTrue(Globals.getContext().getReferenceContext().resolveReferences(null));
    AbstractCharacterTestCase.applyAbility(character, AbilityCategory.FEAT, martialProf, null);
    Ability foo = new Ability();
    final String fooStr = "Foo	TYPE:General	DESC:See Text	BONUS:HP|CURRENTMAX|50|PREPROFWITHARMOR:1,Full Plate";
    featLoader.parseLine(Globals.getContext(), foo, fooStr, cse);
    addAbility(AbilityCategory.FEAT, foo);
    assertEquals("Character has the Full Plate 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) URISyntaxException(java.net.URISyntaxException) UnreachableError(pcgen.base.lang.UnreachableError) URI(java.net.URI)

Example 5 with FeatLoader

use of pcgen.persistence.lst.FeatLoader in project pcgen by PCGen.

the class PCBooleanFunctionTest method additionalSetUp.

@Override
protected void additionalSetUp() throws Exception {
    CampaignSourceEntry cse = new CampaignSourceEntry(new Campaign(), new URI("file:/" + getClass().getName() + ".java"));
    final FeatLoader featLoader = new FeatLoader();
    fooFeat = new Ability();
    final String fooFeatStr = "Foo	TYPE:General	DEFINE:FooV|0";
    featLoader.parseLine(Globals.getContext(), fooFeat, fooFeatStr, cse);
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) Ability(pcgen.core.Ability) Campaign(pcgen.core.Campaign) FeatLoader(pcgen.persistence.lst.FeatLoader) URI(java.net.URI)

Aggregations

URI (java.net.URI)6 CampaignSourceEntry (pcgen.persistence.lst.CampaignSourceEntry)6 FeatLoader (pcgen.persistence.lst.FeatLoader)6 Ability (pcgen.core.Ability)5 Campaign (pcgen.core.Campaign)5 URISyntaxException (java.net.URISyntaxException)4 UnreachableError (pcgen.base.lang.UnreachableError)4 PlayerCharacter (pcgen.core.PlayerCharacter)3 LoadContext (pcgen.rules.context.LoadContext)2 PCTemplate (pcgen.core.PCTemplate)1