Search in sources :

Example 1 with CDOMList

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

the class AvailableSpellInputFacet method dataAdded.

/**
	 * Triggered when one of the Facets to which ConditionallyKnownSpellFacet
	 * listens fires a DataFacetChangeEvent to indicate a CDOMObject was added
	 * to a Player Character.
	 * 
	 * @param dfce
	 *            The DataFacetChangeEvent containing the information about the
	 *            change
	 * 
	 * @see pcgen.cdom.facet.event.DataFacetChangeListener#dataAdded(pcgen.cdom.facet.event.DataFacetChangeEvent)
	 */
@Override
public void dataAdded(DataFacetChangeEvent<CharID, CDOMObject> dfce) {
    CDOMObject cdo = dfce.getCDOMObject();
    Collection<CDOMReference<? extends CDOMList<?>>> listrefs = cdo.getModifiedLists();
    CharID id = dfce.getCharID();
    for (CDOMReference<? extends CDOMList<?>> ref : listrefs) {
        processListRef(id, cdo, ref);
    }
}
Also used : CDOMObject(pcgen.cdom.base.CDOMObject) CDOMList(pcgen.cdom.base.CDOMList) CharID(pcgen.cdom.enumeration.CharID) CDOMReference(pcgen.cdom.base.CDOMReference)

Example 2 with CDOMList

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

the class SpellSupportFacadeImpl method buildAvailableNodes.

/**
	 * Construct the list of available spells for the character. 
	 */
private void buildAvailableNodes() {
    availableSpellNodes.clearContents();
    // Scan character classes for spell classes
    List<PCClass> classList = getCharactersSpellcastingClasses();
    // Look at each spell on each spellcasting class
    for (PCClass pcClass : classList) {
        DoubleKeyMapToList<SpellFacade, String, SpellNode> existingSpells = buildExistingSpellMap(availableSpellNodes, pcClass);
        for (Spell spell : pc.getAllSpellsInLists(charDisplay.getSpellLists(pcClass))) {
            // Create SpellNodeImpl for each spell
            CharacterSpell charSpell = new CharacterSpell(pcClass, spell);
            SpellFacadeImplem spellImplem = new SpellFacadeImplem(pc, spell, charSpell, null);
            HashMapToList<CDOMList<Spell>, Integer> levelInfo = pc.getSpellLevelInfo(spell);
            for (CDOMList<Spell> spellList : charDisplay.getSpellLists(pcClass)) {
                List<Integer> levels = levelInfo.getListFor(spellList);
                if (levels != null) {
                    for (Integer level : levels) {
                        SpellNodeImpl node = new SpellNodeImpl(spellImplem, pcClass, String.valueOf(level), null);
                        if (!existingSpells.containsInList(spellImplem, node.getSpellLevel(), node)) {
                            // Add to list
                            availableSpellNodes.addElement(node);
                        }
                    }
                }
            }
        }
    }
}
Also used : PCClass(pcgen.core.PCClass) SpellSupportForPCClass(pcgen.core.SpellSupportForPCClass) Spell(pcgen.core.spell.Spell) CharacterSpell(pcgen.core.character.CharacterSpell) CharacterSpell(pcgen.core.character.CharacterSpell) CDOMList(pcgen.cdom.base.CDOMList) SpellFacade(pcgen.facade.core.SpellFacade)

Example 3 with CDOMList

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

the class KnownSpellInputFacet method dataAdded.

/**
	 * Triggered when one of the Facets to which ConditionallyKnownSpellFacet
	 * listens fires a DataFacetChangeEvent to indicate a CDOMObject was added
	 * to a Player Character.
	 * 
	 * @param dfce
	 *            The DataFacetChangeEvent containing the information about the
	 *            change
	 * 
	 * @see pcgen.cdom.facet.event.DataFacetChangeListener#dataAdded(pcgen.cdom.facet.event.DataFacetChangeEvent)
	 */
@Override
public void dataAdded(DataFacetChangeEvent<CharID, CDOMObject> dfce) {
    CDOMObject cdo = dfce.getCDOMObject();
    Collection<CDOMReference<? extends CDOMList<?>>> listrefs = cdo.getModifiedLists();
    CharID id = dfce.getCharID();
    for (CDOMReference<? extends CDOMList<?>> ref : listrefs) {
        processListRef(id, cdo, ref);
    }
}
Also used : CDOMObject(pcgen.cdom.base.CDOMObject) CDOMList(pcgen.cdom.base.CDOMList) CharID(pcgen.cdom.enumeration.CharID) CDOMReference(pcgen.cdom.base.CDOMReference)

