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