Search in sources :

Example 6 with AvailableSpell

use of pcgen.cdom.helper.AvailableSpell in project pcgen by PCGen.

the class AvailableSpellInputFacet method processList.

private void processList(CharID id, CDOMList<Spell> spelllist, CDOMReference<? extends CDOMList<?>> listref, CDOMObject cdo) {
    for (CDOMReference<Spell> objref : cdo.getListMods((CDOMReference<? extends CDOMList<Spell>>) listref)) {
        for (AssociatedPrereqObject apo : cdo.getListAssociations(listref, objref)) {
            Collection<Spell> spells = objref.getContainedObjects();
            Integer lvl = apo.getAssociation(AssociationKey.SPELL_LEVEL);
            if (apo.hasPrerequisites()) {
                List<Prerequisite> prereqs = apo.getPrerequisiteList();
                for (Spell spell : spells) {
                    AvailableSpell as = new AvailableSpell(spelllist, spell, lvl);
                    as.addAllPrerequisites(prereqs);
                    conditionallyAvailableSpellFacet.add(id, as, cdo);
                }
            } else {
                for (Spell spell : spells) {
                    availableSpellFacet.add(id, spelllist, lvl, spell, cdo);
                }
            }
        }
    }
}
Also used : AvailableSpell(pcgen.cdom.helper.AvailableSpell) AvailableSpell(pcgen.cdom.helper.AvailableSpell) Spell(pcgen.core.spell.Spell) AssociatedPrereqObject(pcgen.cdom.base.AssociatedPrereqObject) Prerequisite(pcgen.core.prereq.Prerequisite)

Example 7 with AvailableSpell

use of pcgen.cdom.helper.AvailableSpell in project pcgen by PCGen.

the class MasterAvailableSpellFacet method getAllSpellsInList.

/**
	 * Retrieve a list of all spells for a particular spell list. 
	 * @param spellList The list to be queried
	 * @param dsID The owning data set
	 * @return The list of available spells.
	 */
public List<AvailableSpell> getAllSpellsInList(CDOMList<Spell> spellList, DataSetID dsID) {
    List<AvailableSpell> spellsInList = new ArrayList<>();
    Collection<AvailableSpell> spells = getSet(dsID);
    for (AvailableSpell as : spells) {
        if (as.getSpelllist().equals(spellList)) {
            spellsInList.add(as);
        }
    }
    return spellsInList;
}
Also used : AvailableSpell(pcgen.cdom.helper.AvailableSpell) ArrayList(java.util.ArrayList)

Example 8 with AvailableSpell

use of pcgen.cdom.helper.AvailableSpell in project pcgen by PCGen.

the class MasterAvailableSpellFacet method getMatchingSpellsInList.

/**
	 * Retrieve a list of any occurrence of a specific spell in the particular spell list. 
	 * @param spellList The list to be queried
	 * @param dsID The owning data set
	 * @param spell The spell to be found.
	 * @return The list of available spells.
	 */
public List<AvailableSpell> getMatchingSpellsInList(CDOMList<Spell> spellList, DataSetID dsID, Spell spell) {
    List<AvailableSpell> spellsInList = new ArrayList<>();
    Collection<AvailableSpell> spells = getSet(dsID);
    for (AvailableSpell as : spells) {
        if (as.getSpelllist().equals(spellList) && as.getSpell().equals(spell)) {
            spellsInList.add(as);
        }
    }
    return spellsInList;
}
Also used : AvailableSpell(pcgen.cdom.helper.AvailableSpell) ArrayList(java.util.ArrayList)

Example 9 with AvailableSpell

use of pcgen.cdom.helper.AvailableSpell in project pcgen by PCGen.

the class MasterAvailableSpellFacet method initialize.

/**
	 * Initializes the global lists of ClassSkillLists. This method only needs
	 * to be called once for each set of sources that are loaded.
	 */
