Search in sources :

Example 86 with CNAbility

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

the class PrerequisiteUtilities method buildAbilityList.

/**
	 * Build up a list of the character's abilities which match the category requirements.
	 *
	 * @param character The character to be tested.
	 * @param categoryName The name of the required category, null if any category will be matched.
	 * @return A list of categories matching.
	 */
private static Set<Ability> buildAbilityList(final PlayerCharacter character, String categoryName) {
    final Set<Ability> abilityList = new WrappedMapSet<>(IdentityHashMap.class);
    if (character != null) {
        AbilityCategory cat = SettingsHandler.getGame().getAbilityCategory(categoryName);
        if (cat == null) {
            Logging.errorPrint("Invalid category " + categoryName + " in PREABILITY");
            return abilityList;
        }
        if (!cat.getParentCategory().equals(cat)) {
            Logging.errorPrint("Invalid use of child category in PREABILITY");
        }
        for (CNAbility cna : character.getCNAbilities(cat)) {
            abilityList.add(cna.getAbility());
        }
        Collection<AbilityCategory> allCats = SettingsHandler.getGame().getAllAbilityCategories();
        // Now scan for relevant SERVESAS occurrences
        for (AbilityCategory aCat : allCats) {
            for (CNAbility cna : character.getPoolAbilities(aCat)) {
                for (CDOMReference<Ability> ref : cna.getAbility().getSafeListFor(ListKey.SERVES_AS_ABILITY)) {
                    for (Ability ab : ref.getContainedObjects()) {
                        abilityList.add(ab);
                    }
                }
            }
        }
    }
    return abilityList;
}
Also used : Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility) CNAbility(pcgen.cdom.content.CNAbility) WrappedMapSet(pcgen.base.util.WrappedMapSet) AbilityCategory(pcgen.core.AbilityCategory)

Example 87 with CNAbility

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

the class PCBonusLangTermEvaluator method resolve.

@Override
public Float resolve(PlayerCharacter pc) {
    int nml = pc.getDisplay().totalNonMonsterLevels();
    if ((nml > 1) || (nml > 0 && pc.getDisplay().totalHitDice() > 0)) {
        if (!Globals.checkRule(RuleConstants.INTBONUSLANG)) {
            return 0.0f;
        }
    }
    int count = pc.getBonusLanguageCount();
    CNAbility a = pc.getBonusLanguageAbility();
    int currentLangCount = pc.getDetailedAssociationCount(a);
    int result = count - currentLangCount;
    return (float) result;
}
Also used : CNAbility(pcgen.cdom.content.CNAbility)

Example 88 with CNAbility

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

the class PCCountAbilityNameTermEvaluator method resolve.

@Override
public Float resolve(PlayerCharacter pc) {
    Float count = 0.0f;
    List<CNAbility> abilityList = getAbilities(pc);
    for (CNAbility anAbility : abilityList) {
        if (anAbility.getAbilityKey().equalsIgnoreCase(key)) {
            count += countVisibleAbility(pc, anAbility, visible, hidden, false);
            break;
        }
    }
    return count;
}
Also used : CNAbility(pcgen.cdom.content.CNAbility)

Example 89 with CNAbility

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

the class FeatAutoToken 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 (aCat.getParentCategory().equals(aCategory)) {
            for (CNAbility cna : pc.getPoolAbilities(aCat, Nature.AUTOMATIC)) {
                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 90 with CNAbility

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

the class FeatAutoListToken method getAbilityList.

/**
	 * @see pcgen.io.exporttoken.AbilityListToken#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 (aCat.getParentCategory().equals(aCategory)) {
            for (CNAbility cna : pc.getPoolAbilities(aCat, Nature.AUTOMATIC)) {
                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)

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