Search in sources :

Example 26 with CNAbility

use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.

the class ChooserUtilities method getConfiguredController.

public static <T> ChoiceManagerList<T> getConfiguredController(final ChooseDriver aPObject, final PlayerCharacter aPC, final AbilityCategory category, List<String> reservedList) {
    ChoiceManagerList aMan = getChoiceManager(aPObject, aPC);
    if (aMan == null) {
        return null;
    }
    if (aPObject instanceof CNAbility) {
        CNAbility driver = (CNAbility) aPObject;
        Ability a = driver.getAbility();
        AbilityCategory cat;
        if (category == null) {
            cat = SettingsHandler.getGame().getAbilityCategory(a.getCategory());
        } else {
            cat = category;
        }
        aMan.setController(new AbilityChooseController(a, cat, aPC, aMan));
        List<CNAbility> abilities = aPC.getMatchingCNAbilities(a);
        for (CNAbility cna : abilities) {
            reservedList.addAll(aPC.getAssociationList(cna));
        }
    } else if (aPObject instanceof Skill) {
        Skill s = (Skill) aPObject;
        aMan.setController(new SkillChooseController(s, aPC));
    }
    return aMan;
}
Also used : CNAbility(pcgen.cdom.content.CNAbility) Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility) Skill(pcgen.core.Skill) AbilityCategory(pcgen.core.AbilityCategory)

Example 27 with CNAbility

use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.

the class QualifiedName method processChooseInfo.

private static <T> void processChooseInfo(StringBuilder aStrBuf, PlayerCharacter pc, ChooseInformation<T> chooseInfo, List<CNAbility> list) {
    List<T> allSelections = new ArrayList<>();
    for (CNAbility cna : list) {
        if (pc.hasAssociations(cna)) {
            List<? extends T> selections = (List<? extends T>) pc.getDetailedAssociations(cna);
            allSelections.addAll(selections);
        }
    }
    String choiceInfo = chooseInfo.composeDisplay(allSelections).toString();
    if (!choiceInfo.isEmpty()) {
        aStrBuf.append(" (");
        aStrBuf.append(choiceInfo);
        aStrBuf.append(")");
    }
}
Also used : CNAbility(pcgen.cdom.content.CNAbility) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 28 with CNAbility

use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.

the class GrantedAbilityFacet method getCNAbilities.

public Collection<CNAbility> getCNAbilities(CharID id, Ability ability) {
    Set<CNAbility> returnList = new HashSet<>();
    List<List<SourcedCNAS>> list = getList(id);
    if (list != null) {
        Category<Ability> cat = ability.getCDOMCategory();
        for (List<SourcedCNAS> array : list) {
            CNAbility cna = array.get(0).cnas.getCNAbility();
            if (cna.getAbilityCategory().getParentCategory().equals(cat) && cna.getAbilityKey().equals(ability.getKeyName())) {
                returnList.add(cna);
            }
        }
    }
    return returnList;
}
Also used : CNAbility(pcgen.cdom.content.CNAbility) Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility) ArrayList(java.util.ArrayList) List(java.util.List) HashSet(java.util.HashSet)

Example 29 with CNAbility

use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.

the class GrantedAbilityFacet method getPoolAbilities.

public Collection<CNAbility> getPoolAbilities(CharID id, Category<Ability> cat, Nature n) {
    List<CNAbility> returnList = new ArrayList<>();
    List<List<SourcedCNAS>> list = getList(id);
    if (list != null) {
        for (List<SourcedCNAS> array : list) {
            CNAbility cna = array.get(0).cnas.getCNAbility();
            if (cna.getAbilityCategory().equals(cat) && cna.getNature() == n) {
                returnList.add(cna);
            }
        }
    }
    return returnList;
}
Also used : CNAbility(pcgen.cdom.content.CNAbility) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 30 with CNAbility

use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.

the class GrantedAbilityFacet method getCNAbilities.

public Collection<CNAbility> getCNAbilities(CharID id, Category<Ability> cat) {
    if (cat.getParentCategory() != cat) {
    //warning
    }
    List<CNAbility> returnList = new ArrayList<>();
    List<List<SourcedCNAS>> list = getList(id);
    if (list != null) {
        for (List<SourcedCNAS> array : list) {
            CNAbility cna = array.get(0).cnas.getCNAbility();
            if (cna.getAbilityCategory().getParentCategory().equals(cat)) {
                returnList.add(cna);
            }
        }
    }
    return returnList;
}
Also used : CNAbility(pcgen.cdom.content.CNAbility) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

CNAbility (pcgen.cdom.content.CNAbility)131 Ability (pcgen.core.Ability)77 ArrayList (java.util.ArrayList)37 CNAbilitySelection (pcgen.cdom.helper.CNAbilitySelection)28 AbilityCategory (pcgen.core.AbilityCategory)26 Test (org.junit.Test)21 HashMapToList (pcgen.base.util.HashMapToList)16 List (java.util.List)15 PlayerCharacter (pcgen.core.PlayerCharacter)9 Language (pcgen.core.Language)7 HashSet (java.util.HashSet)5 Nature (pcgen.cdom.enumeration.Nature)5 SpecialAbility (pcgen.core.SpecialAbility)5 BonusObj (pcgen.core.bonus.BonusObj)5 BigDecimal (java.math.BigDecimal)4 CDOMObject (pcgen.cdom.base.CDOMObject)4 LoadContext (pcgen.rules.context.LoadContext)4 StringTokenizer (java.util.StringTokenizer)3 GenericMapToList (pcgen.base.util.GenericMapToList)3 PCClass (pcgen.core.PCClass)3