Search in sources :

Example 6 with CDOMListObject

use of pcgen.cdom.base.CDOMListObject in project pcgen by PCGen.

the class SpellListTokenTest method testUnparseSingle.

@Test
public void testUnparseSingle() throws PersistenceLayerException {
    ClassSpellList wp1 = construct(primaryContext, "TestWP1");
    PersistentTransitionChoice<CDOMListObject<Spell>> tc = buildChoice(CDOMDirectSingleRef.getRef(wp1));
    primaryProf.put(ObjectKey.SPELLLIST_CHOICE, tc);
    String[] unparsed = getToken().unparse(primaryContext, primaryProf);
    expectSingle(unparsed, "1|TestWP1");
}
Also used : ClassSpellList(pcgen.cdom.list.ClassSpellList) CDOMListObject(pcgen.cdom.base.CDOMListObject) Test(org.junit.Test)

Example 7 with CDOMListObject

use of pcgen.cdom.base.CDOMListObject in project pcgen by PCGen.

the class SpellListTokenTest method testUnparseNullInList.

@Test
public void testUnparseNullInList() throws PersistenceLayerException {
    ClassSpellList wp1 = construct(primaryContext, "TestWP1");
    ReferenceChoiceSet<ClassSpellList> rcs = buildRCS(CDOMDirectSingleRef.getRef(wp1), null);
    PersistentTransitionChoice<CDOMListObject<Spell>> tc = buildTC(rcs);
    primaryProf.put(ObjectKey.SPELLLIST_CHOICE, tc);
    try {
        getToken().unparse(primaryContext, primaryProf);
        fail();
    } catch (NullPointerException e) {
    // Yep!
    }
}
Also used : ClassSpellList(pcgen.cdom.list.ClassSpellList) CDOMListObject(pcgen.cdom.base.CDOMListObject) Test(org.junit.Test)

Example 8 with CDOMListObject

use of pcgen.cdom.base.CDOMListObject in project pcgen by PCGen.

the class PCGVer2Creator method appendSpellListLines.

/*
	 * ###############################################################
	 * Spell List Information methods
	 * ###############################################################
	 */
/*
	 * #Spell List Information
	 * SPELLLIST:sourceclassname|spelllistentry|spelllistentry
	 */
private void appendSpellListLines(StringBuilder buffer) {
    for (PCClass pcClass : charDisplay.getClassSet()) {
        TransitionChoice<CDOMListObject<Spell>> csc = pcClass.get(ObjectKey.SPELLLIST_CHOICE);
        if (csc != null) {
            List<? extends CDOMList<Spell>> assocList = charDisplay.getSpellLists(pcClass);
            buffer.append(IOConstants.TAG_SPELLLIST).append(':');
            buffer.append(pcClass.getKeyName());
            for (CDOMList<Spell> spell : assocList) {
                buffer.append('|');
                if (ClassSpellList.class.equals(spell.getClass())) {
                    buffer.append("CLASS");
                } else {
                    buffer.append("DOMAIN");
                }
                buffer.append('.').append(spell.getLSTformat());
            }
            buffer.append(IOConstants.LINE_SEP);
        }
    }
}
Also used : PCClass(pcgen.core.PCClass) Spell(pcgen.core.spell.Spell) CharacterSpell(pcgen.core.character.CharacterSpell) CDOMListObject(pcgen.cdom.base.CDOMListObject)

Aggregations

CDOMListObject (pcgen.cdom.base.CDOMListObject)8 Test (org.junit.Test)4 ClassSpellList (pcgen.cdom.list.ClassSpellList)4 Formula (pcgen.base.formula.Formula)2 ChoiceSet (pcgen.cdom.base.ChoiceSet)2 Spell (pcgen.core.spell.Spell)2 ArrayList (java.util.ArrayList)1 StringTokenizer (java.util.StringTokenizer)1 AssociatedPrereqObject (pcgen.cdom.base.AssociatedPrereqObject)1 CDOMReference (pcgen.cdom.base.CDOMReference)1 ConcretePersistentTransitionChoice (pcgen.cdom.base.ConcretePersistentTransitionChoice)1 ConcreteTransitionChoice (pcgen.cdom.base.ConcreteTransitionChoice)1 PrimitiveChoiceSet (pcgen.cdom.base.PrimitiveChoiceSet)1 ReferenceChoiceSet (pcgen.cdom.choiceset.ReferenceChoiceSet)1 SpellReferenceChoiceSet (pcgen.cdom.choiceset.SpellReferenceChoiceSet)1 VariableKey (pcgen.cdom.enumeration.VariableKey)1 ArmorProfProvider (pcgen.cdom.helper.ArmorProfProvider)1 ShieldProfProvider (pcgen.cdom.helper.ShieldProfProvider)1 WeaponProfProvider (pcgen.cdom.helper.WeaponProfProvider)1 PCClass (pcgen.core.PCClass)1