Compare commits
47 Commits
bdf18c2aea
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
| 3809bd5425 | |||
| 85bb30ae73 | |||
| 81065f1054 | |||
| 56944bc8d7 | |||
| eec4597fda | |||
| 8f912d9edb | |||
| b6e75cedc4 | |||
| 1e60656eac | |||
| 762e2d8300 | |||
| 2018b24029 | |||
| 5b901b0f98 | |||
| b18ae57779 | |||
| a19d13b1b5 | |||
| 456d22d985 | |||
| 6638622903 | |||
| f7730df3ec | |||
| bc894de505 | |||
| dbca035ca0 | |||
| c0f0e72967 | |||
| 0fa26ddf5a | |||
| 145af05471 | |||
| b65d25f66a | |||
| 598b8b9b6e | |||
| 3e4e26297b | |||
| 9d744c8674 | |||
| 06b6544653 | |||
| 86c4cf2639 | |||
| b1e5198880 | |||
| f282ac42fb | |||
| 393cd94f4b | |||
| ccb51d750a | |||
| a9fe71046c | |||
| a3d052d2c1 | |||
| 15e5869aec | |||
| c06ae53b4f | |||
| fd91bbe207 | |||
| e5f8f00832 | |||
| e035a99179 | |||
| 3d7d4c01f7 | |||
| cf81c25e6e | |||
| 97ad77f2a4 | |||
| 62439d2d28 | |||
| 57cb9a57ef | |||
| e975d7aa25 | |||
| 7c4754e506 | |||
| 070057afb3 | |||
| 6434256dfb |
@@ -3,12 +3,180 @@
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<title>Cluedo Sheet</title>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@400;700&family=IM+Fell+English:ital@0;1&display=swap" rel="stylesheet">
|
||||
|
||||
<!-- Fonts -->
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@400;700&family=IM+Fell+English:ital@0;1&display=swap"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
|
||||
<style>
|
||||
html,
|
||||
body {
|
||||
margin: 0;
|
||||
height: 100%;
|
||||
background: radial-gradient(
|
||||
ellipse at top,
|
||||
rgba(30, 30, 30, 0.95),
|
||||
#000
|
||||
);
|
||||
}
|
||||
|
||||
/* Splash Overlay */
|
||||
#app-splash {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 2147483647;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
background: radial-gradient(
|
||||
ellipse at top,
|
||||
rgba(30, 30, 30, 0.95),
|
||||
#000
|
||||
);
|
||||
overflow: hidden;
|
||||
opacity: 1;
|
||||
transition: opacity 260ms ease;
|
||||
}
|
||||
|
||||
#app-splash.hide {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* gold animated lines */
|
||||
#app-splash::before,
|
||||
#app-splash::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: -40%;
|
||||
background:
|
||||
linear-gradient(
|
||||
90deg,
|
||||
transparent,
|
||||
rgba(233, 216, 166, 0.18),
|
||||
transparent
|
||||
);
|
||||
transform: rotate(12deg);
|
||||
animation: goldSweep 1.6s linear infinite;
|
||||
opacity: 0.55;
|
||||
filter: blur(0.2px);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
#app-splash::after {
|
||||
transform: rotate(-12deg);
|
||||
animation-duration: 2.2s;
|
||||
opacity: 0.35;
|
||||
}
|
||||
|
||||
@keyframes goldSweep {
|
||||
0% { transform: translateX(-25%) rotate(12deg); }
|
||||
100% { transform: translateX(25%) rotate(12deg); }
|
||||
}
|
||||
|
||||
/* glassy card */
|
||||
.splash-card {
|
||||
position: relative;
|
||||
width: min(520px, 90vw);
|
||||
border-radius: 22px;
|
||||
padding: 18px 16px;
|
||||
background: rgba(20, 20, 22, 0.55);
|
||||
border: 1px solid rgba(233, 216, 166, 0.16);
|
||||
box-shadow: 0 18px 70px rgba(0,0,0,0.55);
|
||||
backdrop-filter: blur(10px);
|
||||
-webkit-backdrop-filter: blur(10px);
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.splash-card::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: linear-gradient(90deg, transparent, rgba(233,216,166,0.16), transparent);
|
||||
opacity: 0.45;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.splash-title {
|
||||
position: relative;
|
||||
font-family: "Cinzel Decorative", serif;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.06em;
|
||||
color: rgba(245, 239, 220, 0.92);
|
||||
font-size: 18px;
|
||||
line-height: 1.25;
|
||||
}
|
||||
|
||||
.splash-sub {
|
||||
position: relative;
|
||||
margin-top: 6px;
|
||||
font-family: "IM Fell English", serif;
|
||||
font-style: italic;
|
||||
color: rgba(233, 216, 166, 0.78);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
/* Loader */
|
||||
.loader {
|
||||
position: relative;
|
||||
margin: 14px auto 0;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border-radius: 999px;
|
||||
border: 2px solid rgba(233, 216, 166, 0.18);
|
||||
border-top-color: rgba(233, 216, 166, 0.92);
|
||||
animation: spin 0.85s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
0% { transform: rotate(0deg); }
|
||||
100% { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
/* tiny spark at bottom */
|
||||
.spark {
|
||||
position: relative;
|
||||
margin: 14px auto 0;
|
||||
width: 160px;
|
||||
height: 2px;
|
||||
border-radius: 999px;
|
||||
background: linear-gradient(90deg, transparent, rgba(233,216,166,0.65), transparent);
|
||||
opacity: 0.6;
|
||||
filter: blur(0.2px);
|
||||
animation: pulse 1.4s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0%, 100% { opacity: 0.35; transform: scaleX(0.92); }
|
||||
50% { opacity: 0.85; transform: scaleX(1.02); }
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- Theme-Key sofort setzen -->
|
||||
<script>
|
||||
try {
|
||||
const k = localStorage.getItem("hpTheme:guest") || "default";
|
||||
document.documentElement.setAttribute("data-theme", k);
|
||||
} catch {}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app-splash" aria-hidden="true">
|
||||
<div class="splash-card">
|
||||
<div class="splash-title">Zauber-Detektiv Notizbogen</div>
|
||||
<div class="splash-sub">Magie wird vorbereitet…</div>
|
||||
<div class="loader" aria-label="Laden"></div>
|
||||
<div class="spark"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.jsx"></script>
|
||||
</body>
|
||||
|
||||
BIN
frontend/public/player_cards/harry.png
Normal file
|
After Width: | Height: | Size: 265 KiB |
BIN
frontend/public/players/ginny.jpg
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
frontend/public/players/harry.jpg
Normal file
|
After Width: | Height: | Size: 3.0 KiB |
BIN
frontend/public/players/hermione.jpg
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
frontend/public/players/luna.jpg
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
frontend/public/players/neville.jpg
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
frontend/public/players/ron.jpg
Normal file
|
After Width: | Height: | Size: 14 KiB |
1089
frontend/src/App.jsx
379
frontend/src/AppLayout.css
Normal file
@@ -0,0 +1,379 @@
|
||||
/* frontend/src/AppLayout.css */
|
||||
html, body, #root {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.appRoot {
|
||||
height: 100vh;
|
||||
display: grid;
|
||||
|
||||
/* Links: flexibel | Rechts: Notes clamp */
|
||||
grid-template-columns: minmax(900px, 1fr) clamp(380px, 32vw, 520px);
|
||||
|
||||
gap: 14px;
|
||||
padding: 14px;
|
||||
box-sizing: border-box;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
/* LEFT COLUMN */
|
||||
.leftPane {
|
||||
overflow: visible;
|
||||
min-width: 0;
|
||||
display: grid;
|
||||
|
||||
/* Top | Main | HUD */
|
||||
grid-template-rows: 68px minmax(360px, 1fr) minmax(160px, 190px);
|
||||
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.topBarRow {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 14px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
/* MAIN: Tools | Board | PlayerRail */
|
||||
.mainRow {
|
||||
min-height: 0;
|
||||
overflow: visible;
|
||||
display: grid;
|
||||
|
||||
/* Tools bewusst schmaler, Board bekommt Bühne */
|
||||
grid-template-columns: 260px minmax(560px, 1fr) 92px;
|
||||
|
||||
gap: 14px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
/* Tools left of board */
|
||||
.leftTools {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
display: grid;
|
||||
align-content: start;
|
||||
}
|
||||
|
||||
.leftToolsRow {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 14px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
/* Board */
|
||||
.boardWrap {
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
border-radius: 22px;
|
||||
min-width: 0;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* Dice overlay: under board slightly right */
|
||||
.diceOverlay {
|
||||
position: absolute;
|
||||
overflow: visible;
|
||||
bottom: 14px;
|
||||
right: 18px;
|
||||
width: 220px;
|
||||
pointer-events: auto;
|
||||
opacity: 0.98;
|
||||
}
|
||||
|
||||
/* Player rail: right of board, before notes (tight) */
|
||||
.playerRail {
|
||||
min-height: 0;
|
||||
border-radius: 22px;
|
||||
border: 1px solid rgba(255,255,255,0.08);
|
||||
background: rgba(0,0,0,0.18);
|
||||
backdrop-filter: blur(10px);
|
||||
box-shadow: 0 16px 50px rgba(0,0,0,0.35);
|
||||
padding: 10px 8px;
|
||||
|
||||
display: grid;
|
||||
grid-template-rows: auto 1fr;
|
||||
justify-items: center;
|
||||
gap: 10px;
|
||||
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.playerRailInner {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: visible;
|
||||
border-radius: 18px;
|
||||
display: grid;
|
||||
justify-items: center;
|
||||
}
|
||||
|
||||
.playerRailTitle {
|
||||
font-weight: 900;
|
||||
font-size: 12px;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.playerRailList {
|
||||
min-height: 0;
|
||||
overflow: visible;
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
align-content: start;
|
||||
justify-items: center;
|
||||
padding-top: 4px;
|
||||
}
|
||||
|
||||
/* HUD */
|
||||
.playerHud {
|
||||
align-items: stretch;
|
||||
overflow: visible;
|
||||
display: grid;
|
||||
grid-template-columns: 1.1fr 1.7fr 1.1fr;
|
||||
gap: 14px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.playerHudMiddle {
|
||||
height: 100%;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
overflow: visible;
|
||||
display: grid;
|
||||
|
||||
/* Geheimkarten groß, Hilfkarte etwas kleiner */
|
||||
grid-template-columns: 1fr 0.78fr;
|
||||
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
/* RIGHT COLUMN */
|
||||
.notesPane {
|
||||
overflow: hidden;
|
||||
min-width: 0;
|
||||
display: grid;
|
||||
grid-template-rows: auto 1fr;
|
||||
}
|
||||
|
||||
.notesScroll {
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
padding-right: 4px;
|
||||
}
|
||||
|
||||
.diceOverlay {
|
||||
position: absolute;
|
||||
bottom: 14px;
|
||||
right: 18px;
|
||||
width: 220px;
|
||||
pointer-events: auto; /* ✅ damit Hover/Clicks für Würfel gehen */
|
||||
opacity: 0.98;
|
||||
}
|
||||
|
||||
/* ===== True 3D Cube Dice (transition-based roll) ===== */
|
||||
.die3d {
|
||||
transform-style: preserve-3d;
|
||||
will-change: transform;
|
||||
}
|
||||
|
||||
.die3d:hover:not(:disabled) {
|
||||
transform: translateY(-3px) rotateX(8deg) rotateY(-10deg);
|
||||
}
|
||||
|
||||
.dieCubeWrap {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
position: relative;
|
||||
transform-style: preserve-3d;
|
||||
}
|
||||
|
||||
.dieCube {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
transform-style: preserve-3d;
|
||||
|
||||
/* absolute angles (numbers are set in JS) */
|
||||
transform: rotateX(calc(var(--rx, 0) * 1deg)) rotateY(calc(var(--ry, 0) * 1deg));
|
||||
|
||||
/* default: snappy */
|
||||
transition: transform 260ms cubic-bezier(0.22, 1.0, 0.25, 1);
|
||||
}
|
||||
|
||||
.dieCube.rolling {
|
||||
/* roll duration */
|
||||
transition: transform 820ms cubic-bezier(0.18, 0.88, 0.22, 1);
|
||||
}
|
||||
|
||||
/* Faces: remove hard borders / inner rings */
|
||||
.dieFace {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
border-radius: 12px;
|
||||
border: none; /* ✅ no face border */
|
||||
background:
|
||||
radial-gradient(120% 120% at 25% 18%, rgba(255,255,255,0.14), rgba(0,0,0,0.40) 60%, rgba(0,0,0,0.72));
|
||||
box-shadow:
|
||||
inset 0 0 0 1px rgba(255,255,255,0.05), /* very subtle */
|
||||
inset 0 14px 24px rgba(255,255,255,0.04);
|
||||
display: grid;
|
||||
place-items: center;
|
||||
backface-visibility: hidden;
|
||||
}
|
||||
|
||||
/* face positions */
|
||||
.dieFace.front { transform: rotateY( 0deg) translateZ(22px); }
|
||||
.dieFace.back { transform: rotateY(180deg) translateZ(22px); }
|
||||
.dieFace.right { transform: rotateY( 90deg) translateZ(22px); }
|
||||
.dieFace.left { transform: rotateY(-90deg) translateZ(22px); }
|
||||
.dieFace.top { transform: rotateX( 90deg) translateZ(22px); }
|
||||
.dieFace.bottom { transform: rotateX(-90deg) translateZ(22px); }
|
||||
|
||||
/* pips */
|
||||
.pipGrid {
|
||||
width: 70%;
|
||||
height: 70%;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.pip {
|
||||
position: absolute;
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
border-radius: 999px;
|
||||
background: rgba(245,245,245,0.92);
|
||||
box-shadow: 0 3px 10px rgba(0,0,0,0.35), inset 0 1px 2px rgba(0,0,0,0.20);
|
||||
}
|
||||
|
||||
.specialIcon {
|
||||
font-size: 20px;
|
||||
line-height: 1;
|
||||
filter: drop-shadow(0 10px 18px rgba(0,0,0,0.55));
|
||||
}
|
||||
|
||||
/* Prevent clipping */
|
||||
.diceRow3d { overflow: visible; }
|
||||
|
||||
.dieCube.snap {
|
||||
transition: none !important;
|
||||
}
|
||||
|
||||
/* one face */
|
||||
.dieFace {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
border-radius: 12px;
|
||||
border: 1px solid rgba(255,255,255,0.10);
|
||||
background:
|
||||
radial-gradient(120% 120% at 25% 18%, rgba(255,255,255,0.14), rgba(0,0,0,0.40) 60%, rgba(0,0,0,0.72));
|
||||
box-shadow:
|
||||
inset 0 0 0 1px rgba(255,255,255,0.06),
|
||||
inset 0 12px 20px rgba(255,255,255,0.05);
|
||||
display: grid;
|
||||
place-items: center;
|
||||
backface-visibility: hidden;
|
||||
}
|
||||
|
||||
/* face positions */
|
||||
.dieFace.front { transform: rotateY( 0deg) translateZ(22px); }
|
||||
.dieFace.back { transform: rotateY(180deg) translateZ(22px); }
|
||||
.dieFace.right { transform: rotateY( 90deg) translateZ(22px); }
|
||||
.dieFace.left { transform: rotateY(-90deg) translateZ(22px); }
|
||||
.dieFace.top { transform: rotateX( 90deg) translateZ(22px); }
|
||||
.dieFace.bottom { transform: rotateX(-90deg) translateZ(22px); }
|
||||
|
||||
/* pips */
|
||||
.pipGrid {
|
||||
width: 70%;
|
||||
height: 70%;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.pip {
|
||||
position: absolute;
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
border-radius: 999px;
|
||||
background: rgba(245,245,245,0.92);
|
||||
box-shadow: 0 3px 10px rgba(0,0,0,0.35), inset 0 1px 2px rgba(0,0,0,0.20);
|
||||
}
|
||||
|
||||
/* special icon */
|
||||
.specialIcon {
|
||||
font-size: 20px;
|
||||
line-height: 1;
|
||||
filter: drop-shadow(0 10px 18px rgba(0,0,0,0.55));
|
||||
}
|
||||
|
||||
/* optional: subtle face ring tint via CSS var */
|
||||
.dieFace {
|
||||
box-shadow:
|
||||
inset 0 0 0 1px rgba(255,255,255,0.06),
|
||||
inset 0 0 0 2px var(--ring, rgba(255,255,255,0.00)),
|
||||
inset 0 12px 20px rgba(255,255,255,0.05);
|
||||
}
|
||||
|
||||
/* Roll animation */
|
||||
@keyframes dieRoll {
|
||||
0% {
|
||||
transform: translateY(0) rotateX(0deg) rotateY(0deg) rotateZ(0deg);
|
||||
}
|
||||
25% {
|
||||
transform: translateY(-6px) rotateX(220deg) rotateY(160deg) rotateZ(90deg);
|
||||
}
|
||||
55% {
|
||||
transform: translateY(0px) rotateX(520deg) rotateY(460deg) rotateZ(240deg);
|
||||
}
|
||||
100% {
|
||||
transform: translateY(-2px) rotateX(720deg) rotateY(720deg) rotateZ(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
.die3dRolling {
|
||||
animation: dieRoll 820ms cubic-bezier(0.2, 0.9, 0.25, 1) both;
|
||||
}
|
||||
|
||||
/* --- Responsive: shrink gracefully (no scroll outside notes) --- */
|
||||
@media (max-height: 860px) {
|
||||
.leftPane {
|
||||
grid-template-rows: 64px minmax(300px, 1fr) 150px;
|
||||
}
|
||||
.diceOverlay {
|
||||
bottom: 10px;
|
||||
right: 12px;
|
||||
width: 200px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 1440px) {
|
||||
.appRoot {
|
||||
grid-template-columns: minmax(820px, 1fr) clamp(360px, 34vw, 480px);
|
||||
}
|
||||
.mainRow {
|
||||
grid-template-columns: 240px minmax(520px, 1fr) 88px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 1280px) {
|
||||
.appRoot {
|
||||
grid-template-columns: 1fr clamp(340px, 36vw, 460px);
|
||||
}
|
||||
.mainRow {
|
||||
grid-template-columns: 220px minmax(480px, 1fr) 84px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 1180px) {
|
||||
/* ab hier wird’s eng: tools noch schmäler */
|
||||
.mainRow {
|
||||
grid-template-columns: 200px minmax(440px, 1fr) 82px;
|
||||
}
|
||||
}
|
||||
147
frontend/src/components/Dice/Dice3D.jsx
Normal file
@@ -0,0 +1,147 @@
|
||||
// frontend/src/components/Dice/Dice3D.jsx
|
||||
import React from "react";
|
||||
|
||||
export const cubeRotationForD6 = (value) => {
|
||||
switch (value) {
|
||||
case 1: return { rx: 0, ry: 0 };
|
||||
case 2: return { rx: -90, ry: 0 };
|
||||
case 3: return { rx: 0, ry: -90 };
|
||||
case 4: return { rx: 0, ry: 90 };
|
||||
case 5: return { rx: 90, ry: 0 };
|
||||
case 6: return { rx: 0, ry: 180 };
|
||||
default: return { rx: 0, ry: 0 };
|
||||
}
|
||||
};
|
||||
|
||||
export const PipFace = ({ value }) => {
|
||||
const pos = (gx, gy) => ({ left: `${gx * 50}%`, top: `${gy * 50}%` });
|
||||
|
||||
const faces = {
|
||||
1: [[1, 1]],
|
||||
2: [[0, 0], [2, 2]],
|
||||
3: [[0, 0], [1, 1], [2, 2]],
|
||||
4: [[0, 0], [2, 0], [0, 2], [2, 2]],
|
||||
5: [[0, 0], [2, 0], [1, 1], [0, 2], [2, 2]],
|
||||
6: [[0, 0], [0, 1], [0, 2], [2, 0], [2, 1], [2, 2]],
|
||||
};
|
||||
|
||||
const arr = faces[value] || faces[1];
|
||||
|
||||
return (
|
||||
<div className="pipGrid">
|
||||
{arr.map(([x, y], idx) => (
|
||||
<div
|
||||
key={idx}
|
||||
className="pip"
|
||||
style={{ ...pos(x, y), transform: "translate(-50%, -50%)" }}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export const DieShell = ({ children, rolling = false, onClick }) => {
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClick}
|
||||
className="die3d"
|
||||
style={{
|
||||
width: 64,
|
||||
height: 64,
|
||||
borderRadius: 18,
|
||||
border: "none",
|
||||
background: "transparent",
|
||||
boxShadow: "none",
|
||||
position: "relative",
|
||||
overflow: "visible",
|
||||
display: "grid",
|
||||
placeItems: "center",
|
||||
cursor: rolling ? "default" : "pointer",
|
||||
transition: "transform 160ms ease",
|
||||
padding: 0,
|
||||
outline: "none",
|
||||
}}
|
||||
disabled={rolling}
|
||||
>
|
||||
<div style={{ position: "relative", zIndex: 2 }}>{children}</div>
|
||||
</button>
|
||||
);
|
||||
};
|
||||
|
||||
export const DieD6 = ({ rolling, onClick, ax, ay, onDone, snap = false }) => {
|
||||
return (
|
||||
<DieShell rolling={rolling} onClick={onClick}>
|
||||
<div className="dieCubeWrap">
|
||||
<div
|
||||
className={`dieCube ${rolling ? "rolling" : ""}`}
|
||||
style={{ "--rx": ax, "--ry": ay }}
|
||||
onTransitionEnd={(e) => {
|
||||
if (e.propertyName !== "transform") return;
|
||||
if (rolling) onDone?.();
|
||||
}}
|
||||
>
|
||||
<div className="dieFace front"><PipFace value={1} /></div>
|
||||
<div className="dieFace back"><PipFace value={6} /></div>
|
||||
<div className="dieFace top"><PipFace value={2} /></div>
|
||||
<div className="dieFace bottom"><PipFace value={5} /></div>
|
||||
<div className="dieFace right"><PipFace value={3} /></div>
|
||||
<div className="dieFace left"><PipFace value={4} /></div>
|
||||
</div>
|
||||
</div>
|
||||
</DieShell>
|
||||
);
|
||||
};
|
||||
|
||||
export const HouseDie = ({ face, rolling, onClick, ax, ay, onDone, snap = false }) => {
|
||||
const faces = {
|
||||
gryffindor: { icon: "🦁", color: "#ef4444" },
|
||||
slytherin: { icon: "🐍", color: "#22c55e" },
|
||||
ravenclaw: { icon: "🦅", color: "#3b82f6" },
|
||||
hufflepuff: { icon: "🦡", color: "#facc15" },
|
||||
help: { icon: "🃏", color: "#f2d27a" },
|
||||
dark: { icon: "🌙", color: "rgba(255,255,255,0.85)" },
|
||||
};
|
||||
|
||||
const order = ["gryffindor", "slytherin", "ravenclaw", "hufflepuff", "help", "dark"];
|
||||
|
||||
return (
|
||||
<DieShell rolling={rolling} onClick={onClick}>
|
||||
<div className="dieCubeWrap">
|
||||
<div
|
||||
className={`dieCube ${rolling ? "rolling" : ""}`}
|
||||
style={{ "--rx": ax, "--ry": ay }}
|
||||
onTransitionEnd={(e) => {
|
||||
if (e.propertyName !== "transform") return;
|
||||
if (rolling) onDone?.();
|
||||
}}
|
||||
>
|
||||
{order.map((key, i) => {
|
||||
const item = faces[key];
|
||||
const faceClass =
|
||||
i === 0 ? "front" :
|
||||
i === 1 ? "top" :
|
||||
i === 2 ? "right" :
|
||||
i === 3 ? "left" :
|
||||
i === 4 ? "bottom" :
|
||||
"back";
|
||||
|
||||
return (
|
||||
<div key={key} className={`dieFace ${faceClass}`}>
|
||||
<div
|
||||
className="specialIcon"
|
||||
style={{
|
||||
color: item.color,
|
||||
textShadow: `0 0 18px ${item.color}55, 0 10px 22px rgba(0,0,0,0.55)`,
|
||||
}}
|
||||
>
|
||||
{item.icon}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</DieShell>
|
||||
);
|
||||
};
|
||||
188
frontend/src/components/Dice/DicePanel.jsx
Normal file
@@ -0,0 +1,188 @@
|
||||
// frontend/src/components/Dice/DicePanel.jsx
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import { stylesTokens } from "../../styles/theme";
|
||||
import { cubeRotationForD6, DieD6, HouseDie } from "./Dice/Dice3D.jsx";
|
||||
|
||||
export default function DicePanel({ onRoll }) {
|
||||
const LS_KEY = "hp_cluedo_dice_v1";
|
||||
|
||||
const [d1, setD1] = useState(4);
|
||||
const [d2, setD2] = useState(2);
|
||||
const [special, setSpecial] = useState("gryffindor");
|
||||
|
||||
const [a1, setA1] = useState({ x: 0, y: 90 });
|
||||
const [a2, setA2] = useState({ x: -90, y: 0 });
|
||||
const [as, setAs] = useState({ x: 0, y: 0 });
|
||||
|
||||
const [rolling, setRolling] = useState(false);
|
||||
const [snap, setSnap] = useState(false);
|
||||
|
||||
const specialFaces = ["gryffindor", "slytherin", "ravenclaw", "hufflepuff", "help", "dark"];
|
||||
const order = ["gryffindor", "slytherin", "ravenclaw", "hufflepuff", "help", "dark"];
|
||||
const randInt = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;
|
||||
|
||||
// roll bookkeeping
|
||||
const pendingRef = useRef(null);
|
||||
const rollIdRef = useRef(0);
|
||||
const doneForRollRef = useRef({ d1: false, d2: false, s: false });
|
||||
|
||||
// restore last
|
||||
useEffect(() => {
|
||||
try {
|
||||
const raw = localStorage.getItem(LS_KEY);
|
||||
if (!raw) return;
|
||||
const parsed = JSON.parse(raw);
|
||||
|
||||
if (parsed?.d1) setD1(parsed.d1);
|
||||
if (parsed?.d2) setD2(parsed.d2);
|
||||
if (parsed?.special) setSpecial(parsed.special);
|
||||
|
||||
if (parsed?.d1) {
|
||||
const r = cubeRotationForD6(parsed.d1);
|
||||
setA1({ x: r.rx, y: r.ry });
|
||||
}
|
||||
if (parsed?.d2) {
|
||||
const r = cubeRotationForD6(parsed.d2);
|
||||
setA2({ x: r.rx, y: r.ry });
|
||||
}
|
||||
if (parsed?.special) {
|
||||
const idx = Math.max(0, order.indexOf(parsed.special));
|
||||
const r = cubeRotationForD6(idx + 1);
|
||||
setAs({ x: r.rx, y: r.ry });
|
||||
}
|
||||
} catch {}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
try {
|
||||
localStorage.setItem(LS_KEY, JSON.stringify({ d1, d2, special }));
|
||||
} catch {}
|
||||
}, [d1, d2, special]);
|
||||
|
||||
const normalize360 = (n) => ((n % 360) + 360) % 360;
|
||||
|
||||
const rollTo = (currentAngles, targetBase) => {
|
||||
const spinX = 720 + randInt(0, 2) * 360;
|
||||
const spinY = 720 + randInt(0, 2) * 360;
|
||||
|
||||
const currX = normalize360(currentAngles.x);
|
||||
const currY = normalize360(currentAngles.y);
|
||||
|
||||
const dx = targetBase.rx - currX;
|
||||
const dy = targetBase.ry - currY;
|
||||
|
||||
return { x: currentAngles.x + spinX + dx, y: currentAngles.y + spinY + dy };
|
||||
};
|
||||
|
||||
const rollAll = () => {
|
||||
if (rolling) return;
|
||||
|
||||
const nd1 = randInt(1, 6);
|
||||
const nd2 = randInt(1, 6);
|
||||
const ns = specialFaces[randInt(0, specialFaces.length - 1)];
|
||||
|
||||
const r1 = cubeRotationForD6(nd1);
|
||||
const r2 = cubeRotationForD6(nd2);
|
||||
const rs = cubeRotationForD6(Math.max(0, order.indexOf(ns)) + 1);
|
||||
|
||||
pendingRef.current = { nd1, nd2, ns };
|
||||
|
||||
rollIdRef.current += 1;
|
||||
doneForRollRef.current = { d1: false, d2: false, s: false };
|
||||
|
||||
setRolling(true);
|
||||
|
||||
setA1((cur) => rollTo(cur, r1));
|
||||
setA2((cur) => rollTo(cur, r2));
|
||||
setAs((cur) => rollTo(cur, rs));
|
||||
};
|
||||
|
||||
const maybeCommit = () => {
|
||||
const flags = doneForRollRef.current;
|
||||
if (!flags.d1 || !flags.d2 || !flags.s) return;
|
||||
|
||||
const p = pendingRef.current;
|
||||
if (!p) return;
|
||||
|
||||
// ✅ rolling beenden
|
||||
setRolling(false);
|
||||
|
||||
// ✅ Ergebnis state setzen
|
||||
setD1(p.nd1);
|
||||
setD2(p.nd2);
|
||||
setSpecial(p.ns);
|
||||
|
||||
// ✅ Winkel auf kleine Basis normalisieren (ohne Transition)
|
||||
const r1 = cubeRotationForD6(p.nd1);
|
||||
const r2 = cubeRotationForD6(p.nd2);
|
||||
const rs = cubeRotationForD6(Math.max(0, order.indexOf(p.ns)) + 1);
|
||||
|
||||
setSnap(true);
|
||||
setA1({ x: r1.rx, y: r1.ry });
|
||||
setA2({ x: r2.rx, y: r2.ry });
|
||||
setAs({ x: rs.rx, y: rs.ry });
|
||||
|
||||
// Snap nur 1 Frame aktiv lassen
|
||||
requestAnimationFrame(() => {
|
||||
requestAnimationFrame(() => setSnap(false));
|
||||
});
|
||||
|
||||
pendingRef.current = null;
|
||||
|
||||
onRoll?.({ d1: p.nd1, d2: p.nd2, special: p.ns });
|
||||
};
|
||||
|
||||
|
||||
const onDoneD1 = () => {
|
||||
if (!rolling) return;
|
||||
if (doneForRollRef.current.d1) return;
|
||||
doneForRollRef.current.d1 = true;
|
||||
maybeCommit();
|
||||
};
|
||||
|
||||
const onDoneD2 = () => {
|
||||
if (!rolling) return;
|
||||
if (doneForRollRef.current.d2) return;
|
||||
doneForRollRef.current.d2 = true;
|
||||
maybeCommit();
|
||||
};
|
||||
|
||||
const onDoneS = () => {
|
||||
if (!rolling) return;
|
||||
if (doneForRollRef.current.s) return;
|
||||
doneForRollRef.current.s = true;
|
||||
maybeCommit();
|
||||
};
|
||||
|
||||
return (
|
||||
<div style={{ pointerEvents: "auto" }}>
|
||||
<div style={{ display: "grid", gap: 8 }}>
|
||||
<div style={{ display: "flex", alignItems: "baseline", justifyContent: "space-between" }}>
|
||||
<div style={{ color: stylesTokens.textMain, fontWeight: 900, fontSize: 13 }}>Würfel</div>
|
||||
<div style={{ color: stylesTokens.textDim, fontWeight: 900, fontSize: 11.5, letterSpacing: 0.7, opacity: 0.75 }}>
|
||||
{rolling ? "ROLL…" : "READY"}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
className="diceRow3d"
|
||||
style={{
|
||||
display: "grid",
|
||||
gridTemplateColumns: "repeat(3, 1fr)",
|
||||
gap: 10,
|
||||
alignItems: "center",
|
||||
justifyItems: "center",
|
||||
overflow: "visible",
|
||||
}}
|
||||
>
|
||||
<DieD6 rolling={rolling} onClick={rollAll} ax={a1.x} ay={a1.y} onDone={onDoneD1} />
|
||||
<DieD6 rolling={rolling} onClick={rollAll} ax={a2.x} ay={a2.y} onDone={onDoneD2} />
|
||||
<HouseDie face={special} rolling={rolling} onClick={rollAll} ax={as.x} ay={as.y} onDone={onDoneS} />
|
||||
</div>
|
||||
|
||||
<div style={{ color: stylesTokens.textDim, fontSize: 12, opacity: 0.95 }}>Klicken zum Rollen</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,14 +1,51 @@
|
||||
import React from "react";
|
||||
import { createRoot } from "react-dom/client";
|
||||
import ReactDOM from "react-dom/client";
|
||||
import App from "./App.jsx";
|
||||
import { applyTheme, DEFAULT_THEME_KEY } from "./styles/themes";
|
||||
import { registerSW } from "virtual:pwa-register";
|
||||
|
||||
createRoot(document.getElementById("root")).render(<App />);
|
||||
registerSW({ immediate: true });
|
||||
const updateSW = registerSW({
|
||||
async function bootstrap() {
|
||||
// Theme sofort setzen
|
||||
try {
|
||||
const key = localStorage.getItem("hpTheme:guest") || DEFAULT_THEME_KEY;
|
||||
applyTheme(key);
|
||||
} catch {
|
||||
applyTheme(DEFAULT_THEME_KEY);
|
||||
}
|
||||
|
||||
// Fonts abwarten (verhindert Layout-Sprung)
|
||||
try {
|
||||
if (document.fonts?.ready) {
|
||||
await document.fonts.ready;
|
||||
}
|
||||
} catch {}
|
||||
|
||||
// App rendern
|
||||
ReactDOM.createRoot(document.getElementById("root")).render(<App />);
|
||||
|
||||
// Splash mind. 3 Sekunden anzeigen (3000ms)
|
||||
const MIN_SPLASH_MS = 3000;
|
||||
const tStart = performance.now();
|
||||
|
||||
const hideSplash = () => {
|
||||
const splash = document.getElementById("app-splash");
|
||||
if (!splash) return;
|
||||
splash.classList.add("hide");
|
||||
setTimeout(() => splash.remove(), 320);
|
||||
};
|
||||
|
||||
const elapsed = performance.now() - tStart;
|
||||
const remaining = Math.max(0, MIN_SPLASH_MS - elapsed);
|
||||
setTimeout(hideSplash, remaining);
|
||||
|
||||
// Service Worker ohne Auto-Reload-Flash
|
||||
registerSW({
|
||||
immediate: true,
|
||||
onNeedRefresh() {
|
||||
updateSW(true); // sofort neue Version aktivieren
|
||||
window.location.reload();
|
||||
console.info("Neue Version verfügbar");
|
||||
// optional: später Toast "Update verfügbar"
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
bootstrap();
|
||||
|
||||
@@ -2,8 +2,6 @@ import { useEffect } from "react";
|
||||
import { stylesTokens } from "../theme";
|
||||
import { applyTheme } from "../themes";
|
||||
|
||||
|
||||
|
||||
export function useHpGlobalStyles() {
|
||||
// Google Fonts
|
||||
useEffect(() => {
|
||||
@@ -76,8 +74,7 @@ export function useHpGlobalStyles() {
|
||||
color: ${stylesTokens.textMain};
|
||||
}
|
||||
body {
|
||||
overflow-x: hidden;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
overflow: hidden;
|
||||
}
|
||||
#root { background: transparent; }
|
||||
* { -webkit-tap-highlight-color: transparent; }
|
||||
|
||||
@@ -195,6 +195,32 @@ export const THEMES = {
|
||||
|
||||
export const DEFAULT_THEME_KEY = "default";
|
||||
|
||||
export function setThemeColorMeta(color) {
|
||||
try {
|
||||
const safe = typeof color === "string" ? color.trim() : "";
|
||||
if (!safe) return;
|
||||
|
||||
// only allow solid colors (hex, rgb, hsl); ignore urls/gradients/rgba overlays
|
||||
const looksSolid =
|
||||
safe.startsWith("#") ||
|
||||
safe.startsWith("rgb(") ||
|
||||
safe.startsWith("hsl(") ||
|
||||
safe.startsWith("oklch(");
|
||||
|
||||
if (!looksSolid) return;
|
||||
|
||||
let meta = document.querySelector('meta[name="theme-color"]');
|
||||
if (!meta) {
|
||||
meta = document.createElement("meta");
|
||||
meta.setAttribute("name", "theme-color");
|
||||
document.head.appendChild(meta);
|
||||
}
|
||||
meta.setAttribute("content", safe);
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
export function applyTheme(themeKey) {
|
||||
const t = THEMES[themeKey] || THEMES[DEFAULT_THEME_KEY];
|
||||
const root = document.documentElement;
|
||||
@@ -202,6 +228,10 @@ export function applyTheme(themeKey) {
|
||||
for (const [k, v] of Object.entries(t.tokens)) {
|
||||
root.style.setProperty(`--hp-${k}`, v);
|
||||
}
|
||||
|
||||
// ✅ PWA/Android Statusbar dynamisch an Theme anpassen
|
||||
// Nimmt (falls vorhanden) statusBarColor, sonst pageBg
|
||||
setThemeColorMeta(t.tokens.statusBarColor || t.tokens.pageBg || "#000000");
|
||||
}
|
||||
|
||||
export function themeStorageKey(email) {
|
||||
|
||||
@@ -20,7 +20,7 @@ export default defineConfig({
|
||||
scope: "/",
|
||||
display: "standalone",
|
||||
background_color: "#1c140d",
|
||||
theme_color: "#caa45a",
|
||||
theme_color: "#000000",
|
||||
icons: [
|
||||
{ src: "/icons/icon-512.png", sizes: "512x512", type: "image/png" }
|
||||
]
|
||||
|
||||