Search in sources :

Example 76 with Ability

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

the class VAbilityToken method getAbilityList.

/**
	 * @see pcgen.io.exporttoken.AbilityToken#getAbilityList(pcgen.core.PlayerCharacter, pcgen.core.AbilityCategory)
	 */
@Override
protected MapToList<Ability, CNAbility> getAbilityList(PlayerCharacter pc, final AbilityCategory aCategory) {
    final MapToList<Ability, CNAbility> listOfAbilities = new HashMapToList<>();
    Collection<AbilityCategory> allCats = SettingsHandler.getGame().getAllAbilityCategories();
    for (AbilityCategory aCat : allCats) {
        if (AbilityCategory.ANY.equals(aCategory) || aCat.getParentCategory().equals(aCategory)) {
            for (CNAbility cna : pc.getPoolAbilities(aCat, Nature.VIRTUAL)) {
                listOfAbilities.addToListFor(cna.getAbility(), cna);
            }
        }
    }
    return listOfAbilities;
}
Also used : Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility) CNAbility(pcgen.cdom.content.CNAbility) HashMapToList(pcgen.base.util.HashMapToList) AbilityCategory(pcgen.core.AbilityCategory)

Example 77 with Ability

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

the class PreShieldProfTest method testShieldProfAddedWithAutoShieldProf.

/**
	 * Test the PREPROFWITHSHIELD with shieldprofs added by a AUTO:SHIELDPROF tag
	 * This is probably more an integration test than a unit test
	 * 
	 * @throws Exception the exception
	 */
public void testShieldProfAddedWithAutoShieldProf() throws Exception {
    final PlayerCharacter character = getCharacter();
    Prerequisite prereq;
    final PreParserFactory factory = PreParserFactory.getInstance();
    prereq = factory.parse("PREPROFWITHSHIELD:1,Heavy Steel Shield");
    assertFalse("Character has no proficiencies", PrereqHandler.passes(prereq, character, null));
    final Ability martialProf = TestHelper.makeAbility("Shield Proficiency (Single)", AbilityCategory.FEAT, "General");
    Globals.getContext().unconditionallyProcess(martialProf, "AUTO", "SHIELDPROF|SHIELDTYPE.Heavy");
    AbstractCharacterTestCase.applyAbility(character, AbilityCategory.FEAT, martialProf, null);
    assertTrue("Character has the Heavy Steel Shield proficiency.", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREPROFWITHSHIELD:1,Heavy Wooden Shield");
    assertTrue("Character has the Heavy Wooden Shield proficiency.", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREPROFWITHSHIELD:1,Light Wooden Shield");
    assertFalse("Character does not have the Light Wooden Shield proficiency.", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREPROFWITHSHIELD:1,TYPE.Heavy");
    assertTrue("Character has heavy shield prof.", PrereqHandler.passes(prereq, character, null));
}
Also used : Ability(pcgen.core.Ability) PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory)

Example 78 with Ability

use of pcgen.core.Ability 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 79 with Ability

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

the class PreShieldProfTest method testType.

/**
	 * Test a PREPROFWITHSHIELD that checks for a number of profs of a certain type.
	 * 
	 * @throws Exception the exception
	 */
public void testType() throws Exception {
    final PlayerCharacter character = getCharacter();
    Globals.getContext().getReferenceContext().constructCDOMObject(Equipment.class, "A Shield");
    Prerequisite prereq;
    final PreParserFactory factory = PreParserFactory.getInstance();
    prereq = factory.parse("PREPROFWITHSHIELD:1,TYPE.Medium");
    assertFalse("Character has no proficiencies", PrereqHandler.passes(prereq, character, null));
    final Ability martialProf = TestHelper.makeAbility("Shield Proficiency (Single)", "FEAT", "General");
    Globals.getContext().unconditionallyProcess(martialProf, "AUTO", "SHIELDPROF|SHIELDTYPE=Medium");
    Globals.getContext().getReferenceContext().resolveReferences(null);
    AbstractCharacterTestCase.applyAbility(character, AbilityCategory.FEAT, martialProf, null);
    assertTrue("Character has Medium Shield Proficiency", PrereqHandler.passes(prereq, character, null));
}
Also used : Ability(pcgen.core.Ability) PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory)

Example 80 with Ability

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

the class PreShieldProfTest method testOneOption.

/**
	 * Test with a simple shield proficiency.
	 * 
	 * @throws Exception the exception
	 */
public void testOneOption() throws Exception {
    final PlayerCharacter character = getCharacter();
    Prerequisite prereq;
    final PreParserFactory factory = PreParserFactory.getInstance();
    prereq = factory.parse("PREPROFWITHSHIELD:1,Heavy Wooden Shield");
    assertFalse("Character has no proficiencies", PrereqHandler.passes(prereq, character, null));
    final Ability martialProf = TestHelper.makeAbility("Shield Proficiency (Single)", "FEAT", "General");
    Globals.getContext().unconditionallyProcess(martialProf, "AUTO", "SHIELDPROF|Heavy Wooden Shield");
    Globals.getContext().unconditionallyProcess(martialProf, "AUTO", "SHIELDPROF|Heavy Steel Shield");
    assertTrue(Globals.getContext().getReferenceContext().resolveReferences(null));
    AbstractCharacterTestCase.applyAbility(character, AbilityCategory.FEAT, martialProf, null);
    assertTrue("Character has the Heavy Wooden Shield proficiency.", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREPROFWITHSHIELD:1,Light Wooden Shield");
    assertFalse("Character does not have the Light Wooden Shield proficiency", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREPROFWITHSHIELD:1,Heavy Steel Shield");
    assertTrue("Character has the Heavy Steel Shield proficiency.", PrereqHandler.passes(prereq, character, null));
}
Also used : Ability(pcgen.core.Ability) PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory)

Aggregations

Ability (pcgen.core.Ability)279 CNAbility (pcgen.cdom.content.CNAbility)128 AbilityCategory (pcgen.core.AbilityCategory)60 PlayerCharacter (pcgen.core.PlayerCharacter)54 Test (org.junit.Test)46 ArrayList (java.util.ArrayList)43 CNAbilitySelection (pcgen.cdom.helper.CNAbilitySelection)25 ParseResult (pcgen.rules.persistence.token.ParseResult)21 HashMapToList (pcgen.base.util.HashMapToList)15 PCClass (pcgen.core.PCClass)15 Spell (pcgen.core.spell.Spell)15 StringTokenizer (java.util.StringTokenizer)14 TestContext (plugin.lsttokens.editcontext.testsupport.TestContext)13 LoadContext (pcgen.rules.context.LoadContext)12 SpecialAbility (pcgen.core.SpecialAbility)11 CharacterSpell (pcgen.core.character.CharacterSpell)11 PreParserFactory (pcgen.persistence.lst.prereq.PreParserFactory)11 List (java.util.List)10 CDOMObject (pcgen.cdom.base.CDOMObject)10 CDOMSingleRef (pcgen.cdom.reference.CDOMSingleRef)10