Search in sources :

Example 11 with ReferenceChoiceSet

use of pcgen.cdom.choiceset.ReferenceChoiceSet in project pcgen by PCGen.

the class SpellListTokenTest method testUnparseBadCount.

@Test
public void testUnparseBadCount() throws PersistenceLayerException {
    ClassSpellList wp1 = construct(primaryContext, "TestWP1");
    ReferenceChoiceSet<ClassSpellList> rcs = new ReferenceChoiceSet<>(Collections.singletonList(CDOMDirectSingleRef.getRef(wp1)));
    ChoiceSet<ClassSpellList> cs = new ChoiceSet<>(token.getTokenName(), rcs);
    cs.setTitle("Pick a ClassSpellList");
    PersistentTransitionChoice<CDOMListObject<Spell>> tc1 = new ConcretePersistentTransitionChoice<>(cs, null);
    primaryProf.put(ObjectKey.SPELLLIST_CHOICE, tc1);
    assertBadUnparse();
}
Also used : ReferenceChoiceSet(pcgen.cdom.choiceset.ReferenceChoiceSet) ChoiceSet(pcgen.cdom.base.ChoiceSet) ClassSpellList(pcgen.cdom.list.ClassSpellList) ReferenceChoiceSet(pcgen.cdom.choiceset.ReferenceChoiceSet) ConcretePersistentTransitionChoice(pcgen.cdom.base.ConcretePersistentTransitionChoice) CDOMListObject(pcgen.cdom.base.CDOMListObject) Test(org.junit.Test)

Example 12 with ReferenceChoiceSet

use of pcgen.cdom.choiceset.ReferenceChoiceSet in project pcgen by PCGen.

the class SkillListTokenTest method testUnparseBadCount.

@Test
public void testUnparseBadCount() throws PersistenceLayerException {
    ClassSkillList wp1 = construct(primaryContext, "TestWP1");
    ReferenceChoiceSet<ClassSkillList> rcs = new ReferenceChoiceSet<>(Collections.singletonList(CDOMDirectSingleRef.getRef(wp1)));
    ChoiceSet<ClassSkillList> cs = new ChoiceSet<>(token.getTokenName(), rcs);
    cs.setTitle("Pick a ClassSkillList");
    PersistentTransitionChoice<ClassSkillList> tc1 = new ConcretePersistentTransitionChoice<>(cs, null);
    primaryProf.put(ObjectKey.SKILLLIST_CHOICE, tc1);
    assertBadUnparse();
}
Also used : ReferenceChoiceSet(pcgen.cdom.choiceset.ReferenceChoiceSet) ChoiceSet(pcgen.cdom.base.ChoiceSet) ClassSkillList(pcgen.cdom.list.ClassSkillList) ReferenceChoiceSet(pcgen.cdom.choiceset.ReferenceChoiceSet) ConcretePersistentTransitionChoice(pcgen.cdom.base.ConcretePersistentTransitionChoice) Test(org.junit.Test)

Example 13 with ReferenceChoiceSet

use of pcgen.cdom.choiceset.ReferenceChoiceSet in project pcgen by PCGen.

the class ClassSkillsLevelTokenTest method testUnparseTrained.

@Test
public void testUnparseTrained() throws PersistenceLayerException {
    List<CDOMReference<Skill>> refs = new ArrayList<>();
    ObjectMatchingReference<Skill, Boolean> omr = new ObjectMatchingReference<>("TRAINED", Skill.class, getAllRef(), ObjectKey.USE_UNTRAINED, Boolean.FALSE);
    omr.returnIncludesNulls(true);
    refs.add(omr);
    ReferenceChoiceSet<Skill> rcs = new ReferenceChoiceSet<>(refs);
    ChoiceSet<Skill> cs = new ChoiceSet<>(getSubToken().getTokenName(), rcs);
    PersistentTransitionChoice<Skill> tc = new ConcretePersistentTransitionChoice<>(cs, FormulaFactory.ONE);
    primaryProf.addToListFor(ListKey.ADD, tc);
    tc.setChoiceActor(new ClassSkillChoiceActor(fighter, null));
    String[] unparsed = getToken().unparse(primaryContext, primaryProf);
    expectSingle(unparsed, getSubTokenName() + '|' + "TRAINED");
}
Also used : ReferenceChoiceSet(pcgen.cdom.choiceset.ReferenceChoiceSet) ChoiceSet(pcgen.cdom.base.ChoiceSet) ArrayList(java.util.ArrayList) ConcretePersistentTransitionChoice(pcgen.cdom.base.ConcretePersistentTransitionChoice) Skill(pcgen.core.Skill) ClassSkillChoiceActor(pcgen.cdom.helper.ClassSkillChoiceActor) CDOMReference(pcgen.cdom.base.CDOMReference) ObjectMatchingReference(pcgen.cdom.reference.ObjectMatchingReference) ReferenceChoiceSet(pcgen.cdom.choiceset.ReferenceChoiceSet) Test(org.junit.Test)

Example 14 with ReferenceChoiceSet

use of pcgen.cdom.choiceset.ReferenceChoiceSet in project pcgen by PCGen.

the class ClassSkillsLevelTokenTest method testUnparseNonExclusive.

