use of pcgen.cdom.helper.AvailableSpell in project pcgen by PCGen.
the class KnownSpellInputFacet 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)) {
Boolean known = apo.getAssociation(AssociationKey.KNOWN);
if ((known == null) || !known.booleanValue()) {
continue;
}
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);
conditionallyKnownSpellFacet.add(id, as, cdo);
}
} else {
for (Spell spell : spells) {
knownSpellFacet.add(id, spelllist, lvl, spell, cdo);
}
}
}
}
}
use of pcgen.cdom.helper.AvailableSpell in project pcgen by PCGen.
the class SpellBuilderFacadeImpl method processLevelChange.
/**
* Update lists that depend on the selected level of spell
* e.g. the list of spells
*/
private void processLevelChange() {
int baseSpellLevel = spellLevel.get();
// List of available spells
List<Spell> spellsOfLevel = new ArrayList<>();
for (AvailableSpell availSpell : classSpells) {
if (availSpell.getLevel() == baseSpellLevel) {
spellsOfLevel.add(availSpell.getSpell());
}
}
Globals.sortPObjectListByName(spellsOfLevel);
availSpells.setContents(spellsOfLevel);
InfoFacade selSpell = spell.get();
if (selSpell == null || !spellsOfLevel.contains(selSpell)) {
Spell newSpell = null;
if (!spellsOfLevel.isEmpty()) {
newSpell = spellsOfLevel.get(0);
}
selectSpell(newSpell);
}
// Spell type
List<String> spellTypeList = getSpellTypeList();
availSpellTypes.setContents(spellTypeList);
spellType.set(spellTypeList.get(0));
}
use of pcgen.cdom.helper.AvailableSpell in project pcgen by PCGen.
the class SpellBuilderFacadeImpl method setClass.
@Override
public void setClass(InfoFacade classFacade) {
pcClass.set(classFacade);
if (classFacade instanceof Domain) {
spellList = ((Domain) classFacade).get(ObjectKey.DOMAIN_SPELLLIST);
} else {
spellList = ((PCClass) classFacade).get(ObjectKey.CLASS_SPELLLIST);
}
classSpells = new ArrayList<>();
for (AvailableSpell availSpell : masterAvailableSpellFacet.getAllSpellsInList(spellList, datasetID)) {
if (canCreateItem(availSpell.getSpell())) {
classSpells.add(availSpell);
}
}
if (spellLevel.get() == null) {
spellLevel.set(availSpellLevels.getElementAt(0));
}
processLevelChange();
}
use of pcgen.cdom.helper.AvailableSpell in project pcgen by PCGen.
the class ClassListToken method allow.
@Override
public boolean allow(PlayerCharacter pc, Spell spell) {
ClassSpellList list = spelllist.get();
DataSetID datasetID = pc.getCharID().getDatasetID();
for (AvailableSpell availSpell : masterAvailableSpellFacet.getMatchingSpellsInList(list, datasetID, spell)) {
int level = availSpell.getLevel();
if (level >= 0 && allow(pc, level, "", spell, list)) {
return true;
}
}
return false;
}
use of pcgen.cdom.helper.AvailableSpell in project pcgen by PCGen.
the class DomainListToken method allow.
@Override
public boolean allow(PlayerCharacter pc, Spell spell) {
DomainSpellList list = spelllist.get();
DataSetID datasetID = pc.getCharID().getDatasetID();
for (AvailableSpell availSpell : masterAvailableSpellFacet.getMatchingSpellsInList(list, datasetID, spell)) {
int level = availSpell.getLevel();
if (level >= 0 && allow(pc, level, "", spell, list)) {
return true;
}
}
return false;
}
Aggregations