@Override
public synchronized void initialize(LoadContext lc) {
    DataSetID dsID = lc.getDataSetID();
    MasterListInterface masterLists = SettingsHandler.getGame().getMasterLists();
    List<CDOMReference<CDOMList<Spell>>> useLists = new ArrayList<>();
    for (CDOMReference ref : masterLists.getActiveLists()) {
        Collection<CDOMList<Spell>> lists = ref.getContainedObjects();
        for (CDOMList<Spell> list : lists) {
            if ((list instanceof ClassSpellList) || (list instanceof DomainSpellList)) {
                useLists.add(ref);
                break;
            }
        }
    }
    for (CDOMReference<CDOMList<Spell>> ref : useLists) {
        for (Spell spell : masterLists.getObjects(ref)) {
            Collection<AssociatedPrereqObject> assoc = masterLists.getAssociations(ref, spell);
            for (AssociatedPrereqObject apo : assoc) {
                int lvl = apo.getAssociation(AssociationKey.SPELL_LEVEL);
                for (CDOMList<Spell> list : ref.getContainedObjects()) {
                    AvailableSpell as = new AvailableSpell(list, spell, lvl);
                    if (apo.hasPrerequisites()) {
                        as.addAllPrerequisites(apo.getPrerequisiteList());
                    }
                    add(dsID, as);
                }
            }
        }
    }
}
Also used : ArrayList(java.util.ArrayList) ClassSpellList(pcgen.cdom.list.ClassSpellList) DataSetID(pcgen.cdom.enumeration.DataSetID) AvailableSpell(pcgen.cdom.helper.AvailableSpell) Spell(pcgen.core.spell.Spell) DomainSpellList(pcgen.cdom.list.DomainSpellList) AvailableSpell(pcgen.cdom.helper.AvailableSpell) MasterListInterface(pcgen.cdom.base.MasterListInterface) CDOMList(pcgen.cdom.base.CDOMList) CDOMReference(pcgen.cdom.base.CDOMReference) AssociatedPrereqObject(pcgen.cdom.base.AssociatedPrereqObject)

Example 10 with AvailableSpell

use of pcgen.cdom.helper.AvailableSpell in project pcgen by PCGen.

the class SpellListToAvailableSpellFacet method dataRemoved.

@Override
public void dataRemoved(DataFacetChangeEvent<CharID, CDOMList<Spell>> dfce) {
    CharID id = dfce.getCharID();
    CDOMList<Spell> list = dfce.getCDOMObject();
    Collection<AvailableSpell> spells = masterAvailableSpellFacet.getSet(id.getDatasetID());
    for (AvailableSpell as : spells) {
        if (as.getSpelllist().equals(list)) {
            remove(id, as, this);
        }
    }
}
Also used : AvailableSpell(pcgen.cdom.helper.AvailableSpell) CharID(pcgen.cdom.enumeration.CharID) AvailableSpell(pcgen.cdom.helper.AvailableSpell) Spell(pcgen.core.spell.Spell)

Aggregations

AvailableSpell (pcgen.cdom.helper.AvailableSpell)11 Spell (pcgen.core.spell.Spell)6 ArrayList (java.util.ArrayList)4 AssociatedPrereqObject (pcgen.cdom.base.AssociatedPrereqObject)3 DataSetID (pcgen.cdom.enumeration.DataSetID)3 CharID (pcgen.cdom.enumeration.CharID)2 ClassSpellList (pcgen.cdom.list.ClassSpellList)2 DomainSpellList (pcgen.cdom.list.DomainSpellList)2 Prerequisite (pcgen.core.prereq.Prerequisite)2 CDOMList (pcgen.cdom.base.CDOMList)1 CDOMReference (pcgen.cdom.base.CDOMReference)1 MasterListInterface (pcgen.cdom.base.MasterListInterface)1 Domain (pcgen.core.Domain)1 InfoFacade (pcgen.facade.core.InfoFacade)1