Skip to content

Commit

Permalink
Fix table label.
Browse files Browse the repository at this point in the history
  • Loading branch information
krbz999 committed Dec 1, 2024
1 parent a9c1ab9 commit e12b582
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions dnd5e_utils/random-spell.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,35 @@
*/

// The spell levels. Use 0 for cantrips.
const levels = [0, 1, 2, 3, 4];
const levels = new Set([0, 1, 2, 3, 4]);

/* ----------------------------------------------------- */

const name = `Random Spell (${CONFIG.DND5E.spellLevels[level]})`;
const spells = await dnd5e.applications.CompendiumBrowser.fetch(Item, {
types: new Set(["spell"]),
filters: [{k: "system.level", o: "in", v: levels}],
index: false,
sort: true
sort: true,
types: new Set(["spell"]),
});

const resultData = [];
for (const [i, spell] of spells.entries()) {
resultData.push({
range: [i + 1, i + 1],
weight: 1,
documentId: spell.id,
documentCollection: spell.pack,
documentId: spell.id,
drawn: false,
img: spell.img,
range: [i + 1, i + 1],
text: spell.name,
type: CONST.TABLE_RESULT_TYPES.COMPENDIUM,
weight: 1,
});
}

const table = new RollTable.implementation({
name: name,
formula: `1d${resultData.length}`,
name: "Random Spell",
results: resultData,
formula: `1d${resultData.length}`
});

table.draw();

0 comments on commit e12b582

Please sign in to comment.