feat: add plain text dice roll detail

Introduces `plainDetail` to the dice engine to provide a non-HTML
version of the roll results. This allows components to display
the roll breakdown without needing to parse or render HTML.
This commit is contained in:
2026-07-06 18:18:16 +08:00
parent 0fc61e2f94
commit 1d0f2f7c3e
5 changed files with 62 additions and 41 deletions
+5 -2
View File
@@ -16,6 +16,7 @@ const schema = z.object({
result: z.object({
total: z.number(),
detail: z.string(),
plainDetail: z.string(),
pools: z.array(
z.object({
rolls: z.array(z.number()),
@@ -47,7 +48,7 @@ registerMessageType<RollPayload>({
schema,
defaultPayload: () => ({
notation: "1d20",
result: { total: 0, detail: "", pools: [] },
result: { total: 0, detail: "", plainDetail: "", pools: [] },
}),
render: (p) => {
const { result } = p;
@@ -60,7 +61,9 @@ registerMessageType<RollPayload>({
<span class="font-bold text-base">{result.total}</span>
</span>
</div>
{result.detail && <p class="text-xs text-gray-400">{result.detail}</p>}
{result.detail && (
<p class="text-xs text-gray-400" innerHTML={result.detail} />
)}
</div>
);
},