Get most of the prompt to create new tables working, and keeping the Dice namespace restricted to a certain bucket type

This commit is contained in:
Oliver-Akins 2025-05-01 23:02:36 -06:00
parent 8c9fd1930a
commit dfc75fceaf
8 changed files with 73 additions and 19 deletions

View file

@ -1,4 +1,5 @@
import { Chart } from "chart.js";
import { diceSizeSorter } from "../utils/sorters/diceSize.mjs";
import { filePath } from "../consts.mjs";
import { Logger } from "../utils/Logger.mjs";
import { smallToLarge } from "../utils/sorters/smallToLarge.mjs";
@ -36,7 +37,7 @@ export class StatsViewer extends HandlebarsApplicationMixin(ApplicationV2) {
static PARTS = {
tableSelect: {
template: filePath(`templates/Apps/StatsViewer/tableSelect.hbs`),
template: filePath(`templates/Apps/common/tableSelect.hbs`),
},
dataFilters: {
template: filePath(`templates/Apps/StatsViewer/dataFilters.hbs`),
@ -138,6 +139,14 @@ export class StatsViewer extends HandlebarsApplicationMixin(ApplicationV2) {
ctx.tables = tableList;
const subtableList = subtables[this._selectedTable];
// Sort the subtables to be sane
if (this._selectedTable === `Dice`) {
subtableList?.sort(diceSizeSorter);
} else {
subtableList?.sort(smallToLarge);
}
if (!subtableList) {
this._selectedSubtable = undefined;
} else if (!subtableList.includes(this._selectedSubtable)) {