use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.
the class AbilitySelectionApplication method dataRemoved.
@Override
public void dataRemoved(DataFacetChangeEvent<CharID, CNAbilitySelection> dfce) {
CharID id = dfce.getCharID();
CNAbilitySelection cnas = dfce.getCDOMObject();
PlayerCharacter pc = pcFacet.getPC(id);
CNAbility cna = cnas.getCNAbility();
Ability ability = cna.getAbility();
String selection = cnas.getSelection();
if (selection != null) {
ChooseInformation<?> chooseInfo = ability.get(ObjectKey.CHOOSE_INFO);
if (chooseInfo != null) {
removeSelection(pc, chooseInfo, cna, selection);
}
}
}
use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.
the class AddTargetedAbilityNormalTest method containsExpected.
@Override
protected boolean containsExpected(Ability granted) {
Collection<CNAbility> abilities = getTargetFacet().getPoolAbilities(id, AbilityCategory.FEAT, Nature.NORMAL);
for (CNAbility a : abilities) {
boolean abilityExpected = a.getAbility().equals(context.getReferenceContext().silentlyGetConstructedCDOMObject(Ability.class, AbilityCategory.FEAT, "Granted"));
if (abilityExpected) {
if (pc.getDetailedAssociationCount(a) == 1) {
if (!pc.getAssociationList(a).get(0).equals("English")) {
continue;
}
Language english = context.getReferenceContext().silentlyGetConstructedCDOMObject(Language.class, "English");
languageFacet.contains(id, english);
return true;
}
}
}
return false;
}
use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.
the class PlayerCharacter method getAbilityPoolSpent.
private BigDecimal getAbilityPoolSpent(final AbilityCategory aCategory) {
double spent = 0.0d;
Collection<CNAbility> abilities = getPoolAbilities(aCategory, Nature.NORMAL);
if (abilities != null) {
for (final CNAbility cna : abilities) {
Ability ability = cna.getAbility();
final int subfeatCount = getSelectCorrectedAssociationCount(cna);
double cost = ability.getSafe(ObjectKey.SELECTION_COST).doubleValue();
if (ChooseActivation.hasNewChooseToken(ability)) {
spent += Math.ceil(subfeatCount * cost);
} else {
int select = ability.getSafe(FormulaKey.SELECT).resolve(this, "").intValue();
double relativeCost = cost / select;
if (aCategory.allowFractionalPool()) {
spent += relativeCost;
} else {
spent += (int) Math.ceil(relativeCost);
}
}
}
}
if (!aCategory.allowFractionalPool()) {
return BigDecimal.valueOf((int) Math.ceil(spent));
}
return BigDecimal.valueOf(spent);
}
use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.
the class PlayerCharacter method getAbilityList.
private Set<Ability> getAbilityList(Category<Ability> cat, Nature nature) {
Set<Ability> newSet = new HashSet<>();
Collection<CNAbility> cnas = grantedAbilityFacet.getPoolAbilities(id, cat, nature);
for (CNAbility cna : cnas) {
newSet.add(cna.getAbility());
}
return newSet;
}
use of pcgen.cdom.content.CNAbility in project pcgen by PCGen.
the class PlayerCharacter method getConsolidatedAssociationList.
public List<String> getConsolidatedAssociationList(CDOMObject cdo) {
if (cdo instanceof Ability) {
List<String> list = new ArrayList<>();
List<CNAbility> cnabilities = getMatchingCNAbilities((Ability) cdo);
for (CNAbility cna : cnabilities) {
list.addAll(getAssociationList(cna));
}
return list;
} else if (cdo instanceof ChooseDriver) {
return getAssociationList((ChooseDriver) cdo);
} else {
// + cdo.getClass() + " but it is not a ChooseDriver");
return Collections.emptyList();
}
}
Aggregations