use of pcgen.base.util.GenericMapToList in project pcgen by PCGen.
the class AbilityToken method buildAbilityList.
/**
* Build up the list of abilities of interest based on the type and visibility selection.
*
* @param types
* The list of types which it must match at least one of.
* @param negate
* The list of types it must not match any of.
* @param abilityType
* The type definition it must match.
* @param aspect
* The aspect which it must match.
* @return List of abilities based on the type, visibility, and aspect selection.
*/
static MapToList<Ability, CNAbility> buildAbilityList(List<String> types, List<String> negate, String abilityType, View view, String aspect, MapToList<Ability, CNAbility> listOfAbilities) {
List<Ability> aList = new ArrayList<>(listOfAbilities.getKeySet());
// Sort the ability list passed in
Globals.sortPObjectListByName(aList);
boolean matchTypeDef = false;
boolean matchVisibilityDef = false;
boolean matchAspectDef = false;
// List to build up
List<Ability> bList = new ArrayList<>();
// on its visibility filtering and its ability type filtering
for (Ability aAbility : aList) {
matchTypeDef = abilityMatchesType(abilityType, aAbility, types, negate);
matchVisibilityDef = abilityVisibleTo(view, aAbility);
matchAspectDef = abilityMatchesAspect(aspect, aAbility);
if (matchTypeDef && matchVisibilityDef && matchAspectDef) {
bList.add(aAbility);
}
}
try {
MapToList<Ability, CNAbility> mtl = new GenericMapToList<>(LinkedHashMap.class);
for (Ability a : bList) {
mtl.addAllToListFor(a, listOfAbilities.getListFor(a));
}
return mtl;
} catch (InstantiationException | IllegalAccessException e) {
throw new UnreachableError(e);
}
}
use of pcgen.base.util.GenericMapToList in project pcgen by PCGen.
the class AbilityToken method buildAbilityList.
/**
* Build up the list of abilities of interest based on the key and visibility selection.
*
* @param key
* The key of the wanted ability.
* @return List of abilities based on the type and visibility selection.
*/
static MapToList<Ability, CNAbility> buildAbilityList(String key, View view, MapToList<Ability, CNAbility> listOfAbilities) {
List<Ability> aList = new ArrayList<>(listOfAbilities.getKeySet());
// Sort the ability list passed in
Globals.sortPObjectListByName(aList);
boolean matchKeyDef = false;
boolean matchVisibilityDef = false;
// List to build up
List<Ability> bList = new ArrayList<>();
// on its visibility filtering and its ability type filtering
for (Ability aAbility : aList) {
matchKeyDef = aAbility.getKeyName().equalsIgnoreCase(key);
matchVisibilityDef = abilityVisibleTo(view, aAbility);
if (matchKeyDef && matchVisibilityDef) {
bList.add(aAbility);
}
}
try {
MapToList<Ability, CNAbility> mtl = new GenericMapToList<>(LinkedHashMap.class);
for (Ability a : bList) {
mtl.addAllToListFor(a, listOfAbilities.getListFor(a));
}
return mtl;
} catch (InstantiationException | IllegalAccessException e) {
throw new UnreachableError(e);
}
}
Aggregations