Example 4 with CDOMList

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

the class SpellClassesTest method testDirect.

@Test
public void testDirect() throws PersistenceLayerException {
    ParseResult result = token.parseToken(context, sp, "Dragon=1");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    finishLoad();
    classFacet.addClass(id, dragon);
    classFacet.setLevel(id, dragon, 1);
    //Right now this is done in PCClass
    FacetLibrary.getFacet(SpellListFacet.class).add(id, dragon.get(ObjectKey.CLASS_SPELLLIST), dragon);
    pc.setDirty(true);
    HashMapToList<CDOMList<Spell>, Integer> map = availableSpellFacet.getSpellLevelInfo(id, sp);
    assertTrue(map.containsListFor(dragon.get(ObjectKey.CLASS_SPELLLIST)));
    assertEquals(1, map.getListFor(dragon.get(ObjectKey.CLASS_SPELLLIST)).size());
    assertEquals(1, map.getListFor(dragon.get(ObjectKey.CLASS_SPELLLIST)).get(0).intValue());
}
Also used : ParseResult(pcgen.rules.persistence.token.ParseResult) SpellListFacet(pcgen.cdom.facet.SpellListFacet) CDOMList(pcgen.cdom.base.CDOMList) Test(org.junit.Test) AbstractTokenModelTest(tokenmodel.testsupport.AbstractTokenModelTest)

Example 5 with CDOMList

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

the class SpellDomainsTest method testDirect.

@Test
public void testDirect() throws PersistenceLayerException {
    ParseResult result = token.parseToken(context, sp, "Source=1");
    if (result != ParseResult.SUCCESS) {
        result.printMessages();
        fail("Test Setup Failed");
    }
    finishLoad();
    classFacet.addClass(id, dragon);
    classFacet.setLevel(id, dragon, 1);
    domainInputFacet.add(id, domain, new ClassSource(dragon, 0));
    pc.setDirty(true);
    HashMapToList<CDOMList<Spell>, Integer> map = availableSpellFacet.getSpellLevelInfo(id, sp);
    assertTrue(map.containsListFor(domain.get(ObjectKey.DOMAIN_SPELLLIST)));
    assertEquals(1, map.getListFor(domain.get(ObjectKey.DOMAIN_SPELLLIST)).size());
    assertEquals(1, map.getListFor(domain.get(ObjectKey.DOMAIN_SPELLLIST)).get(0).intValue());
}
Also used : ParseResult(pcgen.rules.persistence.token.ParseResult) CDOMList(pcgen.cdom.base.CDOMList) ClassSource(pcgen.cdom.helper.ClassSource) Test(org.junit.Test) AbstractTokenModelTest(tokenmodel.testsupport.AbstractTokenModelTest)

Aggregations

CDOMList (pcgen.cdom.base.CDOMList)17 CDOMReference (pcgen.cdom.base.CDOMReference)10 Spell (pcgen.core.spell.Spell)10 ArrayList (java.util.ArrayList)6 AssociatedPrereqObject (pcgen.cdom.base.AssociatedPrereqObject)6 TreeSet (java.util.TreeSet)4 DomainSpellList (pcgen.cdom.list.DomainSpellList)4 HashSet (java.util.HashSet)3 TripleKeyMapToList (pcgen.base.util.TripleKeyMapToList)3 CDOMObject (pcgen.cdom.base.CDOMObject)3 ClassSpellList (pcgen.cdom.list.ClassSpellList)3 PCClass (pcgen.core.PCClass)3 CharacterSpell (pcgen.core.character.CharacterSpell)3 Set (java.util.Set)2 StringTokenizer (java.util.StringTokenizer)2 Test (org.junit.Test)2 MasterListInterface (pcgen.cdom.base.MasterListInterface)2 CharID (pcgen.cdom.enumeration.CharID)2 AvailableSpell (pcgen.cdom.helper.AvailableSpell)2 Prerequisite (pcgen.core.prereq.Prerequisite)2