Compare commits
32
Commits
b5e5cc502d
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7e8a7d7210 | ||
|
|
fea3401415 | ||
|
|
15927216b3 | ||
|
|
d301cf6d9a | ||
|
|
e6f2448e94 | ||
|
|
39c65927ac | ||
|
|
17f2eacb4a | ||
|
|
c809740520 | ||
|
|
c08e3bed57 | ||
|
|
4bcce765b7 | ||
|
|
0524875783 | ||
|
|
6b3e3fd8ca | ||
|
|
15ce86d6f3 | ||
|
|
0e65b8c446 | ||
|
|
5724560171 | ||
|
|
4c968d4caa | ||
|
|
e3eb20efb9 | ||
|
|
24580680a0 | ||
|
|
7179c36173 | ||
|
|
a683472d62 | ||
|
|
4915d2e8d7 | ||
|
|
d0fc9d4019 | ||
|
|
307b6fc77c | ||
|
|
ff6f3e6f4f | ||
|
|
c70141b26a | ||
|
|
cc9fadd30d | ||
|
|
45acdd3400 | ||
|
|
51e5a98a92 | ||
|
|
dbfa9788a7 | ||
|
|
70fb9e4850 | ||
|
|
62cbffdd3f | ||
|
|
5b9fe3ea21 |
No files matched your search
@@ -0,0 +1,5 @@
|
||||
docker build -t git.excaliburs-erben.de/exodus/burg-stett-game:latest .
|
||||
docker push git.excaliburs-erben.de/exodus/burg-stett-game:latest
|
||||
|
||||
# docker save <my_image> | ssh -C user@my.remote.host.com docker load
|
||||
# https://stackoverflow.com/a/31575909
|
||||
@@ -0,0 +1,12 @@
|
||||
services:
|
||||
exodus-burg-stett-game:
|
||||
image: git.excaliburs-erben.de/exodus/burg-stett-game:latest
|
||||
container_name: exodus-burg-stett-game
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "80:80"
|
||||
|
||||
networks:
|
||||
default:
|
||||
name: proxy_net
|
||||
external: true
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
FROM node:22-alpine AS builder
|
||||
RUN apk add --no-cache \
|
||||
python3 \
|
||||
py3-pip \
|
||||
build-base \
|
||||
cairo-dev \
|
||||
pango-dev \
|
||||
jpeg-dev \
|
||||
giflib-dev \
|
||||
librsvg-dev \
|
||||
pixman-dev \
|
||||
pkgconfig
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm install
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
FROM nginx:alpine
|
||||
COPY --from=builder /app/out /usr/share/nginx/html
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
EXPOSE 80
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name game;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
location /serwist/ {
|
||||
add_header Service-Worker-Allowed "/";
|
||||
}
|
||||
}
|
||||
Generated
+13
@@ -16,6 +16,7 @@
|
||||
"next": "16.3.4",
|
||||
"react": "19.2.8",
|
||||
"react-dom": "19.2.8",
|
||||
"screenfull": "^6.0.2",
|
||||
"three": "npm:super-three@0.184.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -8090,6 +8091,18 @@
|
||||
"integrity": "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/screenfull": {
|
||||
"version": "6.0.2",
|
||||
"resolved": "https://registry.npmjs.org/screenfull/-/screenfull-6.0.2.tgz",
|
||||
"integrity": "sha512-AQdy8s4WhNvUZ6P8F6PB21tSPIYKniic+Ogx0AacBMjKP1GUHN2E9URxQHtCusiwxudnCKkdy4GrHXPPJSkCCw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "^14.13.1 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/seedrandom": {
|
||||
"version": "3.0.5",
|
||||
"resolved": "https://registry.npmjs.org/seedrandom/-/seedrandom-3.0.5.tgz",
|
||||
|
||||
+8
-5
@@ -10,14 +10,15 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@serwist/next": "^9.5.12",
|
||||
"aframe": "^1.4.2",
|
||||
"clsx": "^2.1.1",
|
||||
"maplibre-gl": "^6.8.0",
|
||||
"mind-ar": "^1.2.1",
|
||||
"next": "16.3.4",
|
||||
"react": "19.2.8",
|
||||
"react-dom": "19.2.8",
|
||||
"three": "npm:super-three@0.184.0",
|
||||
"aframe": "^1.4.2",
|
||||
"mind-ar": "^1.2.1"
|
||||
"screenfull": "^6.0.2",
|
||||
"three": "npm:super-three@0.184.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@serwist/turbopack": "^9.5.12",
|
||||
@@ -33,7 +34,9 @@
|
||||
},
|
||||
"allowScripts": {
|
||||
"unrs-resolver@1.12.2": true,
|
||||
"@swc/core@1.15.46": true,
|
||||
"esbuild@0.28.2": true
|
||||
"@swc/core@1.16.13": true,
|
||||
"canvas@2.11.2": true,
|
||||
"core-js@3.29.1": true,
|
||||
"esbuild@0.25.12": true
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.0 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1468
-295
File diff suppressed because it is too large.
Load diff
|
Before Width: | Height: | Size: 108 KiB After Width: | Height: | Size: 338 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -63,6 +63,7 @@ html,
|
||||
body {
|
||||
max-width: 100vw;
|
||||
overflow-x: hidden;
|
||||
padding-bottom: env(keyboard-inset-height, 0px);
|
||||
}
|
||||
|
||||
body {
|
||||
|
||||
@@ -11,7 +11,9 @@ export const metadata: Metadata = {
|
||||
export default function RootLayout({ children }: LayoutProps<"/">) {
|
||||
return (
|
||||
<html lang="en" dir="ltr" className={clsx("eisenkraft-regular")}>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, interactive-widget=resizes-visual" />
|
||||
<meta name="apple-mobile-web-app-title" content="Excalibur Outdoor Tour" />
|
||||
<meta name="mobile-web-app-capable" content="yes" />
|
||||
<meta httpEquiv="ScreenOrientation" content="autoRotate:disabled" />
|
||||
<body>
|
||||
<SerwistProvider swUrl="/serwist/sw.js">{children}</SerwistProvider>
|
||||
|
||||
+2
-2
@@ -6,8 +6,8 @@ export default function manifest(): MetadataRoute.Manifest {
|
||||
return {
|
||||
name: 'Excaliburs Erben',
|
||||
short_name: 'Exc. Erben',
|
||||
description: '',
|
||||
//start_url: '/', Disables the default website install popup
|
||||
description: 'Eine sagenhafte Outdoor-Tour',
|
||||
start_url: '/',
|
||||
display: 'fullscreen',
|
||||
orientation: "portrait-primary",
|
||||
background_color: '#000000',
|
||||
|
||||
+43
-4
@@ -14,21 +14,60 @@ import { parse } from "path";
|
||||
import Tour from "@/components/screens/Tour";
|
||||
import clsx from "clsx";
|
||||
import StyledContainer from "@/components/StyledContainer";
|
||||
import Outro from "@/components/screens/Outro";
|
||||
import screenfull from 'screenfull';
|
||||
|
||||
export default function Main() {
|
||||
const [ stepStr, setStep ] = useLocalStorage(PREF.step, "0");
|
||||
const [ players, setPlayers ] = useLocalStorage(PREF.players, "");
|
||||
const [ tourCode, setTourCode ] = useLocalStorage(PREF.code, "");
|
||||
const [ hasAttachedListerner, setHasAttachedListener ] = useState(false);
|
||||
const step = Number.parseInt(stepStr) || 0;
|
||||
|
||||
/*console.log("STEP", step);
|
||||
console.log("PLAYERS", players, parsePlayerData(players));
|
||||
console.log("TourCode", tourCode);*/
|
||||
useEffect(() => {
|
||||
if (!hasAttachedListerner && step > 0) {
|
||||
setHasAttachedListener(true);
|
||||
const doFullscreen = () => {
|
||||
if (process.env.NODE_ENV === "development") return;
|
||||
if (screenfull.isEnabled) {
|
||||
screenfull.request();
|
||||
}
|
||||
};
|
||||
window.addEventListener("click", doFullscreen);
|
||||
let cleanup = () => {};
|
||||
if (window.visualViewport) {
|
||||
const handleResize = () => {
|
||||
const keyboardHeight = window.innerHeight - window.visualViewport.height;
|
||||
const appContainer = document.querySelector('#app');
|
||||
if (appContainer) {
|
||||
appContainer.style.paddingBottom = keyboardHeight > 0 ? `${keyboardHeight}px` : '0px';
|
||||
}
|
||||
|
||||
if (document.activeElement && keyboardHeight > 0) {
|
||||
document.activeElement.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
}
|
||||
};
|
||||
|
||||
window.visualViewport.addEventListener('resize', handleResize);
|
||||
window.visualViewport.addEventListener('scroll', handleResize);
|
||||
|
||||
cleanup = () => {
|
||||
if (window.visualViewport) {
|
||||
window.visualViewport.removeEventListener('resize', handleResize);
|
||||
window.visualViewport.removeEventListener('scroll', handleResize);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
doFullscreen();
|
||||
}
|
||||
}, [step, hasAttachedListerner, setHasAttachedListener]);
|
||||
|
||||
const content = [
|
||||
(<WelcomeScreen key={0}/>),
|
||||
(<Intro key={1} />),
|
||||
(<Tour key={2} />)
|
||||
(<Tour key={2} />),
|
||||
(<Outro key={3} />),
|
||||
];
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { createSerwistRoute } from "@serwist/turbopack";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
// If you are using Next.js versions older than 15.0.0, add the
|
||||
// `nextConfig` option so that Serwist can configure the service
|
||||
// worker according to your options. Serwist 10 and newer will
|
||||
@@ -17,6 +19,7 @@ const revision = spawnSync("git", ["rev-parse", "HEAD"], { encoding: "utf-8" }).
|
||||
export const { dynamic, dynamicParams, revalidate, generateStaticParams, GET } = createSerwistRoute({
|
||||
additionalPrecacheEntries: [{ url: "/", revision }],
|
||||
swSrc: "src/app/sw.ts",
|
||||
maximumFileSizeToCacheInBytes: 300 * 1024 * 1024,
|
||||
// nextConfig,
|
||||
// If set to `false`, Serwist will attempt to use `esbuild-wasm`.
|
||||
useNativeEsbuild: true,
|
||||
|
||||
+1
-32
@@ -20,7 +20,7 @@ const serwist = new Serwist({
|
||||
precacheEntries: self.__SW_MANIFEST,
|
||||
precacheOptions: {
|
||||
cleanupOutdatedCaches: true,
|
||||
concurrency: 20,
|
||||
concurrency: 5,
|
||||
directoryIndex: "index.html",
|
||||
fallbackToNetwork: true,
|
||||
},
|
||||
@@ -50,34 +50,3 @@ const serwist = new Serwist({
|
||||
});
|
||||
|
||||
serwist.addEventListeners();
|
||||
|
||||
/** From Gemini */
|
||||
/*
|
||||
import { defaultCache } from '@serwist/next/worker';
|
||||
import type { PrecacheEntry, SerwistGlobalConfig } from 'serwist';
|
||||
import { CacheFirst, Serwist } from 'serwist';
|
||||
|
||||
declare const self: ServiceWorkerGlobalScope &
|
||||
SerwistGlobalConfig & {
|
||||
__SW_MANIFEST: (string | PrecacheEntry)[];
|
||||
};
|
||||
|
||||
const serwist = new Serwist({
|
||||
precacheEntries: self.__SW_MANIFEST,
|
||||
skipWaiting: true,
|
||||
clientsClaim: true,
|
||||
navigationPreload: true,
|
||||
runtimeCaching: [
|
||||
...defaultCache,
|
||||
{
|
||||
// Intercept map tile requests from standard OSM / tile servers
|
||||
matcher: ({ url }) => url.hostname.includes('tile.openstreetmap.org') || url.pathname.includes('/tiles/'),
|
||||
handler: new CacheFirst({
|
||||
cacheName: 'excalibur-offline-map-tiles-v1',
|
||||
}),
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
serwist.addEventListeners();
|
||||
*/
|
||||
@@ -12,6 +12,7 @@ interface ChargedButtonProps {
|
||||
onAction?: () => void;
|
||||
disabled?: boolean;
|
||||
red?: boolean;
|
||||
whiteText?: boolean;
|
||||
}
|
||||
|
||||
export default function ChargedButton({
|
||||
@@ -22,6 +23,7 @@ export default function ChargedButton({
|
||||
onAction,
|
||||
disabled = false,
|
||||
red = false,
|
||||
whiteText = false,
|
||||
}: ChargedButtonProps) {
|
||||
const [progress, setProgress] = useState(0);
|
||||
const [, setIsCharging] = useState(false);
|
||||
@@ -105,7 +107,8 @@ export default function ChargedButton({
|
||||
<span
|
||||
className={styles["charged-button-frame"]}
|
||||
aria-hidden="true"
|
||||
style={{ backgroundImage: "url(/buttons/Button_leer.webp)" }}
|
||||
style={{ backgroundImage: whiteText ? "url(/buttons/Button_weiß.png)" : "url(/buttons/Button_leer.webp)" }}
|
||||
onContextMenu={() => false}
|
||||
/>
|
||||
|
||||
<span
|
||||
@@ -116,9 +119,10 @@ export default function ChargedButton({
|
||||
clipPath: `inset(0 ${clipPercent}% 0 0)`,
|
||||
WebkitClipPath: `inset(0 ${clipPercent}% 0 0)`,
|
||||
}}
|
||||
onContextMenu={() => false}
|
||||
/>
|
||||
|
||||
<span className={clsx(styles["charged-button-label"], "lancelot-regular")}>{children}</span>
|
||||
<span className={clsx(styles["charged-button-label"], "lancelot-regular", whiteText && styles["charged-button-label-whiteText"])}>{children}</span>
|
||||
|
||||
<span
|
||||
className={clsx(styles["charged-button-label-clipped"], "lancelot-regular")}
|
||||
|
||||
+26
-19
@@ -20,6 +20,7 @@ export interface MapViewProps {
|
||||
onMarkerClick?: (marker: PlaceMarker, currentPosition?: [number, number] | null) => void;
|
||||
// Default vector tile source or tile pattern
|
||||
tileUrlTemplate?: string;
|
||||
triggerGeolocation?: boolean;
|
||||
}
|
||||
|
||||
// MapTile calculations for Bounding Box precaching (Slippy Map Tile Names)
|
||||
@@ -38,11 +39,12 @@ const TILE_CACHE_NAME = 'excalibur-offline-map-tiles-v1';
|
||||
const DEFAULT_TILE_URL = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png';
|
||||
|
||||
export default function MapView({
|
||||
initialCenter = [9.282050, 49.090165],
|
||||
initialCenter = [9.283050, 49.091765],
|
||||
initialZoom = 15,
|
||||
markers = [],
|
||||
onMarkerClick,
|
||||
tileUrlTemplate = DEFAULT_TILE_URL,
|
||||
triggerGeolocation = true,
|
||||
}: MapViewProps) {
|
||||
const mapContainerRef = useRef<HTMLDivElement>(null);
|
||||
const mapRef = useRef<maplibregl.Map | null>(null);
|
||||
@@ -84,6 +86,7 @@ export default function MapView({
|
||||
style: mapStyle,
|
||||
center: initialCenter,
|
||||
zoom: initialZoom,
|
||||
maxZoom: 18,
|
||||
});
|
||||
|
||||
map.addControl(new maplibregl.NavigationControl({ visualizePitch: true }), 'bottom-right');
|
||||
@@ -94,33 +97,37 @@ export default function MapView({
|
||||
el.width = 42;
|
||||
el.className = styles["sword"];
|
||||
|
||||
const geolocate = new maplibregl.GeolocateControl({
|
||||
positionOptions: {
|
||||
enableHighAccuracy: true,
|
||||
},
|
||||
trackUserLocation: true,
|
||||
showUserLocation: true,
|
||||
showAccuracyCircle: false,
|
||||
});
|
||||
geolocate._dotElement = el;
|
||||
let geolocate = null;
|
||||
if (triggerGeolocation) {
|
||||
geolocate = new maplibregl.GeolocateControl({
|
||||
positionOptions: {
|
||||
enableHighAccuracy: true,
|
||||
},
|
||||
trackUserLocation: true,
|
||||
showUserLocation: true,
|
||||
showAccuracyCircle: false,
|
||||
});
|
||||
geolocate._dotElement = el;
|
||||
|
||||
geolocate.on('geolocate', (e: any) => {
|
||||
console.log(e);
|
||||
userPositionRef.current = [e.coords.longitude, e.coords.latitude];
|
||||
});
|
||||
geolocate.on('geolocate', (e: any) => {
|
||||
userPositionRef.current = [e.coords.longitude, e.coords.latitude];
|
||||
});
|
||||
|
||||
map.addControl(geolocate, 'bottom-right');
|
||||
map.addControl(geolocate, 'bottom-right');
|
||||
}
|
||||
|
||||
map.addControl(new maplibregl.ScaleControl({ unit: 'metric' }), 'bottom-left');
|
||||
|
||||
map.on('load', async () => {
|
||||
setMapReady(true);
|
||||
navigator.geolocation.getCurrentPosition((pos) => {
|
||||
userPositionRef.current = [pos.coords.longitude, pos.coords.latitude];
|
||||
map.setCenter([pos.coords.longitude, pos.coords.latitude]);
|
||||
geolocate.trigger();
|
||||
if (triggerGeolocation && geolocate) {
|
||||
userPositionRef.current = [pos.coords.longitude, pos.coords.latitude];
|
||||
map.setCenter([pos.coords.longitude, pos.coords.latitude]);
|
||||
geolocate.trigger();
|
||||
}
|
||||
}, () => {
|
||||
geolocate.trigger();
|
||||
if (triggerGeolocation && geolocate) geolocate.trigger();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -21,6 +21,9 @@ export default function OldButton({children, long=true, red=true, disabled=false
|
||||
style={style}
|
||||
onClick={(disabled ? undefined : onAction)}
|
||||
disabled={disabled}
|
||||
onContextMenu={(e) => {
|
||||
e.preventDefault();
|
||||
}}
|
||||
>
|
||||
<img
|
||||
src={
|
||||
|
||||
@@ -32,6 +32,7 @@ export default function OldTextInput({
|
||||
aria-label={ariaLabel}
|
||||
placeholder={placeholder}
|
||||
style={style}
|
||||
autoComplete="off"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -29,15 +29,24 @@ export default function PermissionCheck({
|
||||
const requestGPSPermission = () => {
|
||||
if (gpsStatus === "granted") return;
|
||||
setIsGPSPermissionLoading(true);
|
||||
|
||||
navigator.geolocation.getCurrentPosition((pos) => {
|
||||
setIsGPSPermissionLoading(false);
|
||||
refresh();
|
||||
}, (e) => {
|
||||
setIsGPSPermissionLoading(false);
|
||||
console.error("GPS Error Code:", e.code, "Message:", e.message);
|
||||
|
||||
if (e.code === 3) {
|
||||
alert("GPS-Timeout: Das Erfassen des Standorts hat zu lange gedauert. Bitte im Freien erneut versuchen.");
|
||||
} else if (e.code === 1) {
|
||||
alert("GPS-Berechtigung verweigert. Bitte in den Safari-Einstellungen für diese Website erlauben.");
|
||||
}
|
||||
refresh();
|
||||
}, {
|
||||
enableHighAccuracy: true,
|
||||
timeout: 3000
|
||||
timeout: 15000,
|
||||
maximumAge: 0
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ export default function RiddleHintPage({
|
||||
voiceOverMode
|
||||
}: RiddleHintProps) {
|
||||
//const [ pointsStr, ] = useLocalStorage(PREF.points, "");
|
||||
const [ boughtHintsStr, ] = useLocalStorage(PREF.boughtHints, "");
|
||||
const [ boughtHintsStr, ] = useLocalStorage(PREF.bought_hints, "");
|
||||
const [ showBuyHint, setShowBuyHint ] = useState(false);
|
||||
const [ showSkipRiddle, setShowSkipRiddle ] = useState(false);
|
||||
const [ currentVoiceOver, setCurrentVoiceOver ] = useState(-1);
|
||||
@@ -68,8 +68,8 @@ export default function RiddleHintPage({
|
||||
<img src={"/icons/hinweis-dunkel.svg"} className={styles["hint-icon"]}/>
|
||||
<p className={clsx(styles["hint-p"], "eisenkraft-regular")}>Hinweise</p>
|
||||
</div>
|
||||
{ nextHintToBuy && nextHintToBuy.penaltyPoints > 0 && <p>Ein {boughtHintObjects.length > 0 ? "weiterer" : ""} Hinweis kostet euch {nextHintToBuy.penaltyPoints} Rufpunkte.</p> }
|
||||
{ nextHintToBuy && nextHintToBuy.penaltyPoints === 0 && <p>Ein {boughtHintObjects.length > 0 ? "weiterer" : ""} Hinweis kostet euch zum Glück keine Rufpunkte.</p> }
|
||||
{ (nextHintToBuy && nextHintToBuy.penaltyPoints > 0) ? <p>Ein {boughtHintObjects.length > 0 ? "weiterer" : ""} Hinweis kostet euch {nextHintToBuy.penaltyPoints} Rufpunkte.</p> : null }
|
||||
{ (nextHintToBuy && nextHintToBuy.penaltyPoints === 0) ? <p>Ein {boughtHintObjects.length > 0 ? "weiterer" : ""} Hinweis kostet euch zum Glück keine Rufpunkte.</p> : null }
|
||||
{ riddle.hints.length === 0 && <p>Für das Rätsel gibt es keine Hinweise!</p> }
|
||||
{ riddle.skipPenaltyPoints === 0 && <p>Überspringt ihr das Rätsel, bekommt ihr keine Rufpunkte.</p> }
|
||||
{ riddle.skipPenaltyPoints > 0 && <p>Überspringt ihr das Rätsel, bekommt ihr {riddle.skipPenaltyPoints} Rufpunkte abgezogen.</p> }
|
||||
@@ -107,7 +107,6 @@ export default function RiddleHintPage({
|
||||
takePoints(riddle.skipPenaltyPoints);
|
||||
dismissHintPage();
|
||||
if (onSkip) onSkip();
|
||||
//TODO: Add completeRiddle
|
||||
}}>JA, ÜBERSPRINGEN</OldButton>
|
||||
</div>
|
||||
</OldPopUp>
|
||||
|
||||
@@ -20,13 +20,14 @@ import { createStationName } from "@/utils/stringer";
|
||||
|
||||
export interface RiddleScreenControls {
|
||||
riddle: Riddle;
|
||||
exitFunction: () => void;
|
||||
exitFunction: () => Promise<void>;
|
||||
showBanner: Dispatch<SetStateAction<boolean>>;
|
||||
page: number;
|
||||
setPage: (pageIndex: number) => void;
|
||||
voiceOverMode: VoiceOverMode;
|
||||
requestingHint: boolean;
|
||||
dismissHint: () => void;
|
||||
onRegisterCloseInterceptor: (closeInterceptor: () => Promise<boolean>) => void;
|
||||
};
|
||||
|
||||
interface RiddleScreenProps {
|
||||
@@ -37,11 +38,17 @@ interface RiddleScreenProps {
|
||||
export default function RiddleScreen({ riddle, onDismiss }: RiddleScreenProps) {
|
||||
const [page, setPage ] = useState(0);
|
||||
const [ showHintPage, setShowHintPage ] = useState(false);
|
||||
const [ voiceOverState, setVoiceOverState ] = useLocalStorage(PREF.voiceover, "off");
|
||||
const [ voiceOverState, setVoiceOverState ] = useLocalStorage(PREF.voice_over, "off");
|
||||
const [ showBanner, setShowBanner ] = useState(true);
|
||||
const contentRef = useRef<HTMLDivElement | null>(null);
|
||||
const closeInterceptorRef = useRef<(() => Promise<boolean>) | null>(null);
|
||||
|
||||
const exitFunction = () => {
|
||||
const exitFunction = async () => {
|
||||
if (closeInterceptorRef.current) {
|
||||
if (!await closeInterceptorRef.current()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
onDismiss();
|
||||
};
|
||||
|
||||
@@ -62,6 +69,9 @@ export default function RiddleScreen({ riddle, onDismiss }: RiddleScreenProps) {
|
||||
"requestingHint": showHintPage,
|
||||
"dismissHint": () => {
|
||||
setShowHintPage(false);
|
||||
},
|
||||
"onRegisterCloseInterceptor": (fn) => {
|
||||
closeInterceptorRef.current = fn;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,59 +1,71 @@
|
||||
"use client";
|
||||
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import React, { Dispatch, SetStateAction, useEffect, useRef, useState } from 'react';
|
||||
import 'aframe';
|
||||
import 'mind-ar/dist/mindar-image-aframe.prod.js';
|
||||
|
||||
const TARGET_CONFIG = [
|
||||
{ targetIndex: 0, videoId: 'video0', videoSrc: '/res/tour/riddle_7/videos/Oswin der Stallknecht.mp4' },
|
||||
{ targetIndex: 1, videoId: 'video1', videoSrc: '/res/tour/riddle_7/videos/Mara die Kräuterfrau.mp4' },
|
||||
{ targetIndex: 2, videoId: 'video2', videoSrc: '/res/tour/riddle_7/videos/Edmund der Schreiber.mp4' },
|
||||
{ targetIndex: 3, videoId: 'video3', videoSrc: '/res/tour/riddle_7/videos/Sir Garrick die Torwache.mp4' },
|
||||
{ targetIndex: 2, videoId: 'video0', videoSrc: '/res/tour/riddle_7/videos/Oswin der Stallknecht.mp4', name: 'Oswin' },
|
||||
{ targetIndex: 1, videoId: 'video1', videoSrc: '/res/tour/riddle_7/videos/Mara die Kräuterfrau.mp4', name: 'Mara' },
|
||||
{ targetIndex: 0, videoId: 'video2', videoSrc: '/res/tour/riddle_7/videos/Edmund der Schreiber.mp4', name: 'Edmund' },
|
||||
{ targetIndex: 3, videoId: 'video3', videoSrc: '/res/tour/riddle_7/videos/Sir Garrick die Torwache.mp4', name: 'Sir Garrick' },
|
||||
];
|
||||
|
||||
export default function Riddle_7_AR_View() {
|
||||
interface Riddle_7_AR_View_Props {
|
||||
setShowNextButton?: Dispatch<SetStateAction<boolean>>
|
||||
};
|
||||
|
||||
export default function Riddle_7_AR_View({
|
||||
setShowNextButton
|
||||
}: Riddle_7_AR_View_Props) {
|
||||
const sceneRef = useRef(null);
|
||||
const targetsRef = useRef([]);
|
||||
const videosRef = useRef({});
|
||||
const lostTimesRef = useRef({});
|
||||
const cooldownRef = useRef({});
|
||||
const activeVideoRef = useRef(null);
|
||||
|
||||
const TARGET_HEIGHT = 1;
|
||||
const [activeVideo, setActiveVideo] = useState(null);
|
||||
|
||||
const [videoDimensions, setVideoDimensions] = useState({});
|
||||
const [hasInteracted, setHasInteracted] = useState(false);
|
||||
useEffect(() => {
|
||||
activeVideoRef.current = activeVideo;
|
||||
}, [activeVideo]);
|
||||
|
||||
useEffect(() => {
|
||||
const sceneEl = sceneRef.current;
|
||||
if (!sceneEl) return;
|
||||
|
||||
const arSystem = sceneEl.systems['mindar-image-system'];
|
||||
|
||||
sceneEl.addEventListener('renderstart', () => {
|
||||
arSystem.start();
|
||||
});
|
||||
const startAR = () => {
|
||||
if (arSystem) {
|
||||
try {
|
||||
arSystem.start();
|
||||
} catch (error) {
|
||||
console.warn('AR System start error:', error);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (sceneEl.hasLoaded) {
|
||||
startAR();
|
||||
} else {
|
||||
sceneEl.addEventListener('loaded', startAR, { once: true });
|
||||
}
|
||||
|
||||
targetsRef.current.forEach((targetEl, index) => {
|
||||
if (!targetEl) return;
|
||||
|
||||
const videoEl = videosRef.current[index];
|
||||
|
||||
const handleTargetFound = () => {
|
||||
if (videoEl) {
|
||||
const lostTime = lostTimesRef.current[index];
|
||||
if (lostTime && Date.now() - lostTime > 10000) {
|
||||
videoEl.currentTime = 0;
|
||||
}
|
||||
lostTimesRef.current[index] = null;
|
||||
if (activeVideoRef.current || cooldownRef.current[index]) return;
|
||||
|
||||
videoEl.play().catch((err) => {
|
||||
console.log(`Autoplay blocked on target ${index}:`, err);
|
||||
});
|
||||
const targetConfig = TARGET_CONFIG.find((t) => t.targetIndex === index);
|
||||
if (targetConfig) {
|
||||
setShowNextButton?.(false);
|
||||
setActiveVideo(targetConfig);
|
||||
}
|
||||
};
|
||||
|
||||
const handleTargetLost = () => {
|
||||
if (videoEl) {
|
||||
videoEl.pause();
|
||||
lostTimesRef.current[index] = Date.now();
|
||||
}
|
||||
cooldownRef.current[index] = false;
|
||||
};
|
||||
|
||||
targetEl.addEventListener('targetFound', handleTargetFound);
|
||||
@@ -61,41 +73,39 @@ export default function Riddle_7_AR_View() {
|
||||
});
|
||||
|
||||
return () => {
|
||||
if (sceneEl) {
|
||||
sceneEl.removeEventListener('loaded', startAR);
|
||||
}
|
||||
if (arSystem) {
|
||||
try {
|
||||
arSystem.stop();
|
||||
arSystem.stop();
|
||||
} catch (error) {
|
||||
console.warn('MindAR stopped after DOM teardown:', error);
|
||||
console.warn('MindAR stopped after DOM teardown:', error);
|
||||
}
|
||||
}
|
||||
}}, []);
|
||||
};
|
||||
}, []);
|
||||
|
||||
const handleLoadedMetadata = (index, videoEl) => {
|
||||
if (videoEl) {
|
||||
const aspect = videoEl.videoWidth / videoEl.videoHeight;
|
||||
setVideoDimensions((prev) => ({
|
||||
...prev,
|
||||
[index]: {
|
||||
width: TARGET_HEIGHT * aspect,
|
||||
height: TARGET_HEIGHT,
|
||||
},
|
||||
}));
|
||||
const handleCloseFullscreen = () => {
|
||||
if (activeVideo) {
|
||||
setShowNextButton(true);
|
||||
cooldownRef.current[activeVideo.targetIndex] = true;
|
||||
setActiveVideo(null);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
position: 'fixed',
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: '100vw',
|
||||
height: '100vh',
|
||||
overflow: 'hidden',
|
||||
backgroundColor: '#000',
|
||||
}}
|
||||
style={{
|
||||
position: 'fixed',
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: '100vw',
|
||||
height: '100vh',
|
||||
overflow: 'hidden',
|
||||
backgroundColor: '#000',
|
||||
}}
|
||||
>
|
||||
|
||||
<a-scene
|
||||
ref={sceneRef}
|
||||
mindar-image="imageTargetSrc: /res/tour/riddle_7/targets.mind; autoStart: false; uiLoading: no; uiError: no; uiScanning: no; filterMinCF: 0.0001; filterBeta: 0.001;"
|
||||
@@ -106,48 +116,71 @@ export default function Riddle_7_AR_View() {
|
||||
device-orientation-permission-ui="enabled: false"
|
||||
style={{ width: '100%', height: '100%' }}
|
||||
>
|
||||
<a-assets>
|
||||
{TARGET_CONFIG.map((target) => (
|
||||
<video
|
||||
key={target.videoId}
|
||||
id={target.videoId}
|
||||
ref={(el) => (videosRef.current[target.targetIndex] = el)}
|
||||
src={target.videoSrc}
|
||||
preload="auto"
|
||||
loop
|
||||
crossOrigin="anonymous"
|
||||
playsInline
|
||||
onLoadedMetadata={(e) =>
|
||||
handleLoadedMetadata(target.targetIndex, e.target)
|
||||
}
|
||||
></video>
|
||||
))}
|
||||
</a-assets>
|
||||
|
||||
<a-camera position="0 0 0" look-controls="enabled: false"></a-camera>
|
||||
|
||||
{TARGET_CONFIG.map((target) => {
|
||||
const dims = videoDimensions[target.targetIndex] || {
|
||||
width: 1,
|
||||
height: TARGET_HEIGHT,
|
||||
};
|
||||
return (
|
||||
{TARGET_CONFIG.map((target) => (
|
||||
<a-entity
|
||||
key={target.targetIndex}
|
||||
ref={(el) => (targetsRef.current[target.targetIndex] = el)}
|
||||
mindar-image-target={`targetIndex: ${target.targetIndex}`}
|
||||
>
|
||||
<a-video
|
||||
src={`#${target.videoId}`}
|
||||
width={dims.width}
|
||||
height={dims.height}
|
||||
position="0 0 0"
|
||||
rotation="0 0 0"
|
||||
></a-video>
|
||||
</a-entity>
|
||||
);
|
||||
})}
|
||||
key={target.targetIndex}
|
||||
ref={(el) => (targetsRef.current[target.targetIndex] = el)}
|
||||
mindar-image-target={`targetIndex: ${target.targetIndex}`}
|
||||
></a-entity>
|
||||
))}
|
||||
</a-scene>
|
||||
|
||||
{activeVideo && (
|
||||
<div
|
||||
style={{
|
||||
position: 'fixed',
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: '100dvw',
|
||||
height: '100dvh',
|
||||
backgroundColor: '#000',
|
||||
zIndex: 9999,
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
}}
|
||||
>
|
||||
<button
|
||||
onClick={handleCloseFullscreen}
|
||||
style={{
|
||||
position: 'absolute',
|
||||
top: '20px',
|
||||
left: '20px',
|
||||
zIndex: 10001,
|
||||
backgroundColor: 'transparent',
|
||||
border: 'none',
|
||||
width: '48px',
|
||||
height: '48px',
|
||||
display: 'flex',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
cursor: 'pointer',
|
||||
outline: 'none',
|
||||
}}
|
||||
aria-label="Close video"
|
||||
>
|
||||
<img src="/icons/kreuz.svg" alt="Close" style={{ width: '40px', height: '40px' }} />
|
||||
</button>
|
||||
|
||||
<video
|
||||
src={activeVideo.videoSrc}
|
||||
controls
|
||||
autoPlay
|
||||
playsInline
|
||||
style={{
|
||||
position: "absolute",
|
||||
top: "0",
|
||||
left: "0",
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
objectFit: 'contain',
|
||||
zIndex: 10000,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
}
|
||||
@@ -13,9 +13,10 @@ interface StyledContainerProps {
|
||||
outerClassName?: string;
|
||||
innerClassName?: string;
|
||||
riddleDesign?: boolean;
|
||||
contentBarStyles?: CSSProperties;
|
||||
};
|
||||
|
||||
export default function StyledContainer({children, outerStyles, innerStyles, outerClassName, innerClassName, riddleDesign=false}: StyledContainerProps) {
|
||||
export default function StyledContainer({children, outerStyles, innerStyles, outerClassName, innerClassName, riddleDesign=false, contentBarStyles}: StyledContainerProps) {
|
||||
|
||||
return (
|
||||
<div className={clsx(styles["container"], outerClassName)} style={outerStyles}>
|
||||
@@ -29,7 +30,7 @@ export default function StyledContainer({children, outerStyles, innerStyles, out
|
||||
<img src="/container/Rand_oben.webp" className={clsx(styles["top-side"])}/>
|
||||
</div>
|
||||
}
|
||||
<div className={clsx(styles["content-bar"])} style={{padding: ((!riddleDesign) ? "20% 5dvw" : "12% 5dvw"), paddingBottom: "0px"}}>
|
||||
<div className={clsx(styles["content-bar"])} style={{padding: ((!riddleDesign) ? "20% 5dvw" : "12% 5dvw"), paddingBottom: "0px", ...contentBarStyles}}>
|
||||
<img src="/container/Rand_Verzierung.webp" className={clsx(styles["side"])} style={{rotate: "180deg"}} />
|
||||
<div className={clsx(styles["content"], innerClassName)} style={innerStyles}>
|
||||
{children}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
width: 100%;
|
||||
> input {
|
||||
width: 100%;
|
||||
accent-color: var(--dark-brown);
|
||||
}
|
||||
> div {
|
||||
display: flex;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import OldButton from "../OldButton";
|
||||
import styles from "@/css/RiddleStyles.module.css";
|
||||
import { useLocalStorage } from "@/hooks/useLocalStorage";
|
||||
@@ -12,7 +12,7 @@ import clsx from "clsx";
|
||||
import { RiddleScreenControls } from "../RiddleScreen";
|
||||
import { addPoints } from "@/utils/points";
|
||||
import RiddleCompleteBanner from "../RiddleCompleteBanner";
|
||||
import { setPlayers } from "@/utils/players";
|
||||
import { getPlayers, setPlayers } from "@/utils/players";
|
||||
import { setPlayerAnswers } from "@/utils/player_answers";
|
||||
import VoiceOver from "../VoiceOver";
|
||||
import RiddleHintPage from "../RiddleHintPage";
|
||||
@@ -30,7 +30,7 @@ export default function Riddle_1({
|
||||
requestingHint,
|
||||
dismissHint,
|
||||
}: RiddleScreenControls) {
|
||||
const [ playerCountStr, setPlayerCount ] = useLocalStorage(PREF.playerCount, "");
|
||||
const [ playerCountStr, setPlayerCount ] = useLocalStorage(PREF.player_count, "");
|
||||
const playerCount = Number.parseInt(playerCountStr) || 0;
|
||||
|
||||
const [ nameScreen, setNameScreen ] = useState(0);
|
||||
@@ -53,6 +53,49 @@ export default function Riddle_1({
|
||||
"Achtes Abenteuermitglied"
|
||||
];
|
||||
|
||||
const defaultPlayers: Player[] = [
|
||||
{
|
||||
"id": 0,
|
||||
"name": "Friedrich",
|
||||
"gender": "male"
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Hildegard",
|
||||
"gender": "female"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "Helmut",
|
||||
"gender": "male"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"name": "Wolfgang",
|
||||
"gender": "male"
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"name": "Gertrude",
|
||||
"gender": "female"
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"name": "Gisela",
|
||||
"gender": "female"
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"name": "Christa",
|
||||
"gender": "female"
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"name": "Adelbert",
|
||||
"gender": "male"
|
||||
}
|
||||
];
|
||||
|
||||
const hasNextPlayer = nameScreen < playerCount-1;
|
||||
const canGoNext = didPlayerEnterAnswer && didPlayerEnterName && didPlayerPickGender && hasNextPlayer;
|
||||
const complete = (() => {
|
||||
@@ -89,6 +132,28 @@ export default function Riddle_1({
|
||||
});
|
||||
};
|
||||
|
||||
const [ playersStr, ] = useLocalStorage(PREF.players, "");
|
||||
|
||||
const players = useMemo(() => {
|
||||
return getPlayers();
|
||||
}, [playersStr]);
|
||||
|
||||
const skipPlayerNames = useMemo(() => {
|
||||
let names = "";
|
||||
const players_length = players.length;
|
||||
for (let i = 0; i < players_length; ++i) {
|
||||
if (i >= players_length-1) {
|
||||
names = names + " und " + players[i].name;
|
||||
} else {
|
||||
if (i > 0) {
|
||||
names = names + ", ";
|
||||
}
|
||||
names = names + players[i].name;
|
||||
}
|
||||
}
|
||||
return names;
|
||||
}, [players]);
|
||||
|
||||
const pages = [
|
||||
(
|
||||
<div key={0}>
|
||||
@@ -220,7 +285,7 @@ export default function Riddle_1({
|
||||
setPlayerAnswers(enteredAnswers);
|
||||
addCompletedRiddle(riddle.step);
|
||||
setPage(2);
|
||||
}} disabled={hasNextPlayer}>EINREICHEN!</ChargedButton>
|
||||
}} disabled={hasNextPlayer}>ANTWORTEN EINREICHEN</ChargedButton>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
@@ -242,6 +307,9 @@ export default function Riddle_1({
|
||||
}
|
||||
]}/>
|
||||
<div className={styles["content"]}>
|
||||
<div style={{textAlign: "center", marginBottom: "1rem"}}>
|
||||
<img src={"/res/tour/riddle_" + (riddle.step + 1) + "/result.svg"} width={"40%"}/>
|
||||
</div>
|
||||
<RiddleCompleteBanner points={riddle.points} win={true}></RiddleCompleteBanner>
|
||||
<p>Der Gelehrte betrachtet seine Einträge noch einmal und nickt zufrieden.</p>
|
||||
<p>„Sehr gut. Namen, Worte – und die Art, wie ihr eure Entscheidungen trefft. Man kann erstaunlich viel über einen Menschen erfahren, wenn man nur die richtigen Fragen stellt.“</p>
|
||||
@@ -252,8 +320,38 @@ export default function Riddle_1({
|
||||
<OldButton red={false} onAction={() => exitFunction()}>ZURÜCK ZUR KARTE</OldButton>
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
(
|
||||
<div key={3}>
|
||||
<VoiceOver voiceOverMode={voiceOverMode} sources={[
|
||||
{
|
||||
"src": "/res/tour/riddle_1/voiceovers/Skip.mp3",
|
||||
"type": "audio/mpeg"
|
||||
}
|
||||
]}/>
|
||||
<div className={styles["content"]}>
|
||||
<div style={{textAlign: "center", marginBottom: "1rem"}}>
|
||||
<img src={"/res/tour/riddle_" + (riddle.step + 1) + "/result.svg"} width={"40%"}/>
|
||||
</div>
|
||||
<p>Nun gut, wenn ihr anonym bleiben wollt, so könnt ihr hierfür keine Rufpunkte erhalten.</p>
|
||||
<p>Ich werde euch fortan {skipPlayerNames} nennen.</p>
|
||||
<p>Schreitet weiter voran.</p>
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
<OldButton red={false} onAction={() => exitFunction()}>ZURÜCK ZUR KARTE</OldButton>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
];
|
||||
|
||||
return requestingHint ? <RiddleHintPage riddle={riddle} dismissHintPage={dismissHint} voiceOverMode={voiceOverMode} onSkip={null}/> : pages[page];
|
||||
return requestingHint ? <RiddleHintPage riddle={riddle} dismissHintPage={dismissHint} voiceOverMode={voiceOverMode} onSkip={() => {
|
||||
const p: Player[] = [];
|
||||
for (let i = 0; i < playerCount; ++i) {
|
||||
p.push(defaultPlayers[i]);
|
||||
}
|
||||
setPlayers(p);
|
||||
showBanner(false);
|
||||
addCompletedRiddle(riddle.step);
|
||||
setPage(3);
|
||||
}}/> : pages[page];
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import { useEffect, useMemo, useRef, useState } from "react";
|
||||
import OldButton from "../OldButton";
|
||||
import styles from "@/css/RiddleStyles.module.css";
|
||||
import { useLocalStorage } from "@/hooks/useLocalStorage";
|
||||
import { PREF } from "@/utils/const";
|
||||
import { API_PREFIX, PREF, WS_SCHEME } from "@/utils/const";
|
||||
import { RiddleScreenControls } from "../RiddleScreen";
|
||||
import { addPoints } from "@/utils/points";
|
||||
import RiddleCompleteBanner from "../RiddleCompleteBanner";
|
||||
@@ -12,17 +12,48 @@ import { getPlayers } from "@/utils/players";
|
||||
import VoiceOver from "../VoiceOver";
|
||||
import RiddleHintPage from "../RiddleHintPage";
|
||||
import { Player } from "@/types/player";
|
||||
import { getSwordState } from "@/utils/swordTalk";
|
||||
import GameController from "../GameController";
|
||||
import { addCompletedRiddle } from "@/utils/completedRiddles";
|
||||
import ChargedButton from "../ChargedButton";
|
||||
import { isDemoMode } from "@/utils/demoMode";
|
||||
|
||||
export type ConnectionStatus = "disconnected" | "connected";
|
||||
export const TOPIC_PREFIX = (process.env.NODE_ENV === "development") ? "staging/outdoor/king-arthur/sword" : "outdoor/king-arthur/sword";
|
||||
|
||||
export type ConnectionStatus = "disconnected" | "connected" | "connecting";
|
||||
|
||||
interface MQTTMessage {
|
||||
topic: string;
|
||||
payload: string;
|
||||
}
|
||||
|
||||
let awaitTryAbort = false;
|
||||
|
||||
/**
|
||||
* Waits until a condition function returns true or a timeout occurs.
|
||||
*
|
||||
* @param {Function} conditionFn - A function that returns a boolean.
|
||||
* @param {number} timeoutMs - Timeout in milliseconds (default: 3000ms).
|
||||
* @param {number} intervalMs - Polling interval in milliseconds (default: 100ms).
|
||||
* @returns {Promise<boolean>} Resolves to true if condition is met, rejects on timeout.
|
||||
*/
|
||||
function waitUntilTrue(conditionFn: () => boolean, timeoutMs = 3000, intervalMs = 100) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const startTime = Date.now();
|
||||
|
||||
const intervalId = setInterval(() => {
|
||||
if (conditionFn()) {
|
||||
clearInterval(intervalId);
|
||||
resolve(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Date.now() - startTime >= timeoutMs) {
|
||||
clearInterval(intervalId);
|
||||
reject(new Error("Timeout"));
|
||||
}
|
||||
}, intervalMs);
|
||||
});
|
||||
}
|
||||
|
||||
export default function Riddle_2({
|
||||
page,
|
||||
setPage,
|
||||
@@ -32,10 +63,39 @@ export default function Riddle_2({
|
||||
voiceOverMode,
|
||||
requestingHint,
|
||||
dismissHint,
|
||||
onRegisterCloseInterceptor
|
||||
}: RiddleScreenControls) {
|
||||
const [ canGoNext, setCanGoNext ] = useState(false);
|
||||
const [ isSwordBackIn, setIsSwordBackIn ] = useState(true);
|
||||
const [ playersStr, ] = useLocalStorage(PREF.players, "");
|
||||
const [ tourCode, ] = useLocalStorage(PREF.code, "");
|
||||
const [ isSystemLockOn, setIsSystemLockOn] = useState<boolean | undefined>(undefined);
|
||||
const [ isSwordOnline, setIsSwordOnline ] = useState(true);
|
||||
const [ wasSwordTakenOffline, setWasSwordTakenOffline ] = useState(false);
|
||||
|
||||
|
||||
const [swordStatus, setSwordStatus] = useState<string | null>(null);
|
||||
// lE == true && sE == true
|
||||
const checkSwordStatusForIdealState = (state: string) => {
|
||||
// M:2,snd:true,sS:true,sE:true,sP:false,lE:true,v:50,pD:150s
|
||||
if (state == null) return false;
|
||||
let sE = false;
|
||||
let lE = false;
|
||||
const tokens = state.split(",");
|
||||
for (const token of tokens) {
|
||||
if (token === "sE:true") {
|
||||
sE = true;
|
||||
} else if (token === "lE:true") {
|
||||
lE = true;
|
||||
}
|
||||
}
|
||||
return sE && lE;
|
||||
};
|
||||
const [ isSwordIdealState, setIsSwordIdealState ] = useState(false);
|
||||
|
||||
const [ demoModeStr, ] = useLocalStorage(PREF.demo_mode, "");
|
||||
const demoMode = useMemo(() => isDemoMode(demoModeStr), [demoModeStr]);
|
||||
//const demoMode = false;
|
||||
|
||||
const [ playerIndex, setPlayerIndex ] = useState(0);
|
||||
const players = useMemo(() => getPlayers(), [playersStr]);
|
||||
@@ -57,63 +117,129 @@ export default function Riddle_2({
|
||||
const isNextIndexLastPlayer = players.length-2 <= playerIndex;
|
||||
|
||||
const [status, setStatus] = useState<ConnectionStatus>("disconnected");
|
||||
const [swordStatus, setSwordStatus] = useState<string>('N/A');
|
||||
//const [throneStatus, setThroneStatus] = useState<string>('N/A');
|
||||
const [ soundInput, setSoundInput ] = useState("Chosen");
|
||||
const statusRef = useRef(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (status === "connected") {
|
||||
statusRef.current = true;
|
||||
} else {
|
||||
statusRef.current = false;
|
||||
}
|
||||
}, [status]);
|
||||
|
||||
const wsRef = useRef<WebSocket | null>(null);
|
||||
const [ showControls, setShowControls ] = useState(false);
|
||||
|
||||
const sendCommand = (topic: string, payload: string) => {
|
||||
if (demoMode) return true;
|
||||
if (wsRef.current && wsRef.current.readyState === WebSocket.OPEN) {
|
||||
wsRef.current.send(JSON.stringify({ topic, payload }));
|
||||
return true;
|
||||
} else {
|
||||
alert('WebSocket is not connected.');
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const tourCode = "TESTTEST!";
|
||||
wsRef.current = new WebSocket(`ws://localhost:8080/ws/bridge?tourCode=${tourCode}`);
|
||||
if (demoMode) return;
|
||||
|
||||
wsRef.current.onopen = () => {
|
||||
setStatus("connected");
|
||||
};
|
||||
let isCancelled = false;
|
||||
let reconnectTimeout: NodeJS.Timeout;
|
||||
|
||||
wsRef.current.onmessage = (event) => {
|
||||
const data: MQTTMessage = JSON.parse(event.data);
|
||||
const connect = () => {
|
||||
if (isCancelled) return;
|
||||
setStatus("connecting");
|
||||
|
||||
if (data.topic === 'outdoor/king-arthur/sword/stat') {
|
||||
setSwordStatus(data.payload);
|
||||
} else if (data.topic === 'outdoor/king-arthur/throne/stat') {
|
||||
//setThroneStatus(data.payload);
|
||||
} else if (data.topic.includes('/event')) {
|
||||
console.log(`Event received on ${data.topic}:`, data.payload);
|
||||
if (data.payload === "pull-denied") {
|
||||
setCanGoNext(true);
|
||||
} else if (data.payload === "pulled-out") {
|
||||
setIsSwordBackIn(false);
|
||||
} else if (data.payload === "locked") {
|
||||
setIsSwordBackIn(true);
|
||||
} else if (data.payload === "ceremonyDone") {
|
||||
setCanGoNext(true);
|
||||
const ws = new WebSocket(`${WS_SCHEME}://${API_PREFIX}/ws/bridge?tourCode=${tourCode}`);
|
||||
wsRef.current = ws;
|
||||
|
||||
ws.onopen = () => {
|
||||
if (!isCancelled) {
|
||||
setStatus("connected");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ws.onmessage = (event) => {
|
||||
const data: MQTTMessage = JSON.parse(event.data);
|
||||
|
||||
if (data.topic === `${TOPIC_PREFIX}/stat`) {
|
||||
setSwordStatus(data.payload);
|
||||
setIsSwordIdealState(checkSwordStatusForIdealState(data.payload));
|
||||
} else if (data.topic.includes('/event')) {
|
||||
console.log(`Event received on ${data.topic}:`, data.payload);
|
||||
if (data.payload === "pull-denied") {
|
||||
setCanGoNext(true);
|
||||
} else if (data.payload === "pulled-out") {
|
||||
setIsSwordBackIn(false);
|
||||
} else if (data.payload === "locked") {
|
||||
setIsSwordBackIn(true);
|
||||
} else if (data.payload === "ceremonyDone") {
|
||||
setCanGoNext(true);
|
||||
} else if (data.payload === "online") {
|
||||
setIsSwordOnline(true);
|
||||
} else if (data.payload === "offline") {
|
||||
setIsSwordOnline(false);
|
||||
}
|
||||
} else if (data.topic.includes('/set')) {
|
||||
if (data.payload === "abortTry") {
|
||||
awaitTryAbort = true;
|
||||
}
|
||||
} else if (data.topic.startsWith("system/")) {
|
||||
if (data.topic === "system/swordLock") {
|
||||
if (data.payload === "locked") {
|
||||
setIsSystemLockOn(true);
|
||||
} else if (data.payload === "unlocked") {
|
||||
setIsSystemLockOn(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ws.onclose = () => {
|
||||
setIsSystemLockOn(undefined);
|
||||
if (!isCancelled) {
|
||||
setStatus("disconnected");
|
||||
reconnectTimeout = setTimeout(connect, 3000);
|
||||
if (statusRef.current) {
|
||||
setPage(0);
|
||||
alert("Die Internet-Verbindung wurde verloren!");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ws.onerror = () => {
|
||||
ws.close();
|
||||
setIsSystemLockOn(undefined);
|
||||
};
|
||||
};
|
||||
|
||||
wsRef.current.onclose = () => {
|
||||
sendCommand('outdoor/king-arthur/sword/set', 'abortTry');
|
||||
setStatus("disconnected");
|
||||
};
|
||||
connect();
|
||||
|
||||
return () => {
|
||||
isCancelled = true;
|
||||
clearTimeout(reconnectTimeout);
|
||||
setIsSystemLockOn(undefined);
|
||||
wsRef.current?.close();
|
||||
};
|
||||
}, []);
|
||||
}, [tourCode]);
|
||||
|
||||
const currentPlayer: Player = players[playerOrder[playerIndex]];
|
||||
|
||||
useEffect(() => {
|
||||
const handleIntercept = async () => {
|
||||
if (page === 1) {
|
||||
awaitTryAbort = false;
|
||||
sendCommand(`${TOPIC_PREFIX}/set`, 'abortTry');
|
||||
await waitUntilTrue(() => {
|
||||
return awaitTryAbort
|
||||
});
|
||||
sendCommand("system/swordLock", "giveLock");
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
onRegisterCloseInterceptor(handleIntercept);
|
||||
}, [onRegisterCloseInterceptor]);
|
||||
|
||||
const pages = [
|
||||
(
|
||||
<div key={0}>
|
||||
@@ -130,12 +256,25 @@ export default function Riddle_2({
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
<OldButton red={false} onAction={() => {
|
||||
if (!sendCommand('outdoor/king-arthur/sword/set', 'stayLocked')) {
|
||||
if (!isSwordOnline && !demoMode) {
|
||||
addPoints(riddle.points);
|
||||
setWasSwordTakenOffline(true);
|
||||
addCompletedRiddle(riddle.step);
|
||||
showBanner(false);
|
||||
setPage(3);
|
||||
return;
|
||||
}
|
||||
if (!isSwordIdealState) {
|
||||
alert("Eine wahre Prüfung kann erst gestarten werden, wenn das Schwert richtig im Felsen ist!");
|
||||
return;
|
||||
}
|
||||
if (!sendCommand(`${TOPIC_PREFIX}/set`, 'stayLocked')) {
|
||||
return;
|
||||
}
|
||||
sendCommand("system/swordLock", "takeLock");
|
||||
setCanGoNext(false);
|
||||
setPage(1);
|
||||
}}>WEITER</OldButton>
|
||||
}} disabled={(isSystemLockOn !== false) && !demoMode && isSwordOnline} >PRÜFUNG STARTEN</OldButton>
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
@@ -146,75 +285,42 @@ export default function Riddle_2({
|
||||
<p style={{fontWeight: "bold", fontSize: "3rem", marginTop: "2rem", marginBottom: "0"}}>{currentPlayer.name},</p>
|
||||
<p style={{textAlign: "center"}}>zieh nun am Schwert und finde heraus, ob du Excaliburs {currentPlayer.gender === "female" ? "Erbin" : "Erbe"} bist!</p>
|
||||
</div> : null }
|
||||
<div style={{ padding: '20px', fontFamily: 'sans-serif', fontSize: '0.6rem', display: showControls ? "" : "none"}}>
|
||||
<h2 style={{ fontSize: '1rem', marginBottom: '10px' }}>King Arthur - Station Control Dashboard</h2>
|
||||
<p style={{ fontSize: '0.6rem' }}><strong>Connection State:</strong> {status}</p>
|
||||
|
||||
<div style={{ display: 'flex', gap: '20px', marginTop: '20px' }}>
|
||||
<div style={{ border: '1px solid #ccc', padding: '15px', borderRadius: '8px', flex: 1 }}>
|
||||
<h3 style={{ fontSize: '0.8rem', marginTop: 0 }}>Excalibur (Sword)</h3>
|
||||
<p style={{ fontSize: '0.6rem' }}><strong>Stat:<br></br></strong> {swordStatus}</p>
|
||||
<button
|
||||
style={{ fontSize: '0.6rem', padding: '4px 8px' }}
|
||||
onClick={() => sendCommand('outdoor/king-arthur/sword/set', 'releaseLock')}
|
||||
>
|
||||
Release Lock
|
||||
</button>
|
||||
<br/><br/>
|
||||
<button
|
||||
style={{ fontSize: '0.6rem', padding: '4px 8px' }}
|
||||
onClick={() => sendCommand('outdoor/king-arthur/sword/set', 'stayLocked')}
|
||||
>
|
||||
Stay Locked
|
||||
</button>
|
||||
<br/><br/>
|
||||
<button
|
||||
style={{ fontSize: '0.6rem', padding: '4px 8px' }}
|
||||
onClick={() => sendCommand('outdoor/king-arthur/sword/set', 'gameStarted')}
|
||||
>
|
||||
Game Started
|
||||
</button>
|
||||
<br/><br/>
|
||||
<button
|
||||
style={{ fontSize: '0.6rem', padding: '4px 8px' }}
|
||||
onClick={() => sendCommand('outdoor/king-arthur/sword/set', 'gameFinished')}
|
||||
>
|
||||
Game Stopped
|
||||
</button>
|
||||
<br/><br/>
|
||||
<input type='text' placeholder='sound' value={soundInput} onChange={(e) => setSoundInput(e.target.value)}/>
|
||||
<br/><br/>
|
||||
<button
|
||||
style={{ fontSize: '0.6rem', padding: '4px 8px' }}
|
||||
onClick={() => sendCommand('outdoor/king-arthur/sword/cfg', 'playSound:' + soundInput)}
|
||||
>
|
||||
Play Sound
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
<OldButton red={false} onAction={() => {
|
||||
<ChargedButton red={false} onAction={() => {
|
||||
if (playerIndex >= players.length-1) {
|
||||
showBanner(false);
|
||||
setPage(2);
|
||||
addPoints(riddle.points);
|
||||
addCompletedRiddle(riddle.step);
|
||||
sendCommand("system/swordLock", "giveLock");
|
||||
} else {
|
||||
if (isNextIndexLastPlayer) {
|
||||
if (!sendCommand('outdoor/king-arthur/sword/set', 'releaseLock')) {
|
||||
if (!sendCommand(`${TOPIC_PREFIX}/set`, 'releaseLock')) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (!sendCommand('outdoor/king-arthur/sword/set', 'stayLocked')) {
|
||||
if (!sendCommand(`${TOPIC_PREFIX}/set`, 'stayLocked')) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
setCanGoNext(false);
|
||||
setPlayerIndex(playerIndex+1);
|
||||
}
|
||||
}} disabled={!canGoNext}>WEITER</OldButton>
|
||||
{playerIndex < 1 ? <OldButton red={true} onAction={() => setPage(0)} className={styles["backButton"]}>ZURÜCK</OldButton> : null}
|
||||
}} disabled={!canGoNext && !demoMode}>{(playerIndex >= players.length-1) ? "PRÜFUNG BEENDEN" : "NÄCHSTER PRÜFLING"}</ChargedButton>
|
||||
{playerIndex < 1 ? <OldButton red={true} onAction={async () => {
|
||||
if (demoMode) {
|
||||
setPage(0);
|
||||
return;
|
||||
}
|
||||
awaitTryAbort = false;
|
||||
sendCommand(`${TOPIC_PREFIX}/set`, 'abortTry');
|
||||
await waitUntilTrue(() => {
|
||||
return awaitTryAbort;
|
||||
});
|
||||
sendCommand("system/swordLock", "giveLock");
|
||||
setPage(0);
|
||||
}} className={styles["backButton"]}>ZURÜCK</OldButton> : null}
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
@@ -227,13 +333,36 @@ export default function Riddle_2({
|
||||
}
|
||||
]}/>
|
||||
<div className={styles["content"]}>
|
||||
<div style={{textAlign: "center", marginBottom: "1rem"}}>
|
||||
<img src={"/res/tour/riddle_" + (riddle.step + 1) + "/result.svg"} width={"50%"}/>
|
||||
</div>
|
||||
<RiddleCompleteBanner points={riddle.points} win={true}></RiddleCompleteBanner>
|
||||
<p>Der Fels gibt nach, und nach all den Jahren liegt Excalibur wieder in der Hand eines Menschen. Die Prophezeiung hat gewählt.</p>
|
||||
<p>Bevor ihr das Schwert zurückgebt, haltet diesen Augenblick fest. Hebt Excalibur, versammelt euch und macht ein Foto, das ebenso gut seinen Platz in den Chroniken von Stettenfels finden könnte. Triumphiert ruhig ein wenig – schließlich zieht man nicht jeden Tag ein legendäres Königsschwert aus einem Felsen.</p>
|
||||
<p>Erst wenn euer Beweis für die Nachwelt geschaffen ist, steckt Excalibur zurück in den Stein. Denn aus der Ferne erreicht euch noch immer kein Jubel, sondern nur Schweigen. Offenbar genügt es nicht mehr, das Schwert zu ziehen.</p>
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
<OldButton red={false} disabled={!isSwordBackIn} onAction={() => exitFunction()}>ZURÜCK ZUR KARTE</OldButton>
|
||||
<OldButton red={false} disabled={!isSwordBackIn && !demoMode} onAction={() => exitFunction()}>ZURÜCK ZUR KARTE</OldButton>
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
(
|
||||
<div key={3}>
|
||||
<VoiceOver voiceOverMode={voiceOverMode} sources={[
|
||||
{
|
||||
"src": "/res/tour/riddle_2/voiceovers/Skip.mp3",
|
||||
"type": "audio/mpeg"
|
||||
}
|
||||
]}/>
|
||||
<div className={styles["content"]}>
|
||||
<div style={{textAlign: "center", marginBottom: "1rem"}}>
|
||||
<img src={"/res/tour/riddle_" + (riddle.step + 1) + "/result.svg"} width={"50%"}/>
|
||||
</div>
|
||||
<RiddleCompleteBanner points={wasSwordTakenOffline ? riddle.points : 0} win={true}></RiddleCompleteBanner>
|
||||
<p><b>{players?.[players?.length - 1]?.name}</b>, du bist <b>{players?.[players?.length - 1]?.gender === "female" ? "die" : "der"} Auserwählte</b> und wärst des Schwertes würdig gewesen. Nun gut, schreitet ohne Schwert und mit nur wenigen Rufpunkten voran.</p>
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
<OldButton red={false} disabled={!isSwordBackIn && !demoMode} onAction={() => exitFunction()}>ZURÜCK ZUR KARTE</OldButton>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
@@ -241,6 +370,8 @@ export default function Riddle_2({
|
||||
|
||||
return requestingHint ? <RiddleHintPage riddle={riddle} dismissHintPage={dismissHint} voiceOverMode={voiceOverMode} onSkip={() => {
|
||||
addCompletedRiddle(riddle.step);
|
||||
setPage(2);
|
||||
setWasSwordTakenOffline(false);
|
||||
showBanner(false);
|
||||
setPage(3);
|
||||
}}/> : pages[page];
|
||||
}
|
||||
@@ -59,9 +59,10 @@ export default function Riddle_3({
|
||||
]}/>
|
||||
<div className={styles["content"]}>
|
||||
<p>Die Nachricht verbreitet sich schneller als jeder Reiter: Excalibur wurde gezogen. Doch ein Schwert allein macht noch keinen König, und nun soll das Volk selbst sehen, wer vor ihm steht.</p>
|
||||
<p>Der Auserwählte muss deshalb allein hinauf zum Turm. Dort, über den Köpfen der anderen, wird sich zeigen, ob auf den neuen Träger Excaliburs nur neugierige Blicke gerichtet sind – oder bereits erste Hoffnung.</p>
|
||||
<p><b><span>{`${name}, ${call} `}</span>Auserwählte</b> nimmt jetzt die Schriftrolle an sich, geht zum Eisentor und öffnet das Schloss mit dem Code <b>6357</b>. Tretet hindurch und geht allein weiter bis zum Turm.</p>
|
||||
<p>Das gemeine Volk versammelt sich währenddessen unterhalb des Turms. Sobald der Auserwählte oben angekommen ist, das Banner herabgelassen wurde und sich das Volk unten versammelt hat, kann die Ansprache beginnen.</p>
|
||||
<p>Der Auserwählte muss deshalb allein durch das Tor zum Turm. Dort, über den Köpfen der anderen, wird sich zeigen, ob auf den neuen Träger Excaliburs nur neugierige Blicke gerichtet sind - oder bereits erste Hoffnung.</p>
|
||||
<p><b>{name}</b>, <span>{call}</span> Auserwählte <b>nimmt</b> jetzt die Schriftrolle an sich, geht zum Eisentor und öffnet das Schloss mit dem Code <b>6357</b>, tritt hindurch und geht weiter bis ganz nach hinten zum Turm. Dort <b>lässt</b> er <b>das Banner herab.</b></p>
|
||||
<p>Das <b>gemeine Volk nimmt das Handy</b>, steigt die kleine Treppe vor dem Tor hinab und versammelt sich unterhalb des Banners.</p>
|
||||
<p>Sobald der Auserwählte angekommen ist, das Banner herabgelassen wurde und sich das Volk unten versammelt hat, kann es weitergehen, wenn alle bereit sind.</p>
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
<ChargedButton red={false} disabled={false} onAction={() => setPage(1)}>WIR SIND BEREIT</ChargedButton>
|
||||
@@ -123,6 +124,7 @@ export default function Riddle_3({
|
||||
]}/>
|
||||
<RiddleCompleteBanner points={riddle.failPenaltyPoints} win={false}></RiddleCompleteBanner>
|
||||
<p>Die Rede ist verklungen, doch unter dem Turm liegt spürbare Unruhe in der Luft. Zu viele Worte haben Zweifel geweckt und zu wenig Vertrauen geschaffen, sodass das Volk noch nicht bereit ist, euch als würdigen Herrscher anzuerkennen.</p>
|
||||
<p>Der Auserwählte darf nun das Banner wieder einrollen, zum Eisentor zurückkehren, das Schloss verschließen und sich seiner Gruppe anschließen.</p>
|
||||
<p>Euer Ruf hat darunter gelitten, doch noch ist nichts entschieden. Ein schlechter erster Eindruck kann überwunden werden, wenn eure nächsten Taten überzeugender sprechen als eure Worte.</p>
|
||||
<p>Rufpunkte werden abgezogen.</p>
|
||||
</div>
|
||||
@@ -136,6 +138,7 @@ export default function Riddle_3({
|
||||
]}/>
|
||||
<RiddleCompleteBanner points={halfPoints} win={true}></RiddleCompleteBanner>
|
||||
<p>Die letzten Worte verhallen an der Mauer. Einige haben gejubelt, andere blieben skeptisch, und so erkennt das Volk zwar, dass mehr in euch stecken könnte, schenkt euch sein Vertrauen aber noch nicht vollständig.</p>
|
||||
<p>Der Auserwählte darf nun das Banner wieder einrollen, zum Eisentor zurückkehren, das Schloss verschließen und sich seiner Gruppe anschließen.</p>
|
||||
<p>Euer Ruf verändert sich nur wenig. Von nun an werden die Menschen genau beobachten, ob euren Worten auch Taten folgen.</p>
|
||||
<p>Rufpunkte werden entsprechend eurer Bewertung angepasst.</p>
|
||||
</div>
|
||||
@@ -149,7 +152,8 @@ export default function Riddle_3({
|
||||
]}/>
|
||||
<RiddleCompleteBanner points={riddle.points} win={true}></RiddleCompleteBanner>
|
||||
<p>Kaum ist die Rede beendet, brandet unter dem Turm Zustimmung auf. Eure Worte haben Wirkung gezeigt, und das Volk sieht in euch nicht länger nur den Menschen, der Excalibur aus dem Stein gezogen hat, sondern erstmals einen möglichen Herrscher.</p>
|
||||
<p>Euer Ruf wächst – und mit ihm die Hoffnung, dass sich die Fehler der Vergangenheit nicht wiederholen müssen.</p>
|
||||
<p>Der Auserwählte darf nun das Banner wieder einrollen, zum Eisentor zurückkehren, das Schloss verschließen und sich seiner Gruppe anschließen.</p>
|
||||
<p>Euer Ruf wächst – und mit ihm die Hoffnung, dass sich die Fehler der Vergangenheit nicht wiederholen müssen. Wenn ihr erfahren wollt, warum im Volk dennoch Zweifel geblieben sind, müsst ihr weiterziehen.</p>
|
||||
<p>Ihr erhaltet zusätzliche Rufpunkte.</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import OldTextInput from "../OldTextInput";
|
||||
import VoiceOver from "../VoiceOver";
|
||||
import RiddleHintPage from "../RiddleHintPage";
|
||||
import { addCompletedRiddle } from "@/utils/completedRiddles";
|
||||
import ChargedButton from "../ChargedButton";
|
||||
|
||||
export default function Riddle_5({
|
||||
page,
|
||||
@@ -38,7 +39,7 @@ export default function Riddle_5({
|
||||
<div className={styles["content"]}>
|
||||
<p>Euer Ziel steht fest: Der Bund der Tafelrunde muss neu geschmiedet werden. Doch nach seinem Zerfall zogen sich viele Ritter aus dem Königreich zurück; einige suchten neue Herren, andere legten ihre Waffen nieder, und manche verschwanden dorthin, wo kaum noch jemand nach ihnen suchte.</p>
|
||||
<p>Auch Sir Parzival soll sich mit einigen der alten Ritter jenseits der bekannten Wege niedergelassen haben. Wo genau, weiß niemand, aber man munkelt, dass sich an einem kleinen Schlund der Name offenbaren soll. Auf eurer Karte endet das vertraute Land an einer Stelle, die nur mit einem einzigen Wort bezeichnet ist: „Unbekannt.“</p>
|
||||
<p>Wenn ihr die Ritter finden wollt, wagt euch zum Ort des Schlunds.</p>
|
||||
<p>Wenn ihr die Ritter finden wollt, wagt euch zum Ort des kleinen Schlunds.</p>
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
<OldButton red={false} onAction={() => setPage(1)}>WEITER</OldButton>
|
||||
@@ -64,7 +65,7 @@ export default function Riddle_5({
|
||||
onChange={(e) => setSolution(e.target.value)}
|
||||
value={solution}
|
||||
/>
|
||||
<OldButton red={false} onAction={() => {
|
||||
<ChargedButton red={false} onAction={() => {
|
||||
const s = solution.toLowerCase().trim();
|
||||
if (s.length < 2) {
|
||||
return;
|
||||
@@ -78,7 +79,7 @@ export default function Riddle_5({
|
||||
setPage(2);
|
||||
}
|
||||
addCompletedRiddle(riddle.step);
|
||||
}} disabled={false}>EINREICHEN</OldButton>
|
||||
}} disabled={false}>EINREICHEN</ChargedButton>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
|
||||
@@ -40,6 +40,7 @@ export default function Riddle_6({
|
||||
const [isHeartFast, setIsHeartFast] = useState(true);
|
||||
const closePopupRef = useRef<(() => void) | null>(null);
|
||||
const heartFastTimerRef = useRef<NodeJS.Timeout | null>(null);
|
||||
const popupTimerRef = useRef<NodeJS.Timeout | null>(null);
|
||||
|
||||
const voiceOverModeRef = useRef(voiceOverMode);
|
||||
useEffect(() => {
|
||||
@@ -47,22 +48,32 @@ export default function Riddle_6({
|
||||
}, [voiceOverMode]);
|
||||
|
||||
const handleClosePopup = () => {
|
||||
if (closePopupRef.current) {
|
||||
closePopupRef.current();
|
||||
} else {
|
||||
setPopupData(null);
|
||||
}
|
||||
};
|
||||
if (popupTimerRef.current) {
|
||||
clearTimeout(popupTimerRef.current);
|
||||
popupTimerRef.current = null;
|
||||
}
|
||||
|
||||
if (closePopupRef.current) {
|
||||
closePopupRef.current();
|
||||
} else {
|
||||
setPopupData(null);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!popupData || voiceOverMode === "on") return;
|
||||
if (!popupData) return;
|
||||
|
||||
const timer = setTimeout(() => {
|
||||
handleClosePopup();
|
||||
}, 9000);
|
||||
popupTimerRef.current = setTimeout(() => {
|
||||
handleClosePopup();
|
||||
}, 15000);
|
||||
|
||||
return () => clearTimeout(timer);
|
||||
}, [popupData, voiceOverMode]);
|
||||
return () => {
|
||||
if (popupTimerRef.current) {
|
||||
clearTimeout(popupTimerRef.current);
|
||||
popupTimerRef.current = null;
|
||||
}
|
||||
};
|
||||
}, [popupData]);
|
||||
|
||||
useEffect(() => {
|
||||
if (page !== 2 || mode === 'won') return;
|
||||
@@ -292,7 +303,8 @@ export default function Riddle_6({
|
||||
<RiddleCompleteBanner points={riddle.points} win={true}></RiddleCompleteBanner>
|
||||
<p>Endlich herrscht vollkommene Ruhe, und für einen kurzen Augenblick scheint selbst der Wald mit euch den Atem anzuhalten.</p>
|
||||
<p>Ihr habt verstanden, was Sir Galahad von einem Herrscher verlangt: Nicht jede Herausforderung wird durch Stärke gewonnen; manchmal zeigt sich wahre Größe darin, den richtigen Augenblick abzuwarten.</p>
|
||||
<p>Die Prüfung ist bestanden, und unter den alten Rittern beginnt sich die Nachricht zu verbreiten, dass der neue Auserwählte mehr besitzt als Excalibur – nämlich Selbstbeherrschung.</p>
|
||||
<p>Die Prüfung ist bestanden, und unter den alten Rittern beginnt sich die Nachricht zu verbreiten, dass der neue Auserwählte mehr besitzt als Excalibur - nämlich Selbstbeherrschung.</p>
|
||||
<p>Ihr gewinnt Rufpunkte.</p>
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
<OldButton red={false} disabled={false} onAction={() => exitFunction()}>ZURÜCK ZUR KARTE</OldButton>
|
||||
@@ -301,7 +313,7 @@ export default function Riddle_6({
|
||||
),
|
||||
(
|
||||
<div key={4}>
|
||||
<VoiceOver voiceOverMode={voiceOverMode} sources={[{ "src": "/res/tour/riddle_6/voiceovers/Erfolg.mp3", "type": "audio/mpeg" }]}/>
|
||||
<VoiceOver voiceOverMode={voiceOverMode} sources={[{ "src": "/res/tour/riddle_6/voiceovers/Skip.mp3", "type": "audio/mpeg" }]}/>
|
||||
<div className={styles["content"]}>
|
||||
<RiddleCompleteBanner points={riddle.skipPenaltyPoints} win={false}></RiddleCompleteBanner>
|
||||
<p>Ihr entscheidet euch, die Prüfung der Stille hinter euch zu lassen. Vielleicht fehlt euch die Geduld, vielleicht wollt ihr eure Reise einfach fortsetzen – doch die alten Ritter vergessen solche Entscheidungen nicht.</p>
|
||||
|
||||
@@ -12,6 +12,7 @@ import VoiceOver from "../VoiceOver";
|
||||
import { addPoints, takePoints } from "@/utils/points";
|
||||
import RiddleHintPage from "../RiddleHintPage";
|
||||
import { addCompletedRiddle } from "@/utils/completedRiddles";
|
||||
import ChargedButton from "../ChargedButton";
|
||||
|
||||
const Riddle_7_AR_View = dynamic(
|
||||
() => import('../Riddle_7_AR_View'),
|
||||
@@ -29,6 +30,7 @@ export default function Riddle_7({
|
||||
dismissHint,
|
||||
}: RiddleScreenControls) {
|
||||
|
||||
const [ showNextButton, setShowNextButton ] = useState(true);
|
||||
const [ selection, setSelection ] = useState(-1);
|
||||
|
||||
const pages = [
|
||||
@@ -80,11 +82,11 @@ export default function Riddle_7({
|
||||
(
|
||||
<div key={2}>
|
||||
<div className={styles["content"]}>
|
||||
<Riddle_7_AR_View />
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
<OldButton red={false} disabled={false} onAction={() => setPage(3)}>URTEIL SPRECHEN</OldButton>
|
||||
<Riddle_7_AR_View setShowNextButton={setShowNextButton}/>
|
||||
</div>
|
||||
{ showNextButton ? <div className={styles["buttons"]}>
|
||||
<OldButton red={false} disabled={false} onAction={() => setPage(3)} style={{zIndex: 9998}}>URTEIL SPRECHEN</OldButton>
|
||||
</div> : null }
|
||||
</div>
|
||||
),
|
||||
(
|
||||
@@ -104,7 +106,7 @@ export default function Riddle_7({
|
||||
<SelectionButton selected={selection === 2} onSelect={() => setSelection(2)} klein={true}>Sir Garrick, die Torwache</SelectionButton>
|
||||
<SelectionButton selected={selection === 3} onSelect={() => setSelection(3)} klein={true}>Edmund, der Schreiber</SelectionButton>
|
||||
</div>
|
||||
<OldButton red={false} disabled={selection === -1} onAction={() => {
|
||||
<ChargedButton red={false} disabled={selection === -1} onAction={() => {
|
||||
if (selection === 3) {
|
||||
addPoints(riddle.points);
|
||||
setPage(4);
|
||||
@@ -113,7 +115,7 @@ export default function Riddle_7({
|
||||
setPage(5);
|
||||
}
|
||||
addCompletedRiddle(riddle.step);
|
||||
}}>ÜBERPRÜFEN!</OldButton>
|
||||
}}>ÜBERPRÜFEN!</ChargedButton>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
|
||||
@@ -56,7 +56,7 @@ export default function Riddle_8({
|
||||
<div className={styles["content"]}>
|
||||
<p>Setzt den Würfel auf das markierte Startfeld und richtet ihn wie vorgegeben aus.</p>
|
||||
<p>Kippt ihn anschließend nur auf direkt benachbarte Felder. Die dicken Linien dürfen außerdem nicht überquert werden.</p>
|
||||
<p>Das Symbol, das oben auf dem Würfel liegt, bestimmt, auf welches Symbol ihr als Nächstes ziehen dürft.</p>
|
||||
<p>Das Symbol, das oben auf dem Würfel liegt, bestimmt, auf welches Symbol ihr als Nächstes kippen dürft.</p>
|
||||
<p>Euer Ziel ist das Feld, dessen Symbol zusätzlich mit einem <b>Stern</b> gekennzeichnet ist.</p>
|
||||
<p>Sobald der Würfel dort angekommen ist, hebt ihn an. Das Symbol auf seiner Unterseite ist eure Lösung.</p>
|
||||
<div className="center-flex">
|
||||
|
||||
@@ -11,6 +11,8 @@ import { addPoints, takePoints } from "@/utils/points";
|
||||
import RiddleHintPage from "../RiddleHintPage";
|
||||
import ChargedButton from "../ChargedButton";
|
||||
import { addCompletedRiddle } from "@/utils/completedRiddles";
|
||||
import { useLocalStorage } from "@/hooks/useLocalStorage";
|
||||
import { PREF } from "@/utils/const";
|
||||
|
||||
export default function Riddle_9({
|
||||
page,
|
||||
@@ -22,6 +24,7 @@ export default function Riddle_9({
|
||||
requestingHint,
|
||||
dismissHint,
|
||||
}: RiddleScreenControls) {
|
||||
const [ screenPageStr, setScreenPage ] = useLocalStorage(PREF.step, "");
|
||||
const [answer, setAnswer] = useState("");
|
||||
|
||||
const pages = [
|
||||
@@ -41,7 +44,7 @@ export default function Riddle_9({
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
<OldButton red={false} onAction={() => {
|
||||
showBanner(false);
|
||||
showBanner(true);
|
||||
setPage(1);
|
||||
}}>WEITER</OldButton>
|
||||
</div>
|
||||
@@ -56,8 +59,7 @@ export default function Riddle_9({
|
||||
}
|
||||
]}/>
|
||||
<div className={styles["content"]}>
|
||||
<p>Auf Tisch, Stuhl, Bechern und Gedecken findet ihr verschiedene <b>Symbole</b>.</p>
|
||||
<p>Die Buchstaben ergeben das Wort, das Artus für die neue Tafelrunde hinterlassen hat.</p>
|
||||
<p>Auf Tisch, Stuhl, Bechern und Gedecken findet ihr verschiedene Symbole.</p>
|
||||
<p style={{fontWeight: "bold", textAlign: "center"}}>Unter welchem Motto steht die erneuerte Tafelrunde?</p>
|
||||
<div className="center-flex">
|
||||
<OldTextInput
|
||||
@@ -103,7 +105,9 @@ export default function Riddle_9({
|
||||
<p>Ein weiterer Schritt zur Krone ist getan.</p>
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
<ChargedButton red={false} disabled={false} onAction={() => exitFunction()}>ERGEBNIS ANZEIGEN</ChargedButton>
|
||||
<ChargedButton red={false} disabled={false} onAction={() => {
|
||||
setScreenPage("3");
|
||||
}}>ERGEBNIS ANZEIGEN</ChargedButton>
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
@@ -122,7 +126,9 @@ export default function Riddle_9({
|
||||
<p>Euer Fehler kostet euch Ansehen, doch die Bedeutung des Vermächtnisses ist nun klar.</p>
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
<ChargedButton red={false} disabled={false} onAction={() => exitFunction()}>ERGEBNIS ANZEIGEN</ChargedButton>
|
||||
<ChargedButton red={false} disabled={false} onAction={() => {
|
||||
setScreenPage("3");
|
||||
}}>ERGEBNIS ANZEIGEN</ChargedButton>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
- [ ] Turn Riddles into seperate, dynamically loaded, components
|
||||
- [ ] Create script to update riddles
|
||||
- [ ] Link components to Database
|
||||
- [ ] Preload required riddles at start of tour
|
||||
@@ -3,31 +3,48 @@ import { PREF } from "@/utils/const"
|
||||
import ChargedButton from "../ChargedButton";
|
||||
import { usePermissions } from "@/hooks/usePermission";
|
||||
import styles from "@/css/Intro.module.css";
|
||||
import { ChangeEvent, InputEvent, MouseEvent, MouseEventHandler, PointerEvent, useRef, useState } from "react";
|
||||
import { ChangeEvent, InputEvent, MouseEvent, MouseEventHandler, PointerEvent, useMemo, useRef, useState } from "react";
|
||||
import Image from "next/image";
|
||||
import PermissionCheck from "../PermissionCheck";
|
||||
import { PermissionStateResult } from "@/utils/permissions";
|
||||
import StyledContainer from "../StyledContainer";
|
||||
import OldButton from "../OldButton";
|
||||
import OldTextInput from "../OldTextInput";
|
||||
|
||||
const MIN_PLAYERS = 2;
|
||||
const MAX_PLAYERS = 8;
|
||||
import clsx from "clsx";
|
||||
import { MAX_PLAYERS, MIN_PLAYERS } from "@/utils/players";
|
||||
import { isDemoMode, setDemoMode } from "@/utils/demoMode";
|
||||
|
||||
export default function Intro() {
|
||||
const [ stepStr, setStep ] = useLocalStorage(PREF.step, "0");
|
||||
const [ , setPoints ] = useLocalStorage(PREF.points, "0");
|
||||
const [ , setCompletedRiddles ] = useLocalStorage(PREF.completed_riddles, "");
|
||||
const [ , setPlayers ] = useLocalStorage(PREF.players, "");
|
||||
const [ , setWorthyWords ] = useLocalStorage(PREF.worthyWords, "");
|
||||
const [ , setWorthyWords ] = useLocalStorage(PREF.worthy_words, "");
|
||||
const [ rewatchScreen, setRewatchScreen ] = useState(false);
|
||||
const [ enterPlayerCount, setEnterPlayerCount ] = useState(false);
|
||||
const [ videoEnded, setVideoEnded ] = useState(false);
|
||||
const [ videoPaused, setVideoPaused ] = useState(false);
|
||||
const [ voiceOverState, setVoiceOverState ] = useLocalStorage(PREF.voice_over, "off");
|
||||
const [ boughtHintsStr, setBoughtHints ] = useLocalStorage(PREF.bought_hints, "");
|
||||
const [ reachedRiddlesStr, setReachedRiddles ] = useLocalStorage(PREF.reached_riddles, "");
|
||||
const introVideoRef = useRef<HTMLVideoElement | null>(null);
|
||||
const [ granted, setGranted ] = useState(false);
|
||||
|
||||
const [ , setPlayerCount ] = useLocalStorage(PREF.playerCount, "");
|
||||
const [ demoModeStr, ] = useLocalStorage(PREF.demo_mode, "");
|
||||
const demoMode = useMemo(() => isDemoMode(demoModeStr), [demoModeStr]);
|
||||
|
||||
const goToTheMap = () => {
|
||||
setPoints("0");
|
||||
setCompletedRiddles("");
|
||||
setBoughtHints("");
|
||||
setPlayers("");
|
||||
setWorthyWords("");
|
||||
setReachedRiddles("");
|
||||
setVoiceOverState("on");
|
||||
setStep("2");
|
||||
};
|
||||
|
||||
const [ , setPlayerCount ] = useLocalStorage(PREF.player_count, "");
|
||||
const [ playerCountStr, setPlayerCountStr] = useState("");
|
||||
|
||||
const validPlayerCount = (number: number) => {
|
||||
@@ -72,7 +89,7 @@ export default function Intro() {
|
||||
objectFit: "fill",
|
||||
zIndex: 1
|
||||
}} alt="Background" loading="eager"/>
|
||||
<StyledContainer innerClassName={styles["permission-container"]}>
|
||||
<StyledContainer innerClassName={styles["container"]}>
|
||||
{ !enterPlayerCount || !granted ?
|
||||
<div>
|
||||
<PermissionCheck onRefresh={handlePermissions}></PermissionCheck>
|
||||
@@ -111,6 +128,7 @@ export default function Intro() {
|
||||
}} holdDuration={500} disabled={!isPlayerCountValid}>
|
||||
ABENTEUER BEGINNEN!
|
||||
</ChargedButton>
|
||||
<p className={clsx("lancelot-italic")} style={{marginTop: "1rem"}}>Zum Aufladen den Button gedrückt halten</p>
|
||||
</div>
|
||||
:
|
||||
<div className={styles["intro-video-container"]}>
|
||||
@@ -133,8 +151,9 @@ export default function Intro() {
|
||||
}}
|
||||
playsInline={true}
|
||||
>
|
||||
<source src="/res/intro/testvid.webm" type="video/webm"/>
|
||||
<source src="/res/intro/intro.mp4" type="video/mp4"/>
|
||||
</video>
|
||||
{ demoMode ? <ChargedButton onAction={() => { goToTheMap(); }}>DEMO SKIP</ChargedButton> : null }
|
||||
{ !videoEnded && videoPaused ?
|
||||
<div className={styles["pause-screen"]}>
|
||||
<Image src="/icons/pause.svg" alt="Pause Icon" width={48} height={48}/>
|
||||
@@ -150,14 +169,10 @@ export default function Intro() {
|
||||
introVideoRef.current.play();
|
||||
setVideoEnded(false);
|
||||
}
|
||||
}}>Video wiederholen?</ChargedButton>
|
||||
}} whiteText={true}>Video wiederholen?</ChargedButton>
|
||||
<ChargedButton holdDuration={500} onAction={() => {
|
||||
setPoints("0");
|
||||
setCompletedRiddles("");
|
||||
setPlayers("");
|
||||
setWorthyWords("");
|
||||
setStep("2");
|
||||
}}>Wir sind bereit!</ChargedButton>
|
||||
goToTheMap();
|
||||
}} whiteText={true}>Wir sind bereit!</ChargedButton>
|
||||
</div> : null }
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
import { useLocalStorage } from "@/hooks/useLocalStorage"
|
||||
import { PREF } from "@/utils/const"
|
||||
import ChargedButton from "../ChargedButton";
|
||||
import styles from "@/css/Outro.module.css";
|
||||
import { ChangeEvent, InputEvent, MouseEvent, MouseEventHandler, PointerEvent, useEffect, useMemo, useRef, useState } from "react";
|
||||
import Image from "next/image";
|
||||
import StyledContainer from "../StyledContainer";
|
||||
import OldButton from "../OldButton";
|
||||
import OldTextInput from "../OldTextInput";
|
||||
import clsx from "clsx";
|
||||
import { getPoints } from "@/utils/points";
|
||||
import VoiceOver from "../VoiceOver";
|
||||
import { VoiceOverMode } from "@/types/voiceOverMode";
|
||||
import { isDemoMode } from "@/utils/demoMode";
|
||||
import { finishSession } from "@/utils/sessionHandler";
|
||||
|
||||
export default function Outro() {
|
||||
const [ tourCode, setTourCode ] = useLocalStorage(PREF.code, "");
|
||||
const [ resultPage, setResultPage ] = useState(0);
|
||||
const [ stepStr, setStep ] = useLocalStorage(PREF.step, "0");
|
||||
const [ pointsStr, setPoints ] = useLocalStorage(PREF.points, "0");
|
||||
const [ playersStr, setPlayers ] = useLocalStorage(PREF.players, "");
|
||||
const [ worthyWordsStr, setWorthyWords ] = useLocalStorage(PREF.worthy_words, "");
|
||||
const [ rewatchScreen, setRewatchScreen ] = useState(false);
|
||||
const [ videoEnded, setVideoEnded ] = useState(false);
|
||||
const [ videoPaused, setVideoPaused ] = useState(false);
|
||||
const [ voiceOverState, setVoiceOverState ] = useLocalStorage(PREF.voice_over, "off");
|
||||
const [ boughtHintsStr, setBoughtHints ] = useLocalStorage(PREF.bought_hints, "");
|
||||
const points = useMemo(() => {
|
||||
return getPoints();
|
||||
}, [pointsStr]);
|
||||
const outroVideoRef = useRef<HTMLVideoElement | null>(null);
|
||||
|
||||
const [ demoModeStr, ] = useLocalStorage(PREF.demo_mode, "");
|
||||
const demoMode = useMemo(() => isDemoMode(demoModeStr), [demoModeStr]);
|
||||
|
||||
const handleVideoClick = (e: PointerEvent<HTMLVideoElement>): boolean => {
|
||||
e.currentTarget.play();
|
||||
return true;
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!tourCode || tourCode.length === 0 || demoMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
finishSession(tourCode).then((res) => {
|
||||
if (!res.ok) {
|
||||
finishSession(tourCode).finally(() => {
|
||||
setTourCode("");
|
||||
});
|
||||
} else {
|
||||
setTourCode("");
|
||||
}
|
||||
}).catch(() => {
|
||||
setTourCode("");
|
||||
});
|
||||
}, [tourCode]);
|
||||
|
||||
const pages = [
|
||||
(
|
||||
<div className={styles["outro-video-container"]} key={0}>
|
||||
<video
|
||||
ref={outroVideoRef}
|
||||
disablePictureInPicture={true}
|
||||
autoPlay={true}
|
||||
loop={false}
|
||||
autoFocus={true}
|
||||
width={"100%"}
|
||||
onEnded={() => setVideoEnded(true)}
|
||||
onAbort={() => setVideoEnded(true)}
|
||||
onError={() => setVideoEnded(true)}
|
||||
onPause={() => setVideoPaused(true)}
|
||||
onPlay={() => setVideoPaused(false)}
|
||||
onClick={handleVideoClick}
|
||||
onContextMenu={(e) => {
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}}
|
||||
playsInline={true}
|
||||
>
|
||||
<source src={points <= 3000 ? "/res/outro/ending_1.mp4" : points <= 7000 ? "/res/outro/ending_2.mp4" : "/res/outro/ending_3.mp4"} type="video/mp4"/>
|
||||
</video>
|
||||
{ demoMode ? <ChargedButton onAction={() => { setResultPage(1); }}>DEMO SKIP</ChargedButton> : null }
|
||||
{ !videoEnded && videoPaused ?
|
||||
<div className={styles["pause-screen"]}>
|
||||
<Image src="/icons/pause.svg" alt="Pause Icon" width={48} height={48}/>
|
||||
</div>
|
||||
:
|
||||
null
|
||||
}
|
||||
{ videoEnded ? <div className={styles["rewatch-controls"]}>
|
||||
<ChargedButton holdDuration={500} onAction={() => {
|
||||
if (outroVideoRef.current) {
|
||||
outroVideoRef.current.pause();
|
||||
outroVideoRef.current.currentTime = 0;
|
||||
outroVideoRef.current.play();
|
||||
setVideoEnded(false);
|
||||
}
|
||||
}} whiteText={true}>Video wiederholen?</ChargedButton>
|
||||
<ChargedButton holdDuration={500} onAction={() => {
|
||||
setResultPage(1);
|
||||
}} whiteText={true}>Ergebnisse ansehen!</ChargedButton>
|
||||
</div> : null }
|
||||
</div>
|
||||
),
|
||||
(
|
||||
<div key={1} style={{width: "100%", height: "100%"}}>
|
||||
{ points <= 3000 ?
|
||||
<div className={styles["result-page"]}>
|
||||
<VoiceOver voiceOverMode={voiceOverState as VoiceOverMode}
|
||||
sources={[
|
||||
{
|
||||
src: "/res/outro/voiceovers/End_1.mp3",
|
||||
type: "audio/mpeg"
|
||||
}
|
||||
]}
|
||||
/>
|
||||
<h2>Die schwere Krone</h2>
|
||||
<p>Die Krönung ist vollzogen, Excalibur hat seinen Träger gefunden und die Ritter der Tafelrunde sind an ihre Plätze zurückgekehrt. Auf Stettenfels sitzt wieder ein König auf dem Thron, doch die Freude über diesen Tag wird von spürbarer Zurückhaltung begleitet.</p>
|
||||
<p>Das Volk hat eure Entscheidungen aufmerksam verfolgt, eure Erfolge gesehen und auch jene Augenblicke nicht vergessen, in denen Zweifel entstanden sind. Die Krone gehört nun euch, doch Vertrauen lässt sich nicht an einem einzigen Tag erringen.</p>
|
||||
<p>Ob das Reich euch eines Tages aus voller Überzeugung folgen wird, entscheidet sich nicht durch diese Krönung, sondern durch alles, was von nun an auf sie folgt.</p>
|
||||
<p>Ihr habt die Tour mit <b>{points}</b> Rufpunkten abgeschlossen.</p>
|
||||
</div>
|
||||
: points < 7000 ?
|
||||
<div className={styles["result-page"]}>
|
||||
<VoiceOver voiceOverMode={voiceOverState as VoiceOverMode}
|
||||
sources={[
|
||||
{
|
||||
src: "/res/outro/voiceovers/End_2.mp3",
|
||||
type: "audio/mpeg"
|
||||
}
|
||||
]}
|
||||
/>
|
||||
<h2>Der geachtete König</h2>
|
||||
<p>Die Krönung ist vollzogen, Excalibur hat seinen Träger gefunden und die Tafelrunde ist wieder vereint. Auf Stettenfels beginnt eine neue Herrschaft, und in den Gesichtern der Menschen liegt zum ersten Mal seit langer Zeit mehr Hoffnung als Furcht.</p>
|
||||
<p>Nicht jeder Zweifel ist verschwunden, doch ihr habt bewiesen, dass ihr nicht nur führen, sondern auch zuhören, entscheiden und andere hinter euch vereinen könnt. Das Volk weiß, dass ihr nicht fehlerlos seid, erkennt aber ebenso, dass ihr bereit seid, Verantwortung zu tragen.</p>
|
||||
<p>So endet an diesem Tag die Zeit des Auserwählten, und es beginnt die Zeit eines Königs, dem man zu folgen bereit ist.</p>
|
||||
<p>Ihr habt die Tour mit <b>{points}</b> Rufpunkten abgeschlossen.</p>
|
||||
</div>
|
||||
:
|
||||
<div className={styles["result-page"]}>
|
||||
<VoiceOver voiceOverMode={voiceOverState as VoiceOverMode}
|
||||
sources={[
|
||||
{
|
||||
src: "/res/outro/voiceovers/End_3.mp3",
|
||||
type: "audio/mpeg"
|
||||
}
|
||||
]}
|
||||
/>
|
||||
<h2>Der würdige König</h2>
|
||||
<p>Die Krönung ist vollzogen, Excalibur hat seinen Träger gefunden und die Ritter der Tafelrunde stehen geschlossen an eurer Seite. Als ihr euch erhebt, geht ein Ruck durch den Saal, und nicht nur die Ritter, sondern auch das Volk begegnet euch mit offenem Vertrauen.</p>
|
||||
<p>Auf eurer Reise habt ihr mehr getan, als Prüfungen zu bestehen. Ihr habt Zweifel überwunden, gerecht geurteilt und einen zerbrochenen Bund wieder zusammengeführt. Gerade darin zeigt sich, dass nicht Excalibur allein einen König bestimmt, sondern die Entscheidungen, die er trifft, und die Menschen, die ihm aus freiem Willen folgen.</p>
|
||||
<p>So beginnt mit diesem Tag nicht nur eine neue Herrschaft, sondern die Geschichte eines Königs, den das Reich aus Überzeugung anerkennt.</p>
|
||||
<p>Ihr habt die Tour mit <b>{points}</b> Rufpunkten abgeschlossen.</p>
|
||||
</div>
|
||||
}
|
||||
{ demoMode ? <ChargedButton onAction={() => {
|
||||
localStorage.clear();
|
||||
setStep("0");
|
||||
}} style={{position: "absolute", scale: "0.75", top: "2%", left: "1%"}}>DEMO BEENDEN</ChargedButton> : null }
|
||||
</div>
|
||||
)
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="screen-container">
|
||||
<img src={"/bg/Hintergrund_ohne_Verzierung.webp"} style={{
|
||||
position: "absolute",
|
||||
top: 0,
|
||||
left: 0,
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
objectFit: "fill",
|
||||
zIndex: 1
|
||||
}} alt="Background" loading="eager"/>
|
||||
<StyledContainer innerClassName={styles["container"]} contentBarStyles={{height: resultPage === 1 ? "100%" : ""}} riddleDesign={resultPage === 1}>
|
||||
{ resultPage === 1 ? <div className={styles["action-bookmark"]}>
|
||||
<div style={{width: "32px", height: "24px", margin: "10px 20px 24px"}}>
|
||||
</div>
|
||||
<img src={voiceOverState === "off" ? "/icons/Vorlese-Icon.svg" : "/icons/Vorlese-Icon-leise.svg"} className={styles["bookmark-icon"]} style={{width: "32px", height: "24px", margin: "10px 20px 24px"}} onClick={() => {
|
||||
setVoiceOverState(voiceOverState === "off" ? "on" : "off");
|
||||
}} />
|
||||
</div> : null}
|
||||
{pages.length > resultPage && resultPage > -1 ? pages[resultPage] : <p>Invalid Page</p>}
|
||||
</StyledContainer>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { useLocalStorage } from "@/hooks/useLocalStorage"
|
||||
import { PREF } from "@/utils/const"
|
||||
import { API_PREFIX, PREF } from "@/utils/const"
|
||||
import ChargedButton from "../ChargedButton";
|
||||
import styles from "@/css/Tour.module.css";
|
||||
import MapView, { PlaceMarker } from "../MapView";
|
||||
@@ -16,22 +16,53 @@ import { MAX_POINTS, MIN_POINTS } from "@/utils/points";
|
||||
import { Riddle } from "@/types/riddle";
|
||||
import * as maplibregl from 'maplibre-gl';
|
||||
import { createStationName } from "@/utils/stringer";
|
||||
import { getRiddleData } from "@/utils/riddledata";
|
||||
import { fetchRiddleData, getRiddleData, setRiddleData } from "@/utils/riddledata";
|
||||
import { heartbeat } from "@/utils/sessionHandler";
|
||||
import { getCompletedRiddles } from "@/utils/completedRiddles";
|
||||
import { isDemoMode } from "@/utils/demoMode";
|
||||
import { addReachedRiddle, getReachedRiddles } from "@/utils/reachedRiddles";
|
||||
|
||||
export default function Tour() {
|
||||
const [ demoModeStr, ] = useLocalStorage(PREF.demo_mode, "");
|
||||
const demoMode = useMemo(() => isDemoMode(demoModeStr), [demoModeStr]);
|
||||
|
||||
const [ showTooFar, setShowTooFar ] = useState(false);
|
||||
const [ completedRiddlesStr, ] = useLocalStorage(PREF.completed_riddles, "");
|
||||
const [ riddleDataStr, ] = useLocalStorage(PREF.riddle_data, "");
|
||||
const riddleData: Riddle[] = useMemo(() => {
|
||||
return getRiddleData();
|
||||
}, [riddleDataStr]);
|
||||
//const riddleData: Riddle[] = [{"id":1,"name":"Der Hüter des Tores","step":0,"latitude":49.089155,"longitude":9.281336,"points":500,"failPenaltyPoints":0,"skipPenaltyPoints":0,"requiredDistance":40,"hints":[]},{"id":2,"name":"Das Schwert im Stein","step":1,"latitude":49.088559,"longitude":9.281426,"points":500,"failPenaltyPoints":0,"skipPenaltyPoints":0,"requiredDistance":25,"hints":[]},{"id":3,"name":"Die Stimme des neuen Königs","step":2,"latitude":49.089056,"longitude":9.282916,"points":1000,"failPenaltyPoints":250,"skipPenaltyPoints":250,"requiredDistance":40,"hints":[]},{"id":4,"name":"Stimmen am Wegesrand","step":3,"latitude":49.089822,"longitude":9.28523,"points":1000,"failPenaltyPoints":100,"skipPenaltyPoints":100,"requiredDistance":25,"hints":[{"id":1,"hint":"Genauer hinzuhören wird euch vermutlich nicht weiterbringen. Vielleicht müsst ihr vielmehr verändern, wie ihr das Gehörte betrachtet – oder was ihr mit einer Tonaufnahme auf eurem Smartphone anstellen könnt.","penaltyPoints":150,"hintOrder":0},{"id":2,"hint":"Die Bauern sprechen nicht unverständlich; ihr hört ihre Worte nur in der falschen Richtung. Nehmt die Tonspur auf und findet einen Weg, sie in umgekehrter Reihenfolge abzuspielen.","penaltyPoints":300,"hintOrder":1}]},{"id":5,"name":"Jenseits der bekannten Wege","step":4,"latitude":49.089916,"longitude":9.285864,"points":1000,"failPenaltyPoints":500,"skipPenaltyPoints":500,"requiredDistance":25,"hints":[{"id":3,"hint":"Der Name des unbekannten Ortes ist vor Ort bereits sichtbar. Haltet Ausschau nach einem prominent platzierten Holzschild in der Nähe des unbekannten Gebietes; dort findet ihr die Lösung, die ihr eingeben müsst.","penaltyPoints":300,"hintOrder":0}]},{"id":6,"name":"Die Prüfung der Stille","step":5,"latitude":49.092468,"longitude":9.285891,"points":500,"failPenaltyPoints":0,"skipPenaltyPoints":500,"requiredDistance":20,"hints":[]},{"id":7,"name":"Lancelots Urteil","step":6,"latitude":49.093505,"longitude":9.282669,"points":1500,"failPenaltyPoints":750,"skipPenaltyPoints":750,"requiredDistance":25,"hints":[{"id":4,"hint":"Nicht nur das, was ihr am Tatort findet, kann einen Verdächtigen überführen; auch das, was dort fehlt, kann entscheidend sein. Oswin, der Stallknecht, war draußen im Regen und im Matsch unterwegs, doch der Boden vor der aufgebrochenen Truhe ist trocken und sauber.\n\nWelche Spuren hätten dort zu finden sein müssen, wenn Oswin tatsächlich der Täter gewesen wäre?","penaltyPoints":100,"hintOrder":0},{"id":5,"hint":"An der aufgebrochenen Schatulle befindet sich eine besonders auffällige Spur: Blut. Zwei der vier Verdächtigen haben eine verletzte Hand.\n\nKonzentriert euch auf diese beiden und vergleicht ihre Aussagen besonders genau mit dem übrigen Beweismaterial. Eine Verletzung allein beweist nichts, doch zusammen mit den anderen Spuren kann sie entscheidend sein.","penaltyPoints":200,"hintOrder":1}]},{"id":8,"name":"Merlins Prüfung","step":7,"latitude":49.089782,"longitude":9.281705,"points":2000,"failPenaltyPoints":500,"skipPenaltyPoints":500,"requiredDistance":25,"hints":[{"id":6,"hint":"Wenn ihr nicht weiterkommt, betrachtet nicht nur das nächste passende Symbol, sondern auch, wie sich der Würfel durch jeden Zug dreht. Der scheinbar direkte Weg kann in eine Sackgasse führen.\n\nPlant mehrere Züge voraus und denkt daran: Die dicken Linien dürfen niemals überquert werden.","penaltyPoints":200,"hintOrder":0}]},{"id":9,"name":"Die Tafelrunde","step":8,"latitude":49.089098,"longitude":9.282348,"points":2000,"failPenaltyPoints":1000,"skipPenaltyPoints":1000,"requiredDistance":25,"hints":[]}];
|
||||
|
||||
useEffect(() => {
|
||||
fetchRiddleData().then((riddleData) => {
|
||||
if (riddleData === null) {
|
||||
alert("Could not update Riddle Data!");
|
||||
return;
|
||||
}
|
||||
setRiddleData(riddleData["riddles"]);
|
||||
});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!riddleData) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (demoMode) {
|
||||
const markers = [];
|
||||
const riddles = riddleData.sort((a, b) => a.step - b.step)
|
||||
for (let i = 0; i < riddles.length; ++i) {
|
||||
markers.push({
|
||||
id: riddles[i].id,
|
||||
lng: riddles[i].longitude,
|
||||
lat: riddles[i].latitude
|
||||
});
|
||||
}
|
||||
setMarkers(markers);
|
||||
return;
|
||||
}
|
||||
|
||||
const completedRiddles = getCompletedRiddles();
|
||||
const nextStep = completedRiddles.length;
|
||||
|
||||
@@ -45,7 +76,7 @@ export default function Tour() {
|
||||
});
|
||||
}
|
||||
setMarkers(markers);
|
||||
}, [riddleData, completedRiddlesStr]);
|
||||
}, [riddleData, completedRiddlesStr, demoMode]);
|
||||
|
||||
const [ stepStr, setStep ] = useLocalStorage(PREF.step, "0");
|
||||
const [ activeRiddle, setActiveRiddle ] = useState<Riddle | null>(null);
|
||||
@@ -57,10 +88,11 @@ export default function Tour() {
|
||||
const [ markers, setMarkers ] = useState<PlaceMarker[]>([]);
|
||||
const { gpsStatus, cameraStatus } = usePermissions();
|
||||
const points = Number.parseInt(pointsStr);
|
||||
const [ worthyAnswersStr, ] = useLocalStorage(PREF.worthyWords, "");
|
||||
const [ boughtHintsStr, ] = useLocalStorage(PREF.boughtHints, "");
|
||||
const [ playerCountStr, ] = useLocalStorage(PREF.playerCount, "");
|
||||
const [ voiceOverStr, ] = useLocalStorage(PREF.voiceover, "");
|
||||
const [ worthyAnswersStr, ] = useLocalStorage(PREF.worthy_words, "");
|
||||
const [ boughtHintsStr, ] = useLocalStorage(PREF.bought_hints, "");
|
||||
const [ playerCountStr, ] = useLocalStorage(PREF.player_count, "");
|
||||
const [ voiceOverStr, ] = useLocalStorage(PREF.voice_over, "");
|
||||
const [ reachedRiddlesStr, ] = useLocalStorage(PREF.reached_riddles, "");
|
||||
|
||||
const permissionsGranted = gpsStatus === "granted" && cameraStatus === "granted";
|
||||
|
||||
@@ -76,26 +108,36 @@ export default function Tour() {
|
||||
|
||||
const [ code, ] = useLocalStorage(PREF.code, "");
|
||||
|
||||
/*useEffect(() => {
|
||||
useEffect(() => {
|
||||
if (demoMode) return;
|
||||
|
||||
if (code.length === 0) {
|
||||
return;
|
||||
}
|
||||
const intervalId = setInterval(() => {
|
||||
|
||||
const doHeartbeat = () => {
|
||||
heartbeat({
|
||||
"playerCount": playerCountStr,
|
||||
"player_count": playerCountStr,
|
||||
"players": players,
|
||||
"worthy_answers": worthyAnswersStr,
|
||||
"completed_riddles": completedRiddlesStr,
|
||||
"points": pointsStr,
|
||||
"boughtHints": boughtHintsStr,
|
||||
"voiceOverStr": voiceOverStr
|
||||
"bought_hints": boughtHintsStr,
|
||||
"voice_over": voiceOverStr,
|
||||
"reached_riddles": reachedRiddlesStr,
|
||||
}, code);
|
||||
}, 2000);
|
||||
// TODO: Check if Code is valid.
|
||||
};
|
||||
|
||||
const intervalId = setInterval(() => {
|
||||
doHeartbeat();
|
||||
}, 50000);
|
||||
doHeartbeat();
|
||||
|
||||
return () => {
|
||||
clearInterval(intervalId);
|
||||
};
|
||||
}, [playerCountStr, players, worthyAnswersStr, completedRiddlesStr, pointsStr, boughtHintsStr, voiceOverStr]);*/
|
||||
}, [playerCountStr, players, worthyAnswersStr, completedRiddlesStr, pointsStr, boughtHintsStr, voiceOverStr]);
|
||||
|
||||
const selectedActiveRiddleData = clickedMarker !== null ? riddleData.find(v => v.id === clickedMarker) as Riddle : null;
|
||||
|
||||
@@ -131,8 +173,11 @@ export default function Tour() {
|
||||
</div>
|
||||
<div className={styles["main-content"]}>
|
||||
<div className={styles["map"]}>
|
||||
<MapView markers={markers} onMarkerClick={(marker, position) => {
|
||||
console.log(marker, position);
|
||||
<MapView markers={markers} triggerGeolocation={!demoMode} onMarkerClick={(marker, position) => {
|
||||
if (demoMode) {
|
||||
setClickedMarker(marker.id);
|
||||
return;
|
||||
}
|
||||
if (!position) {
|
||||
return;
|
||||
}
|
||||
@@ -148,15 +193,20 @@ export default function Tour() {
|
||||
|
||||
const distanceMeters = userLngLat.distanceTo(markerLngLat);
|
||||
const isNearby = distanceMeters <= r.requiredDistance;
|
||||
const reachedRiddles = getReachedRiddles();
|
||||
const reachedAlready = reachedRiddles.includes(r.step);
|
||||
|
||||
if (isNearby) {
|
||||
if (isNearby || demoMode || reachedAlready) {
|
||||
setClickedMarker(marker.id);
|
||||
if (!reachedAlready) {
|
||||
addReachedRiddle(r.step);
|
||||
}
|
||||
} else {
|
||||
alert(`Ihr seid noch zu weit entfernt!`);
|
||||
setShowTooFar(true);
|
||||
}
|
||||
}}></MapView>
|
||||
</div>
|
||||
<div className={styles["riddle-overlay"]} style={{display: clickedMarker !== null ? "" : "none"}}>
|
||||
{ clickedMarker && <div className={styles["riddle-overlay"]}>
|
||||
{ activeRiddle === null ?
|
||||
<OldPopUp onDismiss={dismissFunc}>
|
||||
<div style={{textAlign: "center", width: "100%"}}>
|
||||
@@ -176,7 +226,23 @@ export default function Tour() {
|
||||
:
|
||||
<RiddleScreen onDismiss={_dismissFunc} riddle={activeRiddle}></RiddleScreen>
|
||||
}
|
||||
</div>
|
||||
</div> }
|
||||
{ showTooFar && <div className={styles["riddle-overlay"]}>
|
||||
<OldPopUp onDismiss={() => setShowTooFar(false)}>
|
||||
<div style={{textAlign: "center", width: "100%"}}>
|
||||
<p className="lancelot-regular" style={{fontSize: "1.3rem", marginTop: "8px"}}>Ihr seid leider noch zu weit von der Station entfernt!</p>
|
||||
<OldButton
|
||||
red={true}
|
||||
long={true}
|
||||
style={{margin: "auto", marginTop: "16px"}}
|
||||
onAction={(e) => {
|
||||
setShowTooFar(false);
|
||||
e.stopPropagation();
|
||||
}}
|
||||
>SCHLIEßEN</OldButton>
|
||||
</div>
|
||||
</OldPopUp>
|
||||
</div> }
|
||||
{ !permissionsGranted ?
|
||||
<div className={styles["permissions-overlay"]}>
|
||||
<PermissionCheck className={styles["permission-check"]}></PermissionCheck>
|
||||
@@ -184,6 +250,15 @@ export default function Tour() {
|
||||
: null
|
||||
}
|
||||
</div>
|
||||
{ demoMode ? <ChargedButton style={{
|
||||
position: "absolute",
|
||||
bottom: "5%",
|
||||
left: "1%",
|
||||
zIndex: 4
|
||||
}} onAction={() => {
|
||||
localStorage.clear();
|
||||
setStep("0");
|
||||
}}>DEMO BEENDEN</ChargedButton> : null }
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -4,13 +4,16 @@ import { ChangeEvent, SyntheticEvent, useEffect, useRef, useState } from "react"
|
||||
import styles from "../../css/WelcomeScreen.module.css";
|
||||
import ChargedButton from "../ChargedButton";
|
||||
import { useLocalStorage } from "@/hooks/useLocalStorage";
|
||||
import { PREF } from "@/utils/const";
|
||||
import { API_PREFIX, HTTP_SCHEME, PREF } from "@/utils/const";
|
||||
import StyledContainer from "../StyledContainer";
|
||||
import clsx from "clsx";
|
||||
import OldButton from "../OldButton";
|
||||
import OldTextInput from "../OldTextInput";
|
||||
import { checkCode } from "@/utils/codeChecker";
|
||||
import { setRiddleData } from "@/utils/riddledata";
|
||||
import { fetchRiddleData, setRiddleData } from "@/utils/riddledata";
|
||||
import { setSessionData } from "@/utils/sessionHandler";
|
||||
import { setDemoMode } from "@/utils/demoMode";
|
||||
import { Riddle } from "@/types/riddle";
|
||||
|
||||
const CODE_LENGTH = 9;
|
||||
const COOLDOWN_MS = 3000;
|
||||
@@ -26,12 +29,12 @@ export default function WelcomeScreen() {
|
||||
const [, setStep ] = useLocalStorage(PREF.step, "0");
|
||||
|
||||
const [ , setPlayers ] = useLocalStorage(PREF.players, "");
|
||||
const [ , setPlayerCount ] = useLocalStorage(PREF.playerCount, "");
|
||||
const [ , setPlayerCount ] = useLocalStorage(PREF.player_count, "");
|
||||
const [ , setPoints ] = useLocalStorage(PREF.points, "");
|
||||
const [ , setCompletedRiddles ] = useLocalStorage(PREF.completed_riddles, "");
|
||||
const [ , setWorthyAnswers ] = useLocalStorage(PREF.worthyWords, "");
|
||||
const [ , setBoughtHints ] = useLocalStorage(PREF.boughtHints, "");
|
||||
const [ , setVoiceOver ] = useLocalStorage(PREF.voiceover, "");
|
||||
const [ , setWorthyAnswers ] = useLocalStorage(PREF.worthy_words, "");
|
||||
const [ , setBoughtHints ] = useLocalStorage(PREF.bought_hints, "");
|
||||
const [ , setVoiceOver ] = useLocalStorage(PREF.voice_over, "");
|
||||
|
||||
const checkCooldown = () => {
|
||||
if (cooldownRef.current === -1) return false;
|
||||
@@ -71,6 +74,20 @@ export default function WelcomeScreen() {
|
||||
setLastSubmitTs(cooldownRef.current);
|
||||
setCode(value);
|
||||
|
||||
if (value === "6MEGZDEI2") {
|
||||
const riddleData = await fetchRiddleData();
|
||||
|
||||
if (riddleData === null) {
|
||||
alert("Could not fetch RiddleData!");
|
||||
return;
|
||||
}
|
||||
|
||||
setRiddleData(riddleData["riddles"]);
|
||||
setDemoMode(true);
|
||||
setStep("1");
|
||||
return;
|
||||
}
|
||||
|
||||
const data = await checkCode(value);
|
||||
|
||||
if (data === null || data["riddles"] === undefined || data["riddles"] === null || data["riddles"].length < 1) {
|
||||
@@ -79,43 +96,15 @@ export default function WelcomeScreen() {
|
||||
}
|
||||
|
||||
console.log(data);
|
||||
setDemoMode(false);
|
||||
setRiddleData(data["riddles"]);
|
||||
/*if (data["session"] !== undefined && data["session"] !== null) {
|
||||
if (data["session"] !== undefined && data["session"] !== null) {
|
||||
const s = JSON.parse(data["session"]);
|
||||
|
||||
"playerCount": playerCountStr,
|
||||
"players": players,
|
||||
"worthy_answers": worthyAnswersStr,
|
||||
"completed_riddles": completedRiddlesStr,
|
||||
"points": pointsStr,
|
||||
"boughtHints": boughtHintsStr,
|
||||
"voiceOverStr": voiceOverStr*/
|
||||
/*if ("playerCount" in s) {
|
||||
setPlayerCount(s["playerCount"]);
|
||||
}
|
||||
if ("players" in s) {
|
||||
setPlayers(s["players"]);
|
||||
}
|
||||
if ("worthy_answers" in s) {
|
||||
setWorthyAnswers(s["worthy_answers"]);
|
||||
}
|
||||
if ("completed_riddles" in s) {
|
||||
setCompletedRiddles(s["completed_riddles"]);
|
||||
}
|
||||
if ("points" in s) {
|
||||
setPoints(s["points"]);
|
||||
}
|
||||
if ("boughtHints" in s) {
|
||||
setBoughtHints(s["boughtHints"]);
|
||||
}
|
||||
if ("voiceOverStr" in s) {
|
||||
setVoiceOver(s["voiceOverStr"]);
|
||||
}
|
||||
setSessionData(s);
|
||||
setStep("2");
|
||||
} else {
|
||||
setStep("1");
|
||||
}*/
|
||||
setStep("1");
|
||||
}
|
||||
};
|
||||
|
||||
const handleChange = (event: ChangeEvent<HTMLInputElement>): boolean => {
|
||||
@@ -144,7 +133,8 @@ export default function WelcomeScreen() {
|
||||
zIndex: 1
|
||||
}} alt="Background"/>
|
||||
<StyledContainer innerClassName={styles["content"]}>
|
||||
<p style={{fontSize: "1.25rem", color: "var(--dark-brown)"}}>SPIELCODE EINGEBEN:</p>
|
||||
<p style={{fontSize: "1.25rem", color: "var(--dark-brown)", textAlign: "center"}}>Es wird nur ein Handy pro Gruppe benötigt.</p>
|
||||
<p style={{fontSize: "1.25rem", color: "var(--dark-brown)", marginTop: "1rem"}}>SPIELCODE EINGEBEN:</p>
|
||||
<br></br>
|
||||
<OldTextInput
|
||||
value={tourCode}
|
||||
|
||||
@@ -68,6 +68,10 @@
|
||||
/*text-shadow: 0px 1px 3px rgba(0, 0, 0, 0.7);*/
|
||||
}
|
||||
|
||||
.charged-button-label-whiteText {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.charged-button-label-clipped {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
|
||||
Loaded 100 of 116 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user