Files
5etools-mirror-2.github.io/js/dmscreen/dmscreen-util.js
TheGiddyLimit 8117ebddc5 v1.198.1
2024-01-01 19:34:49 +00:00

26 lines
1.0 KiB
JavaScript

export class DmScreenUtil {
// FIXME(Future) switch to a better interface than `data`
static $getPanelDataElements ({board, type, selector = ".dm__data-anchor"}) {
return board.getPanelsByType(type)
.flatMap(it => it.tabDatas.filter(td => td.type === type).map(td => td.$content.find(selector)));
}
/* -------------------------------------------- */
static async pGetScaledCreature ({name, source, scaledCr, scaledSummonSpellLevel, scaledSummonClassLevel}) {
const mon = await DataLoader.pCacheAndGet(
UrlUtil.PG_BESTIARY,
source,
UrlUtil.URL_TO_HASH_BUILDER[UrlUtil.PG_BESTIARY]({name: name, source: source}),
);
if (scaledCr == null && scaledSummonSpellLevel == null && scaledSummonClassLevel == null) return mon;
if (scaledCr != null) return ScaleCreature.scale(mon, scaledCr);
if (scaledSummonSpellLevel != null) return ScaleSpellSummonedCreature.scale(mon, scaledCr);
if (scaledSummonClassLevel != null) return ScaleClassSummonedCreature.scale(mon, scaledCr);
throw new Error(`Should never occur!`);
}
}