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