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
+263
View File
@@ -612,6 +612,269 @@ input[type='radio'] {
animation: rollPop 0.4s ease-out;
}
/* ---------------------------------------------------------------------- */
/* Dice (components/dice/Die.tsx): each die drawn as its own shape. It */
/* tumbles in, flickering through faces, and lands on what it rolled. */
/* ---------------------------------------------------------------------- */
.dice-row {
display: inline-flex;
flex-wrap: wrap;
gap: 0.35rem;
align-items: flex-end;
justify-content: center;
}
.die {
position: relative;
display: inline-flex;
flex-direction: column;
align-items: center;
filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.55));
}
.die-body {
fill: #2b2212;
stroke: var(--accent);
stroke-width: 4;
}
.die-facet {
stroke: var(--accent);
stroke-width: 1.5;
opacity: 0.35;
}
.die-face {
font-family: var(--font-display);
font-weight: 700;
fill: var(--accent-strong);
paint-order: stroke;
stroke: #1a140a;
stroke-width: 5;
}
.die-kind {
font-size: 0.6rem;
letter-spacing: 0.06em;
text-transform: uppercase;
color: var(--text-dim);
line-height: 1;
}
/* Each kind of die has its own tint, as a set of real dice might. */
.die-d4 .die-body { fill: #2a1d1d; }
.die-d6 .die-body { fill: #2b2212; }
.die-d8 .die-body { fill: #1c2a22; }
.die-d10 .die-body { fill: #1b2431; }
.die-d12 .die-body { fill: #2a1f31; }
.die-d20 .die-body { fill: #33260f; }
.die.is-rolling {
animation-name: dieTumble;
animation-timing-function: cubic-bezier(0.2, 0.7, 0.3, 1);
animation-fill-mode: both;
}
.die.is-rolling .die-face {
opacity: 0.75;
}
.die.is-landed {
animation: dieLand 0.28s ease-out;
}
.die.is-dropped {
opacity: 0.4;
}
.die.is-dropped .die-face {
text-decoration: line-through;
}
.die.is-minus .die-body {
stroke: var(--danger-strong);
}
.die.is-crit .die-body {
stroke: var(--success-strong);
fill: #20331a;
}
.die.is-crit {
filter: drop-shadow(0 0 10px rgba(122, 178, 102, 0.9));
animation: dieLand 0.28s ease-out, dieGlow 1.2s ease-in-out 0.28s 2;
}
.die.is-crit .die-face {
fill: #c9f0b8;
}
.die.is-fumble .die-body {
stroke: var(--danger-strong);
fill: #331616;
}
.die.is-fumble {
filter: drop-shadow(0 0 8px rgba(216, 84, 84, 0.8));
animation: dieShake 0.45s ease-in-out;
}
.die.is-fumble .die-face {
fill: #f1b0b0;
}
@keyframes dieTumble {
0% {
transform: translate(-70px, -90px) rotate(-540deg) scale(0.5);
opacity: 0;
}
25% {
opacity: 1;
}
55% {
transform: translate(10px, 6px) rotate(-90deg) scale(1.08);
}
75% {
transform: translate(-4px, -10px) rotate(20deg) scale(1);
}
100% {
transform: translate(0, 0) rotate(0deg) scale(1);
}
}
@keyframes dieLand {
0% {
transform: scale(1.18);
}
100% {
transform: scale(1);
}
}
@keyframes dieGlow {
50% {
filter: drop-shadow(0 0 18px rgba(122, 178, 102, 1));
}
}
@keyframes dieShake {
20% {
transform: translateX(-4px) rotate(-6deg);
}
40% {
transform: translateX(4px) rotate(5deg);
}
60% {
transform: translateX(-3px) rotate(-3deg);
}
80% {
transform: translateX(2px) rotate(2deg);
}
}
/* The total, and what goes with it, appear once the dice have landed. */
.roll-reveal {
animation: rollReveal 0.35s ease-out both;
}
@keyframes rollReveal {
from {
opacity: 0;
transform: scale(0.6);
}
to {
opacity: 1;
transform: scale(1);
}
}
.dice-stage {
display: flex;
flex-direction: column;
align-items: center;
gap: 0.3rem;
width: 100%;
}
.dice-tabs {
display: flex;
gap: 0.4rem;
}
.dice-tabs .die-btn {
padding: 0.4rem 0.8rem;
}
.dice-entry {
padding: 0.6rem;
border: 1px dashed var(--accent);
border-radius: var(--radius);
background: var(--bg-inset);
}
.dice-entry-die {
display: flex;
flex-direction: column;
gap: 0.15rem;
}
.dice-error {
color: var(--danger-strong);
font-size: 0.9rem;
margin: 0.5rem 0 0;
}
/* A roll as a line of the table's feed (components/RollFeed.tsx). */
.roll-feed {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.roll-line {
padding: 0.45rem 0.6rem;
border: 1px solid var(--border-soft);
border-left: 3px solid var(--accent);
border-radius: 6px;
background: var(--bg-inset);
text-align: left;
}
.roll-line.is-crit {
border-left-color: var(--success-strong);
}
.roll-line.is-fumble {
border-left-color: var(--danger-strong);
}
.roll-line-head {
display: flex;
justify-content: space-between;
gap: 0.5rem;
font-size: 0.88rem;
}
.roll-line-body {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 0.4rem;
margin: 0.25rem 0;
}
.roll-line-body .dice-row {
justify-content: flex-start;
}
.roll-line-total {
font-size: 1.5rem;
color: var(--accent-strong);
}
.roll-line-tags {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.3rem;
font-size: 0.75rem;
}
.roll-line-tags .badge {
font-size: 0.68rem;
}
/* Somebody else's roll, shown beside the dice button as it lands. */
.dice-incoming {
position: fixed;
bottom: 1.25rem;
left: calc(1.25rem + 60px + 0.6rem);
z-index: 84;
width: min(300px, calc(100vw - 6.5rem));
padding: 0;
border: none;
background: none;
color: var(--text);
font-family: var(--font-body);
cursor: pointer;
animation: toastIn 0.25s ease-out;
}
.dice-incoming .roll-line {
border-color: var(--accent);
background: linear-gradient(180deg, #1c160d 0%, #120e08 100%);
box-shadow: var(--shadow-deep);
}
@media (prefers-reduced-motion: reduce) {
.die.is-rolling,
.die.is-landed,
.die.is-crit,
.die.is-fumble,
.roll-reveal,
.dice-incoming {
animation: none;
}
}
/* Quick stats drawer */
.drawer-backdrop {
position: fixed;