Search in sources :

Example 1 with AvailableSpell

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);
                }
            }
        }
    }
}
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 2 with AvailableSpell

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));
}
Also used : AvailableSpell(pcgen.cdom.helper.AvailableSpell) InfoFacade(pcgen.facade.core.InfoFacade) ArrayList(java.util.ArrayList) AvailableSpell(pcgen.cdom.helper.AvailableSpell) Spell(pcgen.core.spell.Spell)

Example 3 with AvailableSpell

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();
}
Also used : AvailableSpell(pcgen.cdom.helper.AvailableSpell) Domain(pcgen.core.Domain)

Example 4 with AvailableSpell

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;
}
Also used : AvailableSpell(pcgen.cdom.helper.AvailableSpell) ClassSpellList(pcgen.cdom.list.ClassSpellList) DataSetID(pcgen.cdom.enumeration.DataSetID)

Example 5 with AvailableSpell

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;
}
Also used : DomainSpellList(pcgen.cdom.list.DomainSpellList) AvailableSpell(pcgen.cdom.helper.AvailableSpell) DataSetID(pcgen.cdom.enumeration.DataSetID)

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