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:
+26
-8
@@ -10805,18 +10805,36 @@ Hooks.once("ready", async () => {
|
||||
for (const key of Object.keys(data)) {
|
||||
const t = data[key];
|
||||
if (!t?.name || game.tables.getName(t.name)) continue;
|
||||
await RollTable.create({
|
||||
name: t.name,
|
||||
description: t.description || "",
|
||||
formula: (t.formula || "1d6").replace("@stress", "0"),
|
||||
replacement: true,
|
||||
displayRoll: true,
|
||||
results: (t.results || []).map(r => ({
|
||||
const isD66 = (t.results || []).some(r => typeof r.key === "string");
|
||||
const results = (t.results || []).map(r => {
|
||||
if (typeof r.key === "string") {
|
||||
// d66 shape: key "t.o" → numeric to*1 range; compose display text
|
||||
const [tens, ones] = r.key.split(".").map(Number);
|
||||
const val = tens * 10 + ones;
|
||||
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,
|
||||
text: r.text,
|
||||
range: r.range,
|
||||
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++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user