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;
}
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));
}
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());
}
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));
}
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));
}
Aggregations