fix: d66 crit tables failed rolltable provisioning — handle key-shaped results with 1d6*10+1d6 formula

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-14 16:14:30 +01:00
co-authored by Claude Fable 5
parent 58b8c0a2e9
commit 5aff39cf75
+26 -8
View File
@@ -10805,18 +10805,36 @@ Hooks.once("ready", async () => {
for (const key of Object.keys(data)) { for (const key of Object.keys(data)) {
const t = data[key]; const t = data[key];
if (!t?.name || game.tables.getName(t.name)) continue; if (!t?.name || game.tables.getName(t.name)) continue;
await RollTable.create({ const isD66 = (t.results || []).some(r => typeof r.key === "string");
name: t.name, const results = (t.results || []).map(r => {
description: t.description || "", if (typeof r.key === "string") {
formula: (t.formula || "1d6").replace("@stress", "0"), // d66 shape: key "t.o" → numeric to*1 range; compose display text
replacement: true, const [tens, ones] = r.key.split(".").map(Number);
displayRoll: true, const val = tens * 10 + ones;
results: (t.results || []).map(r => ({ const tail = [r.effects, r.healing ? `Healing: ${r.healing}` : "",
r.recovery ? `Recovery: ${r.recovery}` : "",
r.timeLimit ? `⏱ ${r.timeLimit}` : ""].filter(Boolean).join(" — ");
return {
type: CONST.TABLE_RESULT_TYPES?.TEXT ?? 0,
text: `<strong>${r.name}${r.lethal ? " ☠" : ""}:</strong> ${tail}`,
range: [val, val],
weight: 1
};
}
return {
type: CONST.TABLE_RESULT_TYPES?.TEXT ?? 0, type: CONST.TABLE_RESULT_TYPES?.TEXT ?? 0,
text: r.text, text: r.text,
range: r.range, range: r.range,
weight: 1 weight: 1
})) };
});
await RollTable.create({
name: t.name,
description: t.description || "",
formula: isD66 ? "1d6 * 10 + 1d6" : (t.formula || "1d6").replace("@stress", "0"),
replacement: true,
displayRoll: true,
results
}); });
created++; created++;
} }