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);
}
}
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);
}
}
}
}
}
}
}
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);
}
}
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());
}
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());
}
Aggregations