Search in sources :

Example 41 with CNAbilitySelection

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;
}
Also used : CNAbility(pcgen.cdom.content.CNAbility) Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility) CNAbilitySelection(pcgen.cdom.helper.CNAbilitySelection)

Example 42 with CNAbilitySelection

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;
}
Also used : CNAbility(pcgen.cdom.content.CNAbility) Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility) CNAbilitySelection(pcgen.cdom.helper.CNAbilitySelection)

Example 43 with CNAbilitySelection

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);
}
Also used : AbilityChoiceSet(pcgen.cdom.base.ChoiceSet.AbilityChoiceSet) CNAbilitySelection(pcgen.cdom.helper.CNAbilitySelection) AbilityRefChoiceSet(pcgen.cdom.choiceset.AbilityRefChoiceSet) ConcretePersistentTransitionChoice(pcgen.cdom.base.ConcretePersistentTransitionChoice)

Example 44 with CNAbilitySelection

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");
}
Also used : AbilityChoiceSet(pcgen.cdom.base.ChoiceSet.AbilityChoiceSet) CNAbilitySelection(pcgen.cdom.helper.CNAbilitySelection) CDOMReference(pcgen.cdom.base.CDOMReference) AbilityRefChoiceSet(pcgen.cdom.choiceset.AbilityRefChoiceSet) ConcretePersistentTransitionChoice(pcgen.cdom.base.ConcretePersistentTransitionChoice) Test(org.junit.Test)

Example 45 with CNAbilitySelection

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);
        }
    }
}
Also used : CNAbility(pcgen.cdom.content.CNAbility) Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility) PlayerCharacter(pcgen.core.PlayerCharacter) CNAbilitySelection(pcgen.cdom.helper.CNAbilitySelection) CharID(pcgen.cdom.enumeration.CharID)

Aggregations

CNAbilitySelection (pcgen.cdom.helper.CNAbilitySelection)70 CNAbility (pcgen.cdom.content.CNAbility)35 Test (org.junit.Test)28 Ability (pcgen.core.Ability)26 ArrayList (java.util.ArrayList)17 AbilityCategory (pcgen.core.AbilityCategory)7 CDOMReference (pcgen.cdom.base.CDOMReference)6 PlayerCharacter (pcgen.core.PlayerCharacter)6 ParseResult (pcgen.rules.persistence.token.ParseResult)6 ConcretePersistentTransitionChoice (pcgen.cdom.base.ConcretePersistentTransitionChoice)5 AbilityRefChoiceSet (pcgen.cdom.choiceset.AbilityRefChoiceSet)5 Nature (pcgen.cdom.enumeration.Nature)5 PCTemplate (pcgen.core.PCTemplate)5 CharID (pcgen.cdom.enumeration.CharID)4 List (java.util.List)3 AbilityChoiceSet (pcgen.cdom.base.ChoiceSet.AbilityChoiceSet)3 SpecialAbility (pcgen.core.SpecialAbility)3 BonusObj (pcgen.core.bonus.BonusObj)3 AbstractTokenModelTest (tokenmodel.testsupport.AbstractTokenModelTest)3 HashSet (java.util.HashSet)2