@Test
public void testUnparseNonExclusive() throws PersistenceLayerException {
    List<CDOMReference<Skill>> refs = new ArrayList<>();
    ObjectMatchingReference<Skill, Boolean> omr = new ObjectMatchingReference<>("NONEXCLUSIVE", Skill.class, getAllRef(), ObjectKey.EXCLUSIVE, Boolean.FALSE);
    omr.returnIncludesNulls(true);
    refs.add(omr);
    ReferenceChoiceSet<Skill> rcs = new ReferenceChoiceSet<>(refs);
    ChoiceSet<Skill> cs = new ChoiceSet<>(getSubToken().getTokenName(), rcs);
    PersistentTransitionChoice<Skill> tc = new ConcretePersistentTransitionChoice<>(cs, FormulaFactory.ONE);
    primaryProf.addToListFor(ListKey.ADD, tc);
    tc.setChoiceActor(new ClassSkillChoiceActor(fighter, null));
    String[] unparsed = getToken().unparse(primaryContext, primaryProf);
    expectSingle(unparsed, getSubTokenName() + '|' + "NONEXCLUSIVE");
}
Also used : ReferenceChoiceSet(pcgen.cdom.choiceset.ReferenceChoiceSet) ChoiceSet(pcgen.cdom.base.ChoiceSet) ArrayList(java.util.ArrayList) ConcretePersistentTransitionChoice(pcgen.cdom.base.ConcretePersistentTransitionChoice) Skill(pcgen.core.Skill) ClassSkillChoiceActor(pcgen.cdom.helper.ClassSkillChoiceActor) CDOMReference(pcgen.cdom.base.CDOMReference) ObjectMatchingReference(pcgen.cdom.reference.ObjectMatchingReference) ReferenceChoiceSet(pcgen.cdom.choiceset.ReferenceChoiceSet) Test(org.junit.Test)

Example 15 with ReferenceChoiceSet

use of pcgen.cdom.choiceset.ReferenceChoiceSet in project pcgen by PCGen.

the class ClassSkillsTokenTest method testUnparseExclusive.

@Test
public void testUnparseExclusive() throws PersistenceLayerException {
    List<CDOMReference<Skill>> refs = new ArrayList<>();
    ObjectMatchingReference<Skill, Boolean> omr = new ObjectMatchingReference<>("EXCLUSIVE", Skill.class, getAllRef(), ObjectKey.EXCLUSIVE, Boolean.TRUE);
    omr.returnIncludesNulls(true);
    refs.add(omr);
    ReferenceChoiceSet<Skill> rcs = new ReferenceChoiceSet<>(refs);
    ChoiceSet<Skill> cs = new ChoiceSet<>(getSubToken().getTokenName(), rcs);
    PersistentTransitionChoice<Skill> tc = new ConcretePersistentTransitionChoice<>(cs, FormulaFactory.ONE);
    primaryProf.addToListFor(ListKey.ADD, tc);
    tc.setChoiceActor(new ClassSkillChoiceActor(fighter, null));
    String[] unparsed = getToken().unparse(primaryContext, primaryProf);
    expectSingle(unparsed, getSubTokenName() + '|' + "EXCLUSIVE");
}
Also used : ReferenceChoiceSet(pcgen.cdom.choiceset.ReferenceChoiceSet) ChoiceSet(pcgen.cdom.base.ChoiceSet) ArrayList(java.util.ArrayList) ConcretePersistentTransitionChoice(pcgen.cdom.base.ConcretePersistentTransitionChoice) Skill(pcgen.core.Skill) ClassSkillChoiceActor(pcgen.cdom.helper.ClassSkillChoiceActor) CDOMReference(pcgen.cdom.base.CDOMReference) ObjectMatchingReference(pcgen.cdom.reference.ObjectMatchingReference) ReferenceChoiceSet(pcgen.cdom.choiceset.ReferenceChoiceSet) Test(org.junit.Test)

Aggregations

ChoiceSet (pcgen.cdom.base.ChoiceSet)21 ReferenceChoiceSet (pcgen.cdom.choiceset.ReferenceChoiceSet)21 ArrayList (java.util.ArrayList)19 CDOMReference (pcgen.cdom.base.CDOMReference)19 ConcretePersistentTransitionChoice (pcgen.cdom.base.ConcretePersistentTransitionChoice)18 Skill (pcgen.core.Skill)13 Test (org.junit.Test)12 ClassSkillChoiceActor (pcgen.cdom.helper.ClassSkillChoiceActor)12 ObjectMatchingReference (pcgen.cdom.reference.ObjectMatchingReference)10 StringTokenizer (java.util.StringTokenizer)9 Formula (pcgen.base.formula.Formula)8 ParsingSeparator (pcgen.base.text.ParsingSeparator)6 ParseResult (pcgen.rules.persistence.token.ParseResult)6 ConcreteTransitionChoice (pcgen.cdom.base.ConcreteTransitionChoice)3 ClassSkillList (pcgen.cdom.list.ClassSkillList)2 CDOMListObject (pcgen.cdom.base.CDOMListObject)1 NonInteractive (pcgen.cdom.base.NonInteractive)1 Ungranted (pcgen.cdom.base.Ungranted)1 ModifyChoiceDecorator (pcgen.cdom.choiceset.ModifyChoiceDecorator)1 CNAbility (pcgen.cdom.content.CNAbility)1