src/muncher/import.js
/**
 * This adds magic item spells to a world,
 */
This adds magic item spells to a world.
This adds magic item spells to a world .
async function addMagicItemSpells(input) {
  const itemSpells = await updateFolderItems("itemSpells", input);
  input.inventory.forEach((item) => {
    if (item.flags.magicitems.spells) {
      for (let [i, spell] of Object.entries(item.flags.magicitems.spells)) {
        const itemSpell = itemSpells.find((item) => item.name === spell.name);
        if (itemSpell) {
          for (const [key, value] of Object.entries(itemSpell)) {
            item.flags.magicitems.spells[i][key] = value;
          }
        } else if (!game.user.can("ITEM_CREATE")) {
          ui.notifications.warn(`Magic Item ${item.name} cannot be enriched because of lacking player permissions`);
        }
      }
    }
  });
}
async function addMagicItemSpells ( input ) { const itemSpells = await updateFolderItems ( "itemSpells" , input ) ; input . inventory . forEach ( ( item ) => { if ( item . flags . magicitems . spells ) { for ( let [ i , spell ] of Object . entries ( item . flags . magicitems . spells ) ) { const itemSpell = itemSpells . find ( ( item ) => item . name === spell . name ) ; if ( itemSpell ) { for ( const [ key , value ] of Object . entries ( itemSpell ) ) { item . flags . magicitems . spells [ i ] [ key ] = value ; } } else if ( ! game . user . can ( "ITEM_CREATE" ) ) { ui . notifications . warn ( ` ${ item . name } ` ) ; } } } } ) ; }
This adds magic item spells to a world,
This adds magic item spells to a world
// scan the inventory for each item with spells and copy the imported data over