use of pcgen.cdom.helper.CNAbilitySelection in project pcgen by PCGen.
the class TemplateToken method feats.
/**
* Retrieve the list of the keynames of any feats
* that the PC qualifies for at the supplied level and
* hit dice.
*
* @param pc
*
* @return a list of feats
*/
public static List<CNAbilitySelection> feats(PlayerCharacter pc, PCTemplate pct) {
final List<CNAbilitySelection> feats = new ArrayList<>();
for (PCTemplate rlt : pct.getSafeListFor(ListKey.REPEATLEVEL_TEMPLATES)) {
for (PCTemplate lt : rlt.getSafeListFor(ListKey.LEVEL_TEMPLATES)) {
Collection<? extends CNAbilitySelection> featList = pc.getTemplateFeatList(lt);
if (featList != null) {
feats.addAll(featList);
}
}
}
for (PCTemplate lt : pct.getSafeListFor(ListKey.LEVEL_TEMPLATES)) {
Collection<? extends CNAbilitySelection> featList = pc.getTemplateFeatList(lt);
if (featList != null) {
feats.addAll(featList);
}
}
for (PCTemplate lt : pct.getSafeListFor(ListKey.HD_TEMPLATES)) {
Collection<? extends CNAbilitySelection> featList = pc.getTemplateFeatList(lt);
if (featList != null) {
feats.addAll(featList);
}
}
Collection<? extends CNAbilitySelection> featList = pc.getTemplateFeatList(pct);
if (featList != null) {
feats.addAll(featList);
}
return feats;
}
use of pcgen.cdom.helper.CNAbilitySelection in project pcgen by PCGen.
the class AbstractCharacterTestCase method removeAbility.
protected void removeAbility(AbilityCategory cat, Ability a) {
if (a.getSafe(ObjectKey.MULTIPLE_ALLOWED)) {
fail("addAbility takes Mult:NO Abilities");
}
CNAbility cna = CNAbilityFactory.getCNAbility(cat, Nature.NORMAL, a);
character.removeAbility(new CNAbilitySelection(cna, null), UserSelection.getInstance(), UserSelection.getInstance());
}
use of pcgen.cdom.helper.CNAbilitySelection in project pcgen by PCGen.
the class AbstractJunit4CharacterTestCase method applyAbility.
public static CNAbility applyAbility(PlayerCharacter character, AbilityCategory cat, Ability a, String assoc) {
if (a.getCDOMCategory() == null) {
fail("Attempt to apply an Ability " + a.getKeyName() + " that never received a Category");
}
CNAbility cna = CNAbilityFactory.getCNAbility(cat, Nature.NORMAL, a);
CNAbilitySelection cnas = new CNAbilitySelection(cna, assoc);
character.addAbility(cnas, UserSelection.getInstance(), UserSelection.getInstance());
return cna;
}
use of pcgen.cdom.helper.CNAbilitySelection in project pcgen by PCGen.
the class AbilityTokenTest method testEncodeChoice.
@Test
public void testEncodeChoice() {
Ability item = construct("ItemName");
CNAbilitySelection as = new CNAbilitySelection(CNAbilityFactory.getCNAbility(AbilityCategory.FEAT, Nature.NORMAL, item));
assertEquals("CATEGORY=FEAT|NATURE=NORMAL|ItemName", pca.encodeChoice(as));
}
use of pcgen.cdom.helper.CNAbilitySelection in project pcgen by PCGen.
the class CharacterAbilities method addCategorisedAbility.
/**
* Add the ability to the categorised list held by CharacterAbilities.
* One copy will be added for each choice.
*
* @param cat The AbilityCategory that the ability is being added to.
* @param ability The ability being added.
* @param nature The nature via which the ability is being added.
* @param workingAbilityListMap The map to be adjusted.
*/
private void addCategorisedAbility(CNAbility cna, Map<AbilityCategoryFacade, DefaultListFacade<AbilityFacade>> workingAbilityListMap) {
Ability ability = cna.getAbility();
List<CNAbilitySelection> cas = new ArrayList<>();
Category<Ability> cat = cna.getAbilityCategory();
Nature nature = cna.getNature();
if (ability.getSafe(ObjectKey.MULTIPLE_ALLOWED)) {
List<String> choices = theCharacter.getAssociationList(cna);
if (choices == null || choices.isEmpty()) {
Logging.errorPrint("Ignoring Ability: " + ability + " (" + cat + " / " + nature + ") that UI has as added to the PC, but it has no associations");
} else {
for (String choice : choices) {
cas.add(new CNAbilitySelection(CNAbilityFactory.getCNAbility(cat, nature, ability), choice));
}
}
} else {
cas.add(new CNAbilitySelection(CNAbilityFactory.getCNAbility(cat, nature, ability)));
}
for (CNAbilitySelection sel : cas) {
addElement(workingAbilityListMap, sel);
}
}
Aggregations