/** * Set the spell book to hold any new known spells. * * @param bookName The name of the new default spell book. */ @Override public void setDefaultSpellBook(String bookName) { SpellBook book = charDisplay.getSpellBookByName(bookName); if (book == null || book.getType() != SpellBook.TYPE_SPELL_BOOK) { return; } pc.setSpellBookNameToAutoAddKnown(bookName); defaultSpellBook.set(bookName); }
/** Construct the list of spells the character knows, has prepared or has in a spell book. */ private void buildKnownPreparedNodes() { allKnownSpellNodes.clearContents(); knownSpellNodes.clearContents(); bookSpellNodes.clearContents(); preparedSpellNodes.clearContents(); // Ensure spell information is up to date pc.getSpellList(); // Scan character classes for spell classes List<PCClass> classList = getCharactersSpellcastingClasses(); List<PObject> pobjList = new ArrayList<>(classList); // Include spells from race etc pobjList.add(charDisplay.getRace()); // Look at each spell on each spellcasting class for (PObject pcClass : pobjList) { buildKnownPreparedSpellsForCDOMObject(pcClass); } spellBooks.clear(); spellBookNames.clearContents(); for (SpellBook spellBook : charDisplay.getSpellBooks()) { if (spellBook.getType() == SpellBook.TYPE_PREPARED_LIST) { DummySpellNodeImpl spellListNode = new DummySpellNodeImpl(getRootNode(spellBook.getName())); preparedSpellLists.add(spellListNode); addDummyNodeIfSpellListEmpty(spellBook.getName()); } else if (spellBook.getType() == SpellBook.TYPE_SPELL_BOOK) { DummySpellNodeImpl spellListNode = new DummySpellNodeImpl(getRootNode(spellBook.getName())); spellBooks.add(spellListNode); addDummyNodeIfSpellBookEmpty(spellBook.getName()); spellBookNames.addElement(spellBook.getName()); } } }