V1.26.0: dice that tumble, rolled by the server, seen by the DM

- Each die is drawn as its own shape, tumbles in and lands on its result;
  a natural 20 glows, a natural 1 shakes; respects reduced motion
- In a campaign the server makes every digital roll and keeps it
- The DM sees each roll as it lands: an "Everyone's rolls" tab in the
  roller, a pop-up beside the dice button, and a list on the encounter page
- Players see everyone's rolls or only their own, by the campaign setting;
  the DM can roll hidden
- Physical dice are typed in, one box per die, and checked; with "both",
  each person chooses in the roller
- game/dice.js: parsing, rolling, checking typed dice, critical damage

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-12 08:46:22 +02:00
co-authored by Claude Opus 5.5
parent c3f2b0dfa7
commit 8811f14732
22 changed files with 1345 additions and 167 deletions
@@ -0,0 +1,28 @@
-- Rolls made at the table's dice roller, kept so the DM can see each one.
-- CreateTable
CREATE TABLE "dice_rolls" (
"id" TEXT NOT NULL,
"campaignId" TEXT NOT NULL,
"userId" TEXT NOT NULL,
"rollerName" TEXT NOT NULL,
"label" TEXT,
"notation" TEXT NOT NULL,
"dice" JSONB NOT NULL,
"modifier" INTEGER NOT NULL DEFAULT 0,
"total" INTEGER NOT NULL,
"natural" INTEGER,
"mode" TEXT NOT NULL DEFAULT 'NORMAL',
"physical" BOOLEAN NOT NULL DEFAULT false,
"hidden" BOOLEAN NOT NULL DEFAULT false,
"encounterId" TEXT,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "dice_rolls_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "dice_rolls_campaignId_createdAt_idx" ON "dice_rolls"("campaignId", "createdAt");
-- AddForeignKey
ALTER TABLE "dice_rolls" ADD CONSTRAINT "dice_rolls_campaignId_fkey" FOREIGN KEY ("campaignId") REFERENCES "campaigns"("id") ON DELETE CASCADE ON UPDATE CASCADE;
+30
View File
@@ -290,10 +290,40 @@ model Campaign {
saleOffers SaleOffer[]
notes Note[]
locations Location[]
diceRolls DiceRoll[]
@@map("campaigns")
}
// A roll made at the table's dice roller, kept so the table (and above all
// the DM) can see it. Digital rolls are made by the server; physical ones are
// typed in and checked against their dice. Who sees a roll follows the
// campaign's rollVisibility; a `hidden` one is the DM's alone.
model DiceRoll {
id String @id @default(cuid())
campaignId String
userId String
rollerName String // who rolled, as shown: kept so a roll outlives a renamed account
label String? // what it was for: "Aria: Stealth"
notation String // "1d20+3", "2d6+1d8+2"
// Every die, in order: [{ sides, value, kept, sign }]. `kept` is false for
// the d20 that advantage or disadvantage dropped.
dice Json
modifier Int @default(0)
total Int
natural Int? // the d20 that counted, for a roll of a single d20
mode String @default("NORMAL") // NORMAL | ADVANTAGE | DISADVANTAGE
physical Boolean @default(false) // rolled at the table and typed in
hidden Boolean @default(false) // the DM's alone
encounterId String?
createdAt DateTime @default(now())
campaign Campaign @relation(fields: [campaignId], references: [id], onDelete: Cascade)
@@index([campaignId, createdAt])
@@map("dice_rolls")
}
model Location {
id String @id @default(cuid())
campaignId String