52 lines
1.7 KiB
JavaScript
52 lines
1.7 KiB
JavaScript
|
|
export class SoSUtility {
|
|
|
|
/* -------------------------------------------- */
|
|
static async preloadHandlebarsTemplates() {
|
|
|
|
const templatePaths = [
|
|
'systems/foundryvtt-shadows-over-sol/templates/actor-sheet.html',
|
|
'systems/foundryvtt-shadows-over-sol/templates/editor-notes-gm.html',
|
|
'systems/foundryvtt-shadows-over-sol/templates/stat-option-list.html',
|
|
'systems/foundryvtt-shadows-over-sol/templates/stat-name-list.html',
|
|
|
|
'systems/foundryvtt-shadows-over-sol/templates/item-sheet.html',
|
|
'systems/foundryvtt-shadows-over-sol/templates/item-geneline-sheet.html',
|
|
'systems/foundryvtt-shadows-over-sol/templates/item-subculture-sheet.html',
|
|
|
|
'systems/foundryvtt-shadows-over-sol/templates/dialog-flip.html'
|
|
]
|
|
return loadTemplates(templatePaths);
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
static fillRange (start, end) {
|
|
return Array(end - start + 1).fill().map((item, index) => start + index);
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
static async loadCompendiumNames(compendium) {
|
|
const pack = game.packs.get(compendium);
|
|
let competences;
|
|
await pack.getIndex().then(index => competences = index);
|
|
return competences;
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
static async loadCompendium(compendium, filter = item => true) {
|
|
let compendiumItems = await SoSUtility.loadCompendiumNames(compendium);
|
|
|
|
const pack = game.packs.get(compendium);
|
|
let list = [];
|
|
for (let compendiumItem of compendiumItems) {
|
|
await pack.getEntity(compendiumItem._id).then(it => {
|
|
const item = it.data;
|
|
if (filter(item)) {
|
|
list.push(item);
|
|
}
|
|
});
|
|
};
|
|
return list;
|
|
}
|
|
|
|
} |