use of pcgen.cdom.helper.CNAbilitySelection in project pcgen by PCGen.
the class AutoWeaponProfListTargetTest method containsExpected.
private boolean containsExpected() {
Collection<CNAbilitySelection> casSet = directAbilityFacet.getSet(id);
for (CNAbilitySelection cnas : casSet) {
CNAbility cas = cnas.getCNAbility();
boolean featExpected = cas.getAbilityCategory() == AbilityCategory.FEAT;
boolean abilityExpected = cas.getAbility().equals(context.getReferenceContext().silentlyGetConstructedCDOMObject(Ability.class, AbilityCategory.FEAT, "Granted"));
boolean natureExpected = cas.getNature() == Nature.AUTOMATIC;
boolean selectionExpected = "English".equals(cnas.getSelection());
if (featExpected && abilityExpected && natureExpected && selectionExpected) {
return true;
}
}
return false;
}
use of pcgen.cdom.helper.CNAbilitySelection in project pcgen by PCGen.
the class GlobalAbilityTest method containsExpected.
@Override
protected boolean containsExpected(Ability granted) {
Collection<CNAbilitySelection> casSet = getTargetFacet().getSet(id);
for (CNAbilitySelection cnas : casSet) {
CNAbility cas = cnas.getCNAbility();
boolean featExpected = cas.getAbilityCategory() == AbilityCategory.FEAT;
boolean abilityExpected = cas.getAbility().equals(context.getReferenceContext().silentlyGetConstructedCDOMObject(Ability.class, AbilityCategory.FEAT, "Granted"));
boolean natureExpected = cas.getNature() == Nature.VIRTUAL;
boolean selectionExpected = cnas.getSelection() == null;
if (featExpected && abilityExpected && natureExpected && selectionExpected) {
return true;
}
}
return false;
}
use of pcgen.cdom.helper.CNAbilitySelection in project pcgen by PCGen.
the class AbilityTokenTest method createTC.
private void createTC(List<CDOMReference<Ability>> refs, Formula count) {
AbilityRefChoiceSet rcs = new AbilityRefChoiceSet(CDOMDirectSingleRef.getRef(AbilityCategory.FEAT), refs, Nature.NORMAL);
// TODO: Should this be present for the unit tests?
//assertTrue("Invalid grouping state " + rcs.getGroupingState(), rcs.getGroupingState().isValid());
AbilityChoiceSet cs = new AbilityChoiceSet(getSubToken().getTokenName(), rcs);
cs.setTitle("Virtual Feat Selection");
PersistentTransitionChoice<CNAbilitySelection> tc = new ConcretePersistentTransitionChoice<>(cs, count);
tc.allowStack(false);
// if (dupChoices != 0)
// {
// tc.setStackLimit(dupChoices);
// }
tc.setChoiceActor(subtoken);
primaryProf.addToListFor(ListKey.ADD, tc);
}
use of pcgen.cdom.helper.CNAbilitySelection in project pcgen by PCGen.
the class AbilityTokenTest method testUnparseComplex.
@Test
public void testUnparseComplex() throws PersistenceLayerException {
List<CDOMReference<Ability>> refs = createSingle("TestWP1");
AbilityRefChoiceSet rcs = new AbilityRefChoiceSet(CDOMDirectSingleRef.getRef(AbilityCategory.FEAT), refs, Nature.VIRTUAL);
assert (rcs.getGroupingState().isValid());
AbilityChoiceSet cs = new AbilityChoiceSet(getSubToken().getTokenName(), rcs);
cs.setTitle("Virtual Feat Selection");
PersistentTransitionChoice<CNAbilitySelection> tc = new ConcretePersistentTransitionChoice<>(cs, FormulaFactory.getFormulaFor(3));
tc.allowStack(true);
tc.setStackLimit(2);
tc.setChoiceActor(subtoken);
primaryProf.addToListFor(ListKey.ADD, tc);
String[] unparsed = getToken().unparse(primaryContext, primaryProf);
expectSingle(unparsed, getSubTokenName() + '|' + "3|FEAT|VIRTUAL|STACKS=2,TestWP1");
}
use of pcgen.cdom.helper.CNAbilitySelection 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);
}
}
}
Aggregations