Search in sources :

Example 36 with CNAbilitySelection

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;
}
Also used : ArrayList(java.util.ArrayList) CNAbilitySelection(pcgen.cdom.helper.CNAbilitySelection) PCTemplate(pcgen.core.PCTemplate)

Example 37 with CNAbilitySelection

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());
}
Also used : CNAbility(pcgen.cdom.content.CNAbility) CNAbilitySelection(pcgen.cdom.helper.CNAbilitySelection)

Example 38 with CNAbilitySelection

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;
}
Also used : CNAbility(pcgen.cdom.content.CNAbility) CNAbilitySelection(pcgen.cdom.helper.CNAbilitySelection)

Example 39 with CNAbilitySelection

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));
}
Also used : Ability(pcgen.core.Ability) CNAbilitySelection(pcgen.cdom.helper.CNAbilitySelection) Test(org.junit.Test)

Example 40 with CNAbilitySelection

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);
    }
}
Also used : Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility) Nature(pcgen.cdom.enumeration.Nature) ArrayList(java.util.ArrayList) CNAbilitySelection(pcgen.cdom.helper.CNAbilitySelection)

Aggregations

CNAbilitySelection (pcgen.cdom.helper.CNAbilitySelection)70 CNAbility (pcgen.cdom.content.CNAbility)35 Test (org.junit.Test)28 Ability (pcgen.core.Ability)26 ArrayList (java.util.ArrayList)17 AbilityCategory (pcgen.core.AbilityCategory)7 CDOMReference (pcgen.cdom.base.CDOMReference)6 PlayerCharacter (pcgen.core.PlayerCharacter)6 ParseResult (pcgen.rules.persistence.token.ParseResult)6 ConcretePersistentTransitionChoice (pcgen.cdom.base.ConcretePersistentTransitionChoice)5 AbilityRefChoiceSet (pcgen.cdom.choiceset.AbilityRefChoiceSet)5 Nature (pcgen.cdom.enumeration.Nature)5 PCTemplate (pcgen.core.PCTemplate)5 CharID (pcgen.cdom.enumeration.CharID)4 List (java.util.List)3 AbilityChoiceSet (pcgen.cdom.base.ChoiceSet.AbilityChoiceSet)3 SpecialAbility (pcgen.core.SpecialAbility)3 BonusObj (pcgen.core.bonus.BonusObj)3 AbstractTokenModelTest (tokenmodel.testsupport.AbstractTokenModelTest)3 HashSet (java.util.HashSet)2