/**
   * Create a new instance of SpellSupportFacadeImpl to manage the display and update of a
   * character's spells.
   *
   * @param pc The character we are managing.
   * @param delegate The delegate class for UI display.
   * @param dataSet The current data being used.
   * @param todoManager The user tasks tracker.
   * @param pcFacade The character facade.
   */
  public SpellSupportFacadeImpl(
      PlayerCharacter pc,
      UIDelegate delegate,
      DataSetFacade dataSet,
      TodoManager todoManager,
      CharacterFacadeImpl pcFacade) {
    this.pc = pc;
    this.infoFactory = pcFacade.getInfoFactory();
    this.charDisplay = pc.getDisplay();
    this.delegate = delegate;
    this.dataSet = dataSet;
    this.todoManager = todoManager;
    this.pcFacade = pcFacade;
    rootNodeMap = new HashMap<>();

    spellBookNames = new DefaultListFacade<>();
    defaultSpellBook = new DefaultReferenceFacade<>(charDisplay.getSpellBookNameToAutoAddKnown());

    availableSpellNodes = new DefaultListFacade<>();
    buildAvailableNodes();
    allKnownSpellNodes = new DefaultListFacade<>();
    knownSpellNodes = new DefaultListFacade<>();
    preparedSpellNodes = new DefaultListFacade<>();
    bookSpellNodes = new DefaultListFacade<>();
    preparedSpellLists = new ArrayList<>();
    spellBooks = new ArrayList<>();
    buildKnownPreparedNodes();

    updateSpellsTodo();
  }
 /* (non-Javadoc)
  * @see pcgen.core.facade.SpellSupportFacade#removeKnownSpell(pcgen.core.facade.SpellSupportFacade.SpellNode)
  */
 @Override
 public void removeKnownSpell(SpellNode spell) {
   // TODO: This should also remove the spell from books and lists
   if (removeSpellFromCharacter(spell, Globals.getDefaultSpellBook())) {
     allKnownSpellNodes.removeElement(spell);
     knownSpellNodes.removeElement(spell);
   }
   updateSpellsTodo();
   pcFacade.refreshAvailableTempBonuses();
 }
 /* (non-Javadoc)
  * @see pcgen.core.facade.SpellSupportFacade#addKnownSpell(pcgen.core.facade.SpellSupportFacade.SpellNode)
  */
 @Override
 public void addKnownSpell(SpellNode spell) {
   SpellNode node = addSpellToCharacter(spell, Globals.getDefaultSpellBook(), new ArrayList<>());
   if (node != null) {
     allKnownSpellNodes.addElement(node);
     knownSpellNodes.addElement(node);
     if (!StringUtils.isEmpty(charDisplay.getSpellBookNameToAutoAddKnown())) {
       addToSpellBook(node, charDisplay.getSpellBookNameToAutoAddKnown());
     }
   }
   updateSpellsTodo();
   pcFacade.refreshAvailableTempBonuses();
 }