Compare commits
15
Commits
381313f91f
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c70141b26a | ||
|
|
cc9fadd30d | ||
|
|
45acdd3400 | ||
|
|
51e5a98a92 | ||
|
|
dbfa9788a7 | ||
|
|
70fb9e4850 | ||
|
|
62cbffdd3f | ||
|
|
5b9fe3ea21 | ||
|
|
b5e5cc502d | ||
|
|
a526a24e7c | ||
|
|
a6c476e385 | ||
|
|
ff5efa0423 | ||
|
|
6cf631f995 | ||
|
|
e36bec6b36 | ||
|
|
714d3464bd |
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
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
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
|
||||
EXPOSE 80
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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.
+3
-5
@@ -14,6 +14,7 @@ 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";
|
||||
|
||||
export default function Main() {
|
||||
const [ stepStr, setStep ] = useLocalStorage(PREF.step, "0");
|
||||
@@ -21,14 +22,11 @@ export default function Main() {
|
||||
const [ tourCode, setTourCode ] = useLocalStorage(PREF.code, "");
|
||||
const step = Number.parseInt(stepStr) || 0;
|
||||
|
||||
/*console.log("STEP", step);
|
||||
console.log("PLAYERS", players, parsePlayerData(players));
|
||||
console.log("TourCode", tourCode);*/
|
||||
|
||||
const content = [
|
||||
(<WelcomeScreen key={0}/>),
|
||||
(<Intro key={1} />),
|
||||
(<Tour key={2} />)
|
||||
(<Tour key={2} />),
|
||||
(<Outro key={3} />),
|
||||
];
|
||||
|
||||
return (
|
||||
|
||||
@@ -17,6 +17,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,
|
||||
|
||||
@@ -12,16 +12,18 @@ interface ChargedButtonProps {
|
||||
onAction?: () => void;
|
||||
disabled?: boolean;
|
||||
red?: boolean;
|
||||
whiteText?: boolean;
|
||||
}
|
||||
|
||||
export default function ChargedButton({
|
||||
children,
|
||||
style,
|
||||
className,
|
||||
holdDuration = 500,
|
||||
holdDuration = 600,
|
||||
onAction,
|
||||
disabled = false,
|
||||
red = false,
|
||||
whiteText = false,
|
||||
}: ChargedButtonProps) {
|
||||
const [progress, setProgress] = useState(0);
|
||||
const [, setIsCharging] = useState(false);
|
||||
@@ -118,7 +120,18 @@ export default function ChargedButton({
|
||||
}}
|
||||
/>
|
||||
|
||||
<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")}
|
||||
aria-hidden="true"
|
||||
style={{
|
||||
clipPath: `inset(0 ${clipPercent}% 0 0)`,
|
||||
WebkitClipPath: `inset(0 ${clipPercent}% 0 0)`,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</span>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
+35
-19
@@ -17,9 +17,10 @@ export interface MapViewProps {
|
||||
initialCenter?: [number, number]; // [lng, lat]
|
||||
initialZoom?: number;
|
||||
markers?: PlaceMarker[];
|
||||
onMarkerClick?: (marker: PlaceMarker) => void;
|
||||
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,17 +39,20 @@ 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);
|
||||
const activeMarkersRef = useRef<Map<number, maplibregl.Marker>>(new Map());
|
||||
const [ mapReady, setMapReady ] = useState(false);
|
||||
|
||||
const userPositionRef = useRef<[number, number] | null>(null);
|
||||
|
||||
const [isCaching, setIsCaching] = useState(false);
|
||||
const [cacheProgress, setCacheProgress] = useState<{ loaded: number; total: number } | null>(null);
|
||||
|
||||
@@ -82,6 +86,7 @@ export default function MapView({
|
||||
style: mapStyle,
|
||||
center: initialCenter,
|
||||
zoom: initialZoom,
|
||||
maxZoom: 18,
|
||||
});
|
||||
|
||||
map.addControl(new maplibregl.NavigationControl({ visualizePitch: true }), 'bottom-right');
|
||||
@@ -92,28 +97,39 @@ 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;
|
||||
map.addControl(geolocate, 'bottom-right');
|
||||
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) => {
|
||||
userPositionRef.current = [e.coords.longitude, e.coords.latitude];
|
||||
});
|
||||
|
||||
map.addControl(geolocate, 'bottom-right');
|
||||
}
|
||||
|
||||
map.addControl(new maplibregl.ScaleControl({ unit: 'metric' }), 'bottom-left');
|
||||
|
||||
map.on('load', async () => {
|
||||
setMapReady(true);
|
||||
/*navigator.geolocation.getCurrentPosition((pos) => {
|
||||
map.setCenter([pos.coords.longitude, pos.coords.latitude]);
|
||||
geolocate.trigger();
|
||||
navigator.geolocation.getCurrentPosition((pos) => {
|
||||
if (triggerGeolocation && geolocate) {
|
||||
userPositionRef.current = [pos.coords.longitude, pos.coords.latitude];
|
||||
map.setCenter([pos.coords.longitude, pos.coords.latitude]);
|
||||
geolocate.trigger();
|
||||
}
|
||||
}, () => {
|
||||
geolocate.trigger();
|
||||
});*/
|
||||
}); // TODO: ACTIVATE AFTER TESTING
|
||||
if (triggerGeolocation && geolocate) geolocate.trigger();
|
||||
});
|
||||
});
|
||||
|
||||
mapRef.current = map;
|
||||
|
||||
@@ -160,7 +176,7 @@ export default function MapView({
|
||||
.addTo(map);
|
||||
|
||||
newMarker.getElement().addEventListener('click', () => {
|
||||
onMarkerClick?.(markerData);
|
||||
onMarkerClick?.(markerData, userPositionRef.current);
|
||||
});
|
||||
|
||||
currentMarkers.set(markerData.id, newMarker);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
"use client";
|
||||
|
||||
import React, { CSSProperties, MouseEventHandler } from 'react';
|
||||
import React, { CSSProperties, MouseEventHandler, ReactNode } from 'react';
|
||||
import styles from "@/css/OldButton.module.css";
|
||||
import clsx from 'clsx';
|
||||
|
||||
interface OldButtonProps {
|
||||
children?: string;
|
||||
children?: ReactNode;
|
||||
long?: boolean;
|
||||
red?: boolean;
|
||||
disabled?: boolean;
|
||||
|
||||
@@ -27,6 +27,7 @@ export default function PermissionCheck({
|
||||
}, [onRefresh, gpsStatus, cameraStatus]);
|
||||
|
||||
const requestGPSPermission = () => {
|
||||
if (gpsStatus === "granted") return;
|
||||
setIsGPSPermissionLoading(true);
|
||||
navigator.geolocation.getCurrentPosition((pos) => {
|
||||
setIsGPSPermissionLoading(false);
|
||||
@@ -41,6 +42,7 @@ export default function PermissionCheck({
|
||||
}
|
||||
|
||||
const requestCamPermission = () => {
|
||||
if (cameraStatus === "granted") return;
|
||||
setIsCamPermissionLoading(true);
|
||||
navigator.mediaDevices.getUserMedia({
|
||||
"video": { facingMode: { ideal: "environment" } },
|
||||
@@ -68,19 +70,27 @@ export default function PermissionCheck({
|
||||
<br></br>
|
||||
<div className={styles["status-row"]}>
|
||||
<OldButton
|
||||
disabled={isCamPermissionLoading || cameraStatus === "granted"}
|
||||
disabled={isCamPermissionLoading}
|
||||
onAction={requestCamPermission}
|
||||
>
|
||||
Kamera-Berechtigung</OldButton>
|
||||
<img className={styles["status-icon"]} src={cameraStatus === "granted" ? "/icons/haken.svg" : "/icons/kreuz.svg"} alt={`Status Symbol: ${cameraStatus === "granted" ? "Haken" : "Kreuz"}`}/>
|
||||
<div className="center-flex" style={{flexDirection: "row"}}>
|
||||
<img className={styles["status-icon"]} src={cameraStatus === "granted" ? "/icons/haken.svg" : "/icons/kreuz.svg"} alt={`Status Symbol: ${cameraStatus === "granted" ? "Haken" : "Kreuz"}`}/>
|
||||
<p style={{fontSize: "1rem"}}>Kamera-Berechtigung</p>
|
||||
</div>
|
||||
</OldButton>
|
||||
|
||||
</div>
|
||||
<br></br>
|
||||
<div className={styles["status-row"]}>
|
||||
<OldButton
|
||||
disabled={isGPSPermissionLoading || gpsStatus === "granted"}
|
||||
disabled={isGPSPermissionLoading}
|
||||
onAction={requestGPSPermission}
|
||||
>GPS-Berechtigung</OldButton>
|
||||
<img className={styles["status-icon"]} src={gpsStatus === "granted" ? "/icons/haken.svg" : "/icons/kreuz.svg"} alt={`Status Symbol: ${gpsStatus === "granted" ? "Haken" : "Kreuz"}`}/>
|
||||
>
|
||||
<div className="center-flex" style={{flexDirection: "row"}}>
|
||||
<img className={styles["status-icon"]} src={gpsStatus === "granted" ? "/icons/haken.svg" : "/icons/kreuz.svg"} alt={`Status Symbol: ${gpsStatus === "granted" ? "Haken" : "Kreuz"}`}/>
|
||||
<p style={{fontSize: "1rem"}}>GPS-Berechtigung</p>
|
||||
</div>
|
||||
</OldButton>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -10,22 +10,27 @@ import OldButton from "./OldButton";
|
||||
import { addBoughtHint, getBoughtHints } from "@/utils/boughtHints";
|
||||
import OldPopUp from "./OldPopUp";
|
||||
import { getPoints, takePoints } from "@/utils/points";
|
||||
import VoiceOver from "./VoiceOver";
|
||||
import { VoiceOverMode } from "@/types/voiceOverMode";
|
||||
|
||||
interface RiddleHintProps {
|
||||
riddle: Riddle;
|
||||
onSkip?: (() => void) | null;
|
||||
dismissHintPage: () => void;
|
||||
voiceOverMode: VoiceOverMode;
|
||||
};
|
||||
|
||||
export default function RiddleHintPage({
|
||||
riddle,
|
||||
onSkip,
|
||||
dismissHintPage
|
||||
dismissHintPage,
|
||||
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);
|
||||
|
||||
const boughtHints = useMemo(() => {
|
||||
return getBoughtHints();
|
||||
@@ -47,22 +52,30 @@ export default function RiddleHintPage({
|
||||
return sortedHints.find(h => !boughtHints.includes(h.id));
|
||||
}, [sortedHints, boughtHints]);
|
||||
|
||||
console.log(boughtHints);
|
||||
|
||||
return (
|
||||
<div className={clsx(styles["container"])}>
|
||||
{ currentVoiceOver > -1 ?
|
||||
<VoiceOver voiceOverMode={voiceOverMode}
|
||||
sources={[
|
||||
{
|
||||
src: "/res/tour/riddle_" + (riddle.step + 1) + "/voiceovers/Hinweis " + currentVoiceOver + ".mp3",
|
||||
type: "audio/mpeg"
|
||||
}
|
||||
]}
|
||||
/>
|
||||
: null}
|
||||
<div className={styles["header"]}>
|
||||
<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> }
|
||||
{ riddle.skipPenaltyPoints < 0 && <p>Das Rätsel kann nicht übersprungen werden!</p> }
|
||||
<div className="center-flex">
|
||||
{ nextHintToBuy && <OldButton red={false} onAction={() => setShowBuyHint(true)} style={{marginBottom: "1rem"}}>HINWEIS KAUFEN</OldButton> }
|
||||
<OldButton red={false} onAction={() => setShowBuyHint(true)} disabled={nextHintToBuy === undefined} style={{marginBottom: "1rem"}}>HINWEIS KAUFEN</OldButton>
|
||||
</div>
|
||||
{boughtHintObjects.map((hint, index) => (
|
||||
<div key={hint.id}>
|
||||
@@ -70,7 +83,7 @@ export default function RiddleHintPage({
|
||||
</div>
|
||||
))}
|
||||
<div className="center-flex">
|
||||
{ riddle.skipPenaltyPoints > -1 && <OldButton red={true} onAction={() => setShowSkipRiddle(true)} style={{marginTop: "1rem"}}>RÄTSEL ÜBERSPRINGEN</OldButton> }
|
||||
<OldButton red={true} onAction={() => setShowSkipRiddle(true)} disabled={riddle.skipPenaltyPoints < 0} style={{marginTop: "1rem"}}>RÄTSEL ÜBERSPRINGEN</OldButton>
|
||||
</div>
|
||||
{ (showBuyHint || showSkipRiddle) && <div className={clsx(styles["popup"])}>
|
||||
{ showBuyHint && nextHintToBuy &&
|
||||
@@ -79,6 +92,7 @@ export default function RiddleHintPage({
|
||||
<p>Möchtet ihr diesen Hinweis für {nextHintToBuy.penaltyPoints} Rufpunkte kaufen?</p>
|
||||
<OldButton red={true} /*disabled={points >= nextHintToBuy.penaltyPoints}*/ onAction={() => {
|
||||
addBoughtHint(nextHintToBuy.id);
|
||||
setCurrentVoiceOver(nextHintToBuy.hintOrder + 1)
|
||||
takePoints(nextHintToBuy.penaltyPoints);
|
||||
setShowBuyHint(false);
|
||||
}}>JA, KAUFEN!</OldButton>
|
||||
|
||||
@@ -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,12 +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);
|
||||
console.log(riddle);
|
||||
const closeInterceptorRef = useRef<(() => Promise<boolean>) | null>(null);
|
||||
|
||||
const exitFunction = () => {
|
||||
const exitFunction = async () => {
|
||||
if (closeInterceptorRef.current) {
|
||||
if (!await closeInterceptorRef.current()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
onDismiss();
|
||||
};
|
||||
|
||||
@@ -63,6 +69,9 @@ export default function RiddleScreen({ riddle, onDismiss }: RiddleScreenProps) {
|
||||
"requestingHint": showHintPage,
|
||||
"dismissHint": () => {
|
||||
setShowHintPage(false);
|
||||
},
|
||||
"onRegisterCloseInterceptor": (fn) => {
|
||||
closeInterceptorRef.current = fn;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -93,8 +102,8 @@ export default function RiddleScreen({ riddle, onDismiss }: RiddleScreenProps) {
|
||||
}} alt="Background" loading="eager"/>
|
||||
<StyledContainer riddleDesign={true}>
|
||||
<div className={styles["actions-bookmark"]}>
|
||||
<img src={"/icons/hinweis.svg"} className={styles["bookmark-icon"]} style={{width: "20px", height: "auto", margin: "12px 24px", marginTop: "12px"}} onClick={() => setShowHintPage(true)} />
|
||||
<img src={voiceOverState === "off" ? "/icons/Vorlese-Icon.svg" : "/icons/Vorlese-Icon-leise.svg"} className={styles["bookmark-icon"]} style={{width: "28px", height: "24px", margin: "0px 20px 24px"}} onClick={() => {
|
||||
<img src={"/icons/hinweis.svg"} className={styles["bookmark-icon"]} style={{width: "24px", height: "auto", margin: "12px 24px", marginTop: "12px"}} onClick={() => setShowHintPage(true)} />
|
||||
<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>
|
||||
|
||||
@@ -5,9 +5,9 @@ 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: 2, 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: 0, 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' },
|
||||
];
|
||||
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -52,3 +52,33 @@
|
||||
.genderButton-disabled {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
@keyframes flashRed {
|
||||
0% { background-color: transparent; outline: 2px solid transparent; }
|
||||
0.1% { background-color: rgba(255, 0, 0, 0.4); outline: 2px solid red; }
|
||||
100% { background-color: transparent; outline: 2px solid transparent; }
|
||||
}
|
||||
|
||||
.blinkError {
|
||||
animation-name: flashRed;
|
||||
animation-timing-function: ease;
|
||||
animation-duration: 0.5s;
|
||||
animation-iteration-count: 1;
|
||||
animation-delay: 0s;
|
||||
animation-fill-mode: forwards;
|
||||
animation-direction: normal;
|
||||
animation-play-state: paused;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.blinkErrorInput {
|
||||
animation-name: flashRed;
|
||||
animation-timing-function: ease;
|
||||
animation-duration: 0.5s;
|
||||
animation-iteration-count: 1;
|
||||
animation-delay: 0s;
|
||||
animation-fill-mode: forwards;
|
||||
animation-direction: normal;
|
||||
animation-play-state: paused;
|
||||
border-radius: 6px;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import OldButton from "../OldButton";
|
||||
import styles from "@/css/RiddleStyles.module.css";
|
||||
import { useLocalStorage } from "@/hooks/useLocalStorage";
|
||||
@@ -16,6 +16,9 @@ import { setPlayers } from "@/utils/players";
|
||||
import { setPlayerAnswers } from "@/utils/player_answers";
|
||||
import VoiceOver from "../VoiceOver";
|
||||
import RiddleHintPage from "../RiddleHintPage";
|
||||
import ChargedButton from "../ChargedButton";
|
||||
import { checkCode } from "@/utils/codeChecker";
|
||||
import { addCompletedRiddle } from "@/utils/completedRiddles";
|
||||
|
||||
export default function Riddle_1({
|
||||
page,
|
||||
@@ -27,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);
|
||||
@@ -50,7 +53,8 @@ export default function Riddle_1({
|
||||
"Achtes Abenteuermitglied"
|
||||
];
|
||||
|
||||
const canGoNext = didPlayerEnterAnswer && didPlayerEnterName && didPlayerPickGender && nameScreen < playerCount-1;
|
||||
const hasNextPlayer = nameScreen < playerCount-1;
|
||||
const canGoNext = didPlayerEnterAnswer && didPlayerEnterName && didPlayerPickGender && hasNextPlayer;
|
||||
const complete = (() => {
|
||||
let allSet = true;
|
||||
for (let i = 0; i < playerCount; ++i) {
|
||||
@@ -66,6 +70,25 @@ export default function Riddle_1({
|
||||
return allSet;
|
||||
})();
|
||||
|
||||
const blinkMissing = () => {
|
||||
const genderContainer = document.querySelector(`.${extraStyles["genderButtons"]}`);
|
||||
const maleButton = genderContainer?.querySelector("button:first-child");
|
||||
const femaleButton = genderContainer?.querySelector("button:last-child");
|
||||
const inputs = document.querySelectorAll(`.${extraStyles["blinkErrorInput"]}`);
|
||||
|
||||
const triggerBlink = (el: Element | null) => {
|
||||
el?.getAnimations()[0].play();
|
||||
};
|
||||
|
||||
if (!didPlayerPickGender && maleButton && femaleButton) {
|
||||
triggerBlink(maleButton);
|
||||
triggerBlink(femaleButton);
|
||||
}
|
||||
inputs.forEach((input, idx) => {
|
||||
if ((input as HTMLInputElement).value.trim().length < 1) triggerBlink(input);
|
||||
});
|
||||
};
|
||||
|
||||
const pages = [
|
||||
(
|
||||
<div key={0}>
|
||||
@@ -98,11 +121,11 @@ export default function Riddle_1({
|
||||
}
|
||||
]}/>
|
||||
<div className={styles["content"]}>
|
||||
<p style={{fontWeight: "bold", textAlign: "center", fontSize: "1rem"}}>Was schuldet ein Herr seinem Gesinde am allermeisten?</p>
|
||||
<p style={{fontWeight: "bold", textAlign: "center", fontSize: "1.1rem"}}>{counterStrings[nameScreen]}</p>
|
||||
<div className={extraStyles["genderButtons"]}>
|
||||
<p style={{fontWeight: "bold", textAlign: "center"}}>Was schuldet ein Herr seinem Gesinde am allermeisten?</p>
|
||||
<p style={{fontWeight: "bold", textAlign: "center"}}>{counterStrings[nameScreen]}</p>
|
||||
<div className={clsx(extraStyles["genderButtons"])}>
|
||||
<button
|
||||
className={clsx(extraStyles["genderButton"], didPlayerPickGender && enteredPlayers[nameScreen].gender === "female" ? extraStyles["genderButton-disabled"] : null)}
|
||||
className={clsx(extraStyles["genderButton"], !didPlayerPickGender || enteredPlayers[nameScreen].gender === "female" ? extraStyles["genderButton-disabled"] : null, extraStyles["blinkError"])}
|
||||
onClick={() => {
|
||||
const a = [...enteredPlayers];
|
||||
a[nameScreen] = {
|
||||
@@ -116,7 +139,7 @@ export default function Riddle_1({
|
||||
<img src={"/buttons/Button_m.webp"} width={70} />
|
||||
</button>
|
||||
<button
|
||||
className={clsx(extraStyles["genderButton"], didPlayerPickGender && enteredPlayers[nameScreen].gender === "male" ? extraStyles["genderButton-disabled"] : null)}
|
||||
className={clsx(extraStyles["genderButton"], !didPlayerPickGender || enteredPlayers[nameScreen].gender === "male" ? extraStyles["genderButton-disabled"] : null, extraStyles["blinkError"])}
|
||||
onClick={() => {
|
||||
const a = [...enteredPlayers];
|
||||
a[nameScreen] = {
|
||||
@@ -145,6 +168,7 @@ export default function Riddle_1({
|
||||
setEnteredPlayers(a);
|
||||
}}
|
||||
style={{marginBottom: "1.5rem"}}
|
||||
className={extraStyles["blinkErrorInput"]}
|
||||
></OldTextInput>
|
||||
<p className={extraStyles["label"]}>DEINE ANTWORT:</p>
|
||||
<OldTextInput
|
||||
@@ -156,6 +180,7 @@ export default function Riddle_1({
|
||||
setEnteredAnswers(a);
|
||||
}}
|
||||
style={{marginBottom: "1.5rem"}}
|
||||
className={extraStyles["blinkErrorInput"]}
|
||||
></OldTextInput>
|
||||
</div>
|
||||
<div className={extraStyles["arrows"]}>
|
||||
@@ -170,29 +195,41 @@ export default function Riddle_1({
|
||||
</button>
|
||||
<button
|
||||
className={clsx(extraStyles["arrow"])}
|
||||
disabled={!canGoNext}
|
||||
disabled={!hasNextPlayer}
|
||||
onClick={() => {
|
||||
setNameScreen(nameScreen+1);
|
||||
if (canGoNext) {
|
||||
setNameScreen(nameScreen+1);
|
||||
} else {
|
||||
blinkMissing();
|
||||
}
|
||||
|
||||
}}
|
||||
>
|
||||
<img src={"/icons/pfeil_blau.svg"} width={70} style={{rotate: "180deg"}} />
|
||||
</button>
|
||||
</div>
|
||||
<div className="center-flex">
|
||||
<OldButton red={false} onAction={() => {
|
||||
<ChargedButton red={false} onAction={() => {
|
||||
if (!complete) {
|
||||
blinkMissing();
|
||||
return;
|
||||
}
|
||||
addPoints(riddle.points);
|
||||
showBanner(false);
|
||||
setPlayers(enteredPlayers);
|
||||
setPlayerAnswers(enteredAnswers);
|
||||
addCompletedRiddle(riddle.step);
|
||||
setPage(2);
|
||||
}} disabled={!complete}>EINREICHEN!</OldButton>
|
||||
}} disabled={hasNextPlayer}>EINREICHEN!</ChargedButton>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
<OldButton red={true} onAction={() => {
|
||||
setPage(0);
|
||||
showBanner(true);
|
||||
}}>ZURÜCK</OldButton>
|
||||
}}
|
||||
className={styles["backButton"]}
|
||||
>ZURÜCK</OldButton>
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
@@ -218,5 +255,5 @@ export default function Riddle_1({
|
||||
)
|
||||
];
|
||||
|
||||
return requestingHint ? <RiddleHintPage riddle={riddle} dismissHintPage={dismissHint} onSkip={() => setPage(2)}/> : pages[page];
|
||||
return requestingHint ? <RiddleHintPage riddle={riddle} dismissHintPage={dismissHint} voiceOverMode={voiceOverMode} onSkip={null}/> : pages[page];
|
||||
}
|
||||
@@ -1,16 +1,58 @@
|
||||
"use client";
|
||||
|
||||
import { useMemo, useState } from "react";
|
||||
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";
|
||||
import { getPlayers } from "@/utils/players";
|
||||
import VoiceOver from "../VoiceOver";
|
||||
import RiddleHintPage from "../RiddleHintPage";
|
||||
import { Player } from "@/types/player";
|
||||
import { addCompletedRiddle } from "@/utils/completedRiddles";
|
||||
import ChargedButton from "../ChargedButton";
|
||||
import { isDemoMode } from "@/utils/demoMode";
|
||||
|
||||
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,
|
||||
@@ -21,11 +63,131 @@ 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 [ demoModeStr, ] = useLocalStorage(PREF.demo_mode, "");
|
||||
const demoMode = useMemo(() => isDemoMode(demoModeStr), [demoModeStr]);
|
||||
|
||||
const [ playerIndex, setPlayerIndex ] = useState(0);
|
||||
const players = useMemo(() => getPlayers(), [playersStr]);
|
||||
const playerOrder = useMemo(() => {
|
||||
if (!players || players.length === 0) return [];
|
||||
|
||||
const indices = Array.from({ length: players.length - 1 }, (_, i) => i + 1);
|
||||
|
||||
for (let i = indices.length - 1; i > 0; i--) {
|
||||
const j = Math.floor(Math.random() * (i + 1));
|
||||
[indices[i], indices[j]] = [indices[j], indices[i]];
|
||||
}
|
||||
|
||||
indices.push(0);
|
||||
|
||||
return indices;
|
||||
}, [players]);
|
||||
|
||||
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 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 {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (demoMode) return;
|
||||
|
||||
let isCancelled = false;
|
||||
let reconnectTimeout: NodeJS.Timeout;
|
||||
|
||||
const connect = () => {
|
||||
if (isCancelled) return;
|
||||
setStatus("connecting");
|
||||
|
||||
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);
|
||||
} 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.topic.includes('/set')) {
|
||||
if (data.payload === "abortTry") {
|
||||
awaitTryAbort = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ws.onclose = () => {
|
||||
if (!isCancelled) {
|
||||
setStatus("disconnected");
|
||||
reconnectTimeout = setTimeout(connect, 3000);
|
||||
}
|
||||
};
|
||||
|
||||
ws.onerror = () => {
|
||||
ws.close();
|
||||
};
|
||||
};
|
||||
|
||||
connect();
|
||||
|
||||
return () => {
|
||||
isCancelled = true;
|
||||
clearTimeout(reconnectTimeout);
|
||||
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
|
||||
});
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
onRegisterCloseInterceptor(handleIntercept);
|
||||
}, [onRegisterCloseInterceptor]);
|
||||
|
||||
const pages = [
|
||||
(
|
||||
@@ -42,28 +204,103 @@ export default function Riddle_2({
|
||||
<p>Jetzt seid ihr an der Reihe. Die Prophezeiung selbst bestimmt, wer vortreten darf, einer nach dem anderen, bis der Stahl seinen neuen Träger erkennt.</p>
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
<OldButton red={false} onAction={() => setPage(1)}>WEITER</OldButton>
|
||||
<OldButton red={false} onAction={() => {
|
||||
if (!sendCommand(`${TOPIC_PREFIX}/set`, 'stayLocked')) {
|
||||
return;
|
||||
}
|
||||
setCanGoNext(false);
|
||||
setPage(1);
|
||||
}}>PRÜFUNG STARTEN</OldButton>
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
(
|
||||
<div key={1}>
|
||||
<div className={styles["content"]}>
|
||||
<div className="center-flex">
|
||||
<p style={{fontWeight: "bold", fontSize: "3rem", marginTop: "2rem", marginBottom: "0"}}>Zieh mal {players[playerIndex].name},</p>
|
||||
<p style={{textAlign: "center"}}>zieh nun am Schwert und finde heraus, ob du Excaliburs {players[playerIndex].gender === "female" ? "Erbin" : "Erbe"} bist!</p>
|
||||
{ currentPlayer !== undefined ? <div className="center-flex">
|
||||
<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(`${TOPIC_PREFIX}/set`, 'releaseLock')}
|
||||
>
|
||||
Release Lock
|
||||
</button>
|
||||
<br/><br/>
|
||||
<button
|
||||
style={{ fontSize: '0.6rem', padding: '4px 8px' }}
|
||||
onClick={() => sendCommand(`${TOPIC_PREFIX}/set`, 'stayLocked')}
|
||||
>
|
||||
Stay Locked
|
||||
</button>
|
||||
<br/><br/>
|
||||
<button
|
||||
style={{ fontSize: '0.6rem', padding: '4px 8px' }}
|
||||
onClick={() => sendCommand(`${TOPIC_PREFIX}/set`, 'gameStarted')}
|
||||
>
|
||||
Game Started
|
||||
</button>
|
||||
<br/><br/>
|
||||
<button
|
||||
style={{ fontSize: '0.6rem', padding: '4px 8px' }}
|
||||
onClick={() => sendCommand(`${TOPIC_PREFIX}/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(`${TOPIC_PREFIX}/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) {
|
||||
setPage(2);
|
||||
addPoints(riddle.points);
|
||||
addCompletedRiddle(riddle.step);
|
||||
} else {
|
||||
if (isNextIndexLastPlayer) {
|
||||
if (!sendCommand(`${TOPIC_PREFIX}/set`, 'releaseLock')) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (!sendCommand(`${TOPIC_PREFIX}/set`, 'stayLocked')) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
setCanGoNext(false);
|
||||
setPlayerIndex(playerIndex+1);
|
||||
}
|
||||
}} disabled={false}>WEITER</OldButton>
|
||||
{playerIndex < 1 ? <OldButton red={true} onAction={() => setPage(0)}>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;
|
||||
});
|
||||
setPage(0);
|
||||
}} className={styles["backButton"]}>ZURÜCK</OldButton> : null}
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
@@ -82,11 +319,14 @@ export default function Riddle_2({
|
||||
<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={false /* CHECK IF SWORD IS IN */} onAction={() => exitFunction()}>ZURÜCK ZUR KARTE</OldButton>
|
||||
<OldButton red={false} disabled={!isSwordBackIn && !demoMode} onAction={() => exitFunction()}>ZURÜCK ZUR KARTE</OldButton>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
];
|
||||
|
||||
return requestingHint ? <RiddleHintPage riddle={riddle} dismissHintPage={dismissHint} onSkip={() => setPage(2)}/> : pages[page];
|
||||
return requestingHint ? <RiddleHintPage riddle={riddle} dismissHintPage={dismissHint} voiceOverMode={voiceOverMode} onSkip={() => {
|
||||
addCompletedRiddle(riddle.step);
|
||||
setPage(2);
|
||||
}}/> : pages[page];
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import ChargedButton from "../ChargedButton";
|
||||
import extraStyles from "@/components/riddles-css/Riddle_3.module.css";
|
||||
import VoiceOver from "../VoiceOver";
|
||||
import RiddleHintPage from "../RiddleHintPage";
|
||||
import { addCompletedRiddle } from "@/utils/completedRiddles";
|
||||
|
||||
export default function Riddle_3({
|
||||
page,
|
||||
@@ -63,7 +64,7 @@ export default function Riddle_3({
|
||||
<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>
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
<ChargedButton red={false} disabled={false} onAction={() => setPage(1)} holdDuration={300}>WIR SIND BEREIT</ChargedButton>
|
||||
<ChargedButton red={false} disabled={false} onAction={() => setPage(1)}>WIR SIND BEREIT</ChargedButton>
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
@@ -86,12 +87,12 @@ export default function Riddle_3({
|
||||
<div className={extraStyles["range"]}>
|
||||
<input type="range" min={1} max={10} value={scaleValue} onChange={(e) => setScaleValue(Number.parseInt(e.target.value))}></input>
|
||||
<div className="">
|
||||
<p>Zweifel</p>
|
||||
<p>Würde</p>
|
||||
<p>Zweifelhaft</p>
|
||||
<p>Würdig</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="center-flex">
|
||||
<OldButton red={false} onAction={() => {
|
||||
<ChargedButton red={false} onAction={() => {
|
||||
if (scaleValue < 4) {
|
||||
takePoints(riddle.failPenaltyPoints);
|
||||
} else if (scaleValue < 8) {
|
||||
@@ -99,12 +100,13 @@ export default function Riddle_3({
|
||||
} else {
|
||||
addPoints(riddle.points);
|
||||
}
|
||||
addCompletedRiddle(riddle.step);
|
||||
setPage(2);
|
||||
}} disabled={buttonDebounce}>EINREICHEN!</OldButton>
|
||||
}} disabled={buttonDebounce}>EINREICHEN!</ChargedButton>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
<OldButton red={true} disabled={buttonDebounce} onAction={() => setPage(0)}>ZURÜCK</OldButton>
|
||||
<OldButton red={true} disabled={buttonDebounce} onAction={() => setPage(0)} className={styles["backButton"]}>ZURÜCK</OldButton>
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
@@ -157,16 +159,12 @@ export default function Riddle_3({
|
||||
<OldButton red={false} disabled={false} onAction={() => exitFunction()}>ZURÜCK ZUR KARTE</OldButton>
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
(
|
||||
<div key={3}>
|
||||
<p>Übersprungen?</p>
|
||||
<div className={styles["buttons"]}>
|
||||
<OldButton red={false} disabled={false} onAction={() => exitFunction()}>ZURÜCK ZUR KARTE</OldButton>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
];
|
||||
|
||||
return requestingHint ? <RiddleHintPage riddle={riddle} dismissHintPage={dismissHint} onSkip={() => setPage(3)}/> : pages[page];
|
||||
return requestingHint ? <RiddleHintPage riddle={riddle} dismissHintPage={dismissHint} voiceOverMode={voiceOverMode} onSkip={() => {
|
||||
setScaleValue(1);
|
||||
addCompletedRiddle(riddle.step);
|
||||
setPage(2);
|
||||
}}/> : pages[page];
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import extraStyles from "@/components/riddles-css/Riddle_4.module.css";
|
||||
import SelectionButton from "../SelectionButton";
|
||||
import VoiceOver from "../VoiceOver";
|
||||
import RiddleHintPage from "../RiddleHintPage";
|
||||
import { addCompletedRiddle } from "@/utils/completedRiddles";
|
||||
|
||||
export default function Riddle_4({
|
||||
page,
|
||||
@@ -77,12 +78,13 @@ export default function Riddle_4({
|
||||
} else {
|
||||
takePoints(riddle.failPenaltyPoints);
|
||||
}
|
||||
addCompletedRiddle(riddle.step);
|
||||
setPage(2);
|
||||
}} disabled={selection === -1} holdDuration={300}>EINREICHEN!</ChargedButton>
|
||||
}} disabled={selection === -1}>EINREICHEN!</ChargedButton>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
<OldButton red={true} onAction={() => setPage(0)}>ZURÜCK</OldButton>
|
||||
<OldButton red={true} onAction={() => setPage(0)} className={styles["backButton"]}>ZURÜCK</OldButton>
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
@@ -124,5 +126,9 @@ export default function Riddle_4({
|
||||
)
|
||||
];
|
||||
|
||||
return requestingHint ? <RiddleHintPage riddle={riddle} dismissHintPage={dismissHint} onSkip={() => setPage(2)}/> : pages[page];
|
||||
return requestingHint ? <RiddleHintPage riddle={riddle} dismissHintPage={dismissHint} voiceOverMode={voiceOverMode} onSkip={() => {
|
||||
setSelection(-1);
|
||||
addCompletedRiddle(riddle.step);
|
||||
setPage(2);
|
||||
}}/> : pages[page];
|
||||
}
|
||||
@@ -12,6 +12,8 @@ import { getPlayers } from "@/utils/players";
|
||||
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,
|
||||
@@ -63,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;
|
||||
@@ -76,7 +78,8 @@ export default function Riddle_5({
|
||||
takePoints(riddle.failPenaltyPoints);
|
||||
setPage(2);
|
||||
}
|
||||
}} disabled={false}>EINREICHEN</OldButton>
|
||||
addCompletedRiddle(riddle.step);
|
||||
}} disabled={false}>EINREICHEN</ChargedButton>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
@@ -124,5 +127,8 @@ export default function Riddle_5({
|
||||
)
|
||||
];
|
||||
|
||||
return requestingHint ? <RiddleHintPage riddle={riddle} dismissHintPage={dismissHint} onSkip={() => setPage(2)}/> : pages[page];
|
||||
return requestingHint ? <RiddleHintPage riddle={riddle} dismissHintPage={dismissHint} voiceOverMode={voiceOverMode} onSkip={() => {
|
||||
addCompletedRiddle(riddle.step);
|
||||
setPage(2);
|
||||
}}/> : pages[page];
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import VoiceOver from "../VoiceOver";
|
||||
import { createStationName } from "@/utils/stringer";
|
||||
import { addPoints } from "@/utils/points";
|
||||
import RiddleHintPage from "../RiddleHintPage";
|
||||
import { addCompletedRiddle } from "@/utils/completedRiddles";
|
||||
|
||||
const ERROR_MESSAGES = [
|
||||
{ text: "Noch seid ihr zu unruhig. Ein angehender König sollte schließlich nicht zittern wie ein Blatt im Herbstwind. Findet eure Ruhe und versucht es erneut.", audio: "/res/tour/riddle_6/voiceovers/Fehlermeldung_1.mp3" },
|
||||
@@ -116,6 +117,7 @@ export default function Riddle_6({
|
||||
|
||||
const winRiddle = () => {
|
||||
setMode('won');
|
||||
addCompletedRiddle(riddle.step);
|
||||
setPage(3);
|
||||
showBanner(true);
|
||||
};
|
||||
@@ -163,7 +165,7 @@ export default function Riddle_6({
|
||||
return;
|
||||
}
|
||||
|
||||
if (!popupActive && (now - lastMovementTime >= 10000)) {
|
||||
if (!popupActive && (now - lastMovementTime >= 30000)) {
|
||||
winRiddle();
|
||||
return;
|
||||
}
|
||||
@@ -235,11 +237,11 @@ export default function Riddle_6({
|
||||
<p>Legt das Spielhandy vorsichtig darauf.</p>
|
||||
<p>Nun versucht ihr gemeinsam, das Handy so ruhig wie möglich zu halten.</p>
|
||||
<div className="center-flex">
|
||||
<OldButton red={false} onAction={handleStartTracking} disabled={false}>STARTEN</OldButton>
|
||||
<ChargedButton red={false} onAction={handleStartTracking} disabled={false}>PRÜFUNG STARTEN</ChargedButton>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
<OldButton red={true} onAction={() => setPage(0)}>ZURÜCK</OldButton>
|
||||
<OldButton red={true} onAction={() => setPage(0)} className={styles["backButton"]}>ZURÜCK</OldButton>
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
@@ -279,17 +281,7 @@ export default function Riddle_6({
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
<ChargedButton
|
||||
holdDuration={300}
|
||||
red={true}
|
||||
onAction={() => {
|
||||
addPoints(riddle.points);
|
||||
setPage(3);
|
||||
showBanner(true);
|
||||
}}
|
||||
>
|
||||
Überspringen (Dev)
|
||||
</ChargedButton>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
@@ -323,5 +315,8 @@ export default function Riddle_6({
|
||||
)
|
||||
];
|
||||
|
||||
return requestingHint ? <RiddleHintPage riddle={riddle} dismissHintPage={dismissHint} onSkip={() => setPage(4)}/> : pages[page];
|
||||
return requestingHint ? <RiddleHintPage riddle={riddle} dismissHintPage={dismissHint} voiceOverMode={voiceOverMode} onSkip={() => {
|
||||
setPage(4);
|
||||
addCompletedRiddle(riddle.step);
|
||||
}}/> : pages[page];
|
||||
}
|
||||
@@ -11,6 +11,8 @@ import RiddleCompleteBanner from "../RiddleCompleteBanner";
|
||||
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'),
|
||||
@@ -72,7 +74,7 @@ export default function Riddle_7({
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
<OldButton red={true} onAction={() => setPage(0)}>ZURÜCK</OldButton>
|
||||
<OldButton red={true} onAction={() => setPage(0)} className={styles["backButton"]}>ZURÜCK</OldButton>
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
@@ -103,7 +105,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);
|
||||
@@ -111,14 +113,17 @@ export default function Riddle_7({
|
||||
takePoints(riddle.failPenaltyPoints);
|
||||
setPage(5);
|
||||
}
|
||||
}}>ÜBERPRÜFEN!</OldButton>
|
||||
addCompletedRiddle(riddle.step);
|
||||
}}>ÜBERPRÜFEN!</ChargedButton>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
<OldButton red={true} disabled={false} onAction={() => {
|
||||
setPage(1);
|
||||
showBanner(true);
|
||||
}}>ZURÜCK</OldButton>
|
||||
}}
|
||||
className={styles["backButton"]}
|
||||
>ZURÜCK</OldButton>
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
@@ -164,5 +169,8 @@ export default function Riddle_7({
|
||||
)
|
||||
];
|
||||
|
||||
return requestingHint ? <RiddleHintPage riddle={riddle} dismissHintPage={dismissHint} onSkip={() => setPage(5)}/> : pages[page];
|
||||
return requestingHint ? <RiddleHintPage riddle={riddle} dismissHintPage={dismissHint} voiceOverMode={voiceOverMode} onSkip={() => {
|
||||
addCompletedRiddle(riddle.step);
|
||||
setPage(5);
|
||||
}}/> : pages[page];
|
||||
}
|
||||
@@ -10,6 +10,8 @@ import clsx from "clsx";
|
||||
import { useState } from "react";
|
||||
import VoiceOver from "../VoiceOver";
|
||||
import RiddleHintPage from "../RiddleHintPage";
|
||||
import ChargedButton from "../ChargedButton";
|
||||
import { addCompletedRiddle } from "@/utils/completedRiddles";
|
||||
|
||||
export default function Riddle_8({
|
||||
page,
|
||||
@@ -56,7 +58,7 @@ export default function Riddle_8({
|
||||
<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>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:</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">
|
||||
<div className={extraStyles["image-buttons"]}>
|
||||
<div>
|
||||
@@ -108,7 +110,7 @@ export default function Riddle_8({
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<OldButton red={false} onAction={() => {
|
||||
<ChargedButton red={false} onAction={() => {
|
||||
if (selection === 1) {
|
||||
addPoints(riddle.points);
|
||||
setPage(2);
|
||||
@@ -116,8 +118,8 @@ export default function Riddle_8({
|
||||
takePoints(riddle.failPenaltyPoints);
|
||||
setPage(3);
|
||||
}
|
||||
|
||||
}} disabled={selection === -1}>PRÜFEN LASSEN!</OldButton>
|
||||
addCompletedRiddle(riddle.step);
|
||||
}} disabled={selection === -1}>PRÜFEN LASSEN!</ChargedButton>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
@@ -165,5 +167,8 @@ export default function Riddle_8({
|
||||
)
|
||||
];
|
||||
|
||||
return requestingHint ? <RiddleHintPage riddle={riddle} dismissHintPage={dismissHint} onSkip={() => setPage(3)}/> : pages[page];
|
||||
return requestingHint ? <RiddleHintPage riddle={riddle} dismissHintPage={dismissHint} voiceOverMode={voiceOverMode} onSkip={() => {
|
||||
addCompletedRiddle(riddle.step);
|
||||
setPage(3);
|
||||
}}/> : pages[page];
|
||||
}
|
||||
@@ -9,6 +9,10 @@ import { useState } from "react";
|
||||
import VoiceOver from "../VoiceOver";
|
||||
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,
|
||||
@@ -20,6 +24,7 @@ export default function Riddle_9({
|
||||
requestingHint,
|
||||
dismissHint,
|
||||
}: RiddleScreenControls) {
|
||||
const [ screenPageStr, setScreenPage ] = useLocalStorage(PREF.step, "");
|
||||
const [answer, setAnswer] = useState("");
|
||||
|
||||
const pages = [
|
||||
@@ -38,7 +43,10 @@ export default function Riddle_9({
|
||||
<p>Entschlüsselt es und gebt der neuen Tafelrunde damit, was der alten am Ende fehlte.</p>
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
<OldButton red={false} onAction={() => setPage(1)}>WEITER</OldButton>
|
||||
<OldButton red={false} onAction={() => {
|
||||
showBanner(false);
|
||||
setPage(1);
|
||||
}}>WEITER</OldButton>
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
@@ -52,16 +60,15 @@ export default function Riddle_9({
|
||||
]}/>
|
||||
<div className={styles["content"]}>
|
||||
<p>Auf Tisch, Stuhl, Bechern und Gedecken findet ihr verschiedene <b>Symbole</b>.</p>
|
||||
<p style={{fontWeight: "bold"}}>[SYMBOL 1] – [SYMBOL 2] – [SYMBOL 3] – [SYMBOL 4] – [SYMBOL 5] – [SYMBOL 6] – [SYMBOL 7] – [SYMBOL 8] – [SYMBOL 9] – [SYMBOL 10] – [SYMBOL 11] – [SYMBOL 12]</p>
|
||||
<p>Die Buchstaben ergeben das Wort, das Artus für die neue Tafelrunde hinterlassen hat.</p>
|
||||
<p style={{fontWeight: "bold", textAlign: "center"}}>Unter welchem Motto steht die erneuerte Tafelrunde?</p>
|
||||
<div className="center-flex">
|
||||
<OldTextInput
|
||||
value={answer}
|
||||
onChange={(e) => setAnswer(e.target.value)}
|
||||
style={{textAlign: "center"}}
|
||||
style={{textAlign: "center", marginBottom: "2rem"}}
|
||||
/>
|
||||
<OldButton red={false} onAction={() => {
|
||||
<ChargedButton red={false} onAction={() => {
|
||||
const v = answer.toLowerCase().trim();
|
||||
if (v.length < 12) return;
|
||||
if (v === "bruderschaft" || v === "bruder schaft") {
|
||||
@@ -71,11 +78,15 @@ export default function Riddle_9({
|
||||
takePoints(riddle.failPenaltyPoints);
|
||||
setPage(3);
|
||||
}
|
||||
}} disabled={answer.toLowerCase().trim().length < 12}>WEITER</OldButton>
|
||||
addCompletedRiddle(riddle.step);
|
||||
}} disabled={answer.toLowerCase().trim().length < 12}>EINREICHEN!</ChargedButton>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
<OldButton red={true} onAction={() => setPage(0)}>ZURÜCK</OldButton>
|
||||
<OldButton red={true} onAction={() => {
|
||||
showBanner(true);
|
||||
setPage(0);
|
||||
}} className={styles["backButton"]}>ZURÜCK</OldButton>
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
@@ -95,7 +106,9 @@ export default function Riddle_9({
|
||||
<p>Ein weiterer Schritt zur Krone ist getan.</p>
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
<OldButton red={false} disabled={false} onAction={() => exitFunction()}>ZURÜCK ZUR KARTE</OldButton>
|
||||
<ChargedButton red={false} disabled={false} onAction={() => {
|
||||
setScreenPage("3");
|
||||
}}>ERGEBNIS ANZEIGEN</ChargedButton>
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
@@ -114,11 +127,16 @@ 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"]}>
|
||||
<OldButton red={false} disabled={false} onAction={() => exitFunction()}>ZURÜCK ZUR KARTE</OldButton>
|
||||
<ChargedButton red={false} disabled={false} onAction={() => {
|
||||
setScreenPage("3");
|
||||
}}>ERGEBNIS ANZEIGEN</ChargedButton>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
];
|
||||
|
||||
return requestingHint ? <RiddleHintPage riddle={riddle} dismissHintPage={dismissHint} onSkip={(() => setPage(3))}/> : pages[page];
|
||||
return requestingHint ? <RiddleHintPage riddle={riddle} dismissHintPage={dismissHint} voiceOverMode={voiceOverMode} onSkip={(() => {
|
||||
addCompletedRiddle(riddle.step);
|
||||
setPage(3);
|
||||
})}/> : pages[page];
|
||||
}
|
||||
@@ -3,31 +3,46 @@ 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 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("");
|
||||
setVoiceOverState("on");
|
||||
setStep("2");
|
||||
};
|
||||
|
||||
const [ , setPlayerCount ] = useLocalStorage(PREF.player_count, "");
|
||||
const [ playerCountStr, setPlayerCountStr] = useState("");
|
||||
|
||||
const validPlayerCount = (number: number) => {
|
||||
@@ -72,7 +87,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 +126,7 @@ export default function Intro() {
|
||||
}} holdDuration={500} disabled={!isPlayerCountValid}>
|
||||
ABENTEUER BEGINNEN!
|
||||
</ChargedButton>
|
||||
<p className={clsx("lancelot-italic")} style={{marginTop: "1rem"}}>Auf dem Knopf halten, um ihn aufzuladen!</p>
|
||||
</div>
|
||||
:
|
||||
<div className={styles["intro-video-container"]}>
|
||||
@@ -133,8 +149,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 +167,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,169 @@
|
||||
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, 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";
|
||||
|
||||
export default function Outro() {
|
||||
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;
|
||||
};
|
||||
|
||||
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="/res/outro/testoutro.webm" type="video/webm"/>
|
||||
</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 < 3500 ?
|
||||
<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>
|
||||
)
|
||||
}
|
||||
+144
-170
@@ -1,11 +1,11 @@
|
||||
"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";
|
||||
import { act, MouseEventHandler, useEffect, useState } from "react";
|
||||
import { act, MouseEventHandler, useEffect, useMemo, useState } from "react";
|
||||
import { usePermissions } from "@/hooks/usePermission";
|
||||
import PermissionCheck from "../PermissionCheck";
|
||||
import clsx from "clsx";
|
||||
@@ -14,177 +14,82 @@ import RiddleScreen from "../RiddleScreen";
|
||||
import OldPopUp from "../OldPopUp";
|
||||
import { MAX_POINTS, MIN_POINTS } from "@/utils/points";
|
||||
import { Riddle } from "@/types/riddle";
|
||||
import { latest } from "maplibre-gl";
|
||||
import * as maplibregl from 'maplibre-gl';
|
||||
import { createStationName } from "@/utils/stringer";
|
||||
import { fetchRiddleData, getRiddleData, setRiddleData } from "@/utils/riddledata";
|
||||
import { heartbeat } from "@/utils/sessionHandler";
|
||||
import { getCompletedRiddles } from "@/utils/completedRiddles";
|
||||
import { isDemoMode } from "@/utils/demoMode";
|
||||
|
||||
export default function Tour() {
|
||||
const riddleData = {
|
||||
"riddles": [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "Der Hüter des Tores",
|
||||
"step": 0,
|
||||
"latitude": 49.089155,
|
||||
"longitude": 9.281336,
|
||||
"points": 500,
|
||||
"failPenaltyPoints": 0,
|
||||
"skipPenaltyPoints": -1,
|
||||
"hints": []
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "Das Schwert im Stein",
|
||||
"step": 1,
|
||||
"latitude": 49.088559,
|
||||
"longitude": 9.281426,
|
||||
"points": 500,
|
||||
"failPenaltyPoints": 0,
|
||||
"skipPenaltyPoints": 0,
|
||||
"hints": []
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"name": "Die Stimme des neuen Königs",
|
||||
"step": 2,
|
||||
"latitude": 49.089259,
|
||||
"longitude": 9.28325,
|
||||
"points": 1000,
|
||||
"failPenaltyPoints": 250,
|
||||
"skipPenaltyPoints": 0,
|
||||
"hints": []
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"name": "Stimmen am Wegesrand",
|
||||
"step": 3,
|
||||
"latitude": 49.089822,
|
||||
"longitude": 9.28523,
|
||||
"points": 1000,
|
||||
"failPenaltyPoints": 100,
|
||||
"skipPenaltyPoints": 0,
|
||||
"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": 0,
|
||||
"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.092218,
|
||||
"longitude": 9.285952,
|
||||
"points": 500,
|
||||
"failPenaltyPoints": 0,
|
||||
"skipPenaltyPoints": 500,
|
||||
"hints": []
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"name": "Lancelots Urteil",
|
||||
"step": 6,
|
||||
"latitude": 49.093505,
|
||||
"longitude": 9.282669,
|
||||
"points": 1500,
|
||||
"failPenaltyPoints": 750,
|
||||
"skipPenaltyPoints": 500,
|
||||
"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,
|
||||
"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,
|
||||
"hints": []
|
||||
}
|
||||
]
|
||||
};
|
||||
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]);
|
||||
|
||||
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;
|
||||
|
||||
const markers = [];
|
||||
for (let i = 0; i < 9; ++i) {
|
||||
const data = riddleData["riddles"].find(v => v.step === i);
|
||||
const data = riddleData.find(v => v.step === nextStep);
|
||||
if (data) {
|
||||
markers.push({
|
||||
id: data?.id,
|
||||
lng: data?.longitude,
|
||||
lat: data?.latitude
|
||||
id: data.id,
|
||||
lng: data.longitude,
|
||||
lat: data.latitude
|
||||
});
|
||||
}
|
||||
setMarkers(markers);
|
||||
}, []);
|
||||
}, [riddleData, completedRiddlesStr, demoMode]);
|
||||
|
||||
const [ stepStr, setStep ] = useLocalStorage(PREF.step, "0");
|
||||
const [ activeRiddle, setActiveRiddle ] = useState<Riddle | null>(null);
|
||||
const [ clickedMarker, setClickedMarker ] = useState<number | null>(null);
|
||||
const [ tourCode, setTourCode ] = useLocalStorage(PREF.code, "");
|
||||
const [ completedRiddlesStr, setCompletedRiddles ] = useLocalStorage(PREF.completed_riddles, "");
|
||||
const [ , setPlayers ] = useLocalStorage(PREF.players, "");
|
||||
|
||||
const [ players, setPlayers ] = useLocalStorage(PREF.players, "");
|
||||
const [ pointsStr, setPoints ] = useLocalStorage(PREF.points, "0");
|
||||
const [ markers, setMarkers ] = useState<PlaceMarker[]>([]);
|
||||
const { gpsStatus, cameraStatus } = usePermissions();
|
||||
const points = Number.parseInt(pointsStr);
|
||||
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 permissionsGranted = gpsStatus === "granted" && cameraStatus === "granted";
|
||||
|
||||
@@ -198,7 +103,38 @@ export default function Tour() {
|
||||
e.stopPropagation();
|
||||
};
|
||||
|
||||
const selectedActiveRiddleData = clickedMarker !== null ? riddleData["riddles"].find(v => v.id === clickedMarker) as Riddle : null;
|
||||
const [ code, ] = useLocalStorage(PREF.code, "");
|
||||
|
||||
useEffect(() => {
|
||||
if (demoMode) return;
|
||||
|
||||
if (code.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const doHeartbeat = () => {
|
||||
heartbeat({
|
||||
"player_count": playerCountStr,
|
||||
"players": players,
|
||||
"worthy_answers": worthyAnswersStr,
|
||||
"completed_riddles": completedRiddlesStr,
|
||||
"points": pointsStr,
|
||||
"bought_hints": boughtHintsStr,
|
||||
"voice_over": voiceOverStr
|
||||
}, code);
|
||||
};
|
||||
|
||||
const intervalId = setInterval(() => {
|
||||
doHeartbeat();
|
||||
}, 50000);
|
||||
doHeartbeat();
|
||||
|
||||
return () => {
|
||||
clearInterval(intervalId);
|
||||
};
|
||||
}, [playerCountStr, players, worthyAnswersStr, completedRiddlesStr, pointsStr, boughtHintsStr, voiceOverStr]);
|
||||
|
||||
const selectedActiveRiddleData = clickedMarker !== null ? riddleData.find(v => v.id === clickedMarker) as Riddle : null;
|
||||
|
||||
return (
|
||||
<div className={styles["screen-container"]}>
|
||||
@@ -232,12 +168,35 @@ export default function Tour() {
|
||||
</div>
|
||||
<div className={styles["main-content"]}>
|
||||
<div className={styles["map"]}>
|
||||
<MapView markers={markers} onMarkerClick={(marker) => {
|
||||
console.log(marker);
|
||||
setClickedMarker(marker.id);
|
||||
<MapView markers={markers} triggerGeolocation={!demoMode} onMarkerClick={(marker, position) => {
|
||||
if (demoMode) {
|
||||
setClickedMarker(marker.id);
|
||||
return;
|
||||
}
|
||||
if (!position) {
|
||||
return;
|
||||
}
|
||||
|
||||
const r = riddleData.find(v => v.id === marker.id) as Riddle;
|
||||
if (!r) {
|
||||
alert("Invalid Riddle ID!");
|
||||
return;
|
||||
}
|
||||
|
||||
const userLngLat = new maplibregl.LngLat(position[0], position[1]);
|
||||
const markerLngLat = new maplibregl.LngLat(marker.lng, marker.lat);
|
||||
|
||||
const distanceMeters = userLngLat.distanceTo(markerLngLat);
|
||||
const isNearby = distanceMeters <= r.requiredDistance;
|
||||
|
||||
if (isNearby || demoMode) {
|
||||
setClickedMarker(marker.id);
|
||||
} else {
|
||||
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%"}}>
|
||||
@@ -248,7 +207,7 @@ export default function Tour() {
|
||||
long={true}
|
||||
style={{margin: "auto", marginTop: "8px"}}
|
||||
onAction={(e) => {
|
||||
setActiveRiddle(riddleData["riddles"].find(v => v.id === clickedMarker) as Riddle);
|
||||
setActiveRiddle(riddleData.find(v => v.id === clickedMarker) as Riddle);
|
||||
e.stopPropagation();
|
||||
}}
|
||||
>STARTEN</OldButton>
|
||||
@@ -257,7 +216,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>
|
||||
@@ -265,16 +240,15 @@ export default function Tour() {
|
||||
: null
|
||||
}
|
||||
</div>
|
||||
<ChargedButton holdDuration={600} onAction={() => {
|
||||
setStep("0");
|
||||
setPlayers("");
|
||||
setPoints("");
|
||||
setCompletedRiddles("");
|
||||
setTourCode("");
|
||||
{ demoMode ? <ChargedButton style={{
|
||||
position: "absolute",
|
||||
bottom: "5%",
|
||||
left: "1%",
|
||||
zIndex: 4
|
||||
}} onAction={() => {
|
||||
localStorage.clear();
|
||||
}}
|
||||
style={{position: "absolute", bottom: "50px", left: "0", zIndex: 9}}
|
||||
>Zurücksetzen</ChargedButton>
|
||||
setStep("0");
|
||||
}}>DEMO BEENDEN</ChargedButton> : null }
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -4,14 +4,20 @@ 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 { 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;
|
||||
let isSubmitting = false;
|
||||
|
||||
export default function WelcomeScreen() {
|
||||
const [tourCode, setTourCode] = useState("");
|
||||
@@ -22,6 +28,14 @@ export default function WelcomeScreen() {
|
||||
const [, setCode ] = useLocalStorage(PREF.code, "");
|
||||
const [, setStep ] = useLocalStorage(PREF.step, "0");
|
||||
|
||||
const [ , setPlayers ] = useLocalStorage(PREF.players, "");
|
||||
const [ , setPlayerCount ] = useLocalStorage(PREF.player_count, "");
|
||||
const [ , setPoints ] = useLocalStorage(PREF.points, "");
|
||||
const [ , setCompletedRiddles ] = useLocalStorage(PREF.completed_riddles, "");
|
||||
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;
|
||||
return Date.now() - cooldownRef.current <= COOLDOWN_MS
|
||||
@@ -48,19 +62,49 @@ export default function WelcomeScreen() {
|
||||
}
|
||||
}, [lastSubmitTs]);
|
||||
|
||||
const submit = () => {
|
||||
const submit = async () => {
|
||||
const value = cleanTourCode(tourCodeRef.current);
|
||||
|
||||
if (!isTourCodeValid() && checkCooldown()) {
|
||||
return;
|
||||
}
|
||||
|
||||
isSubmitting = true;
|
||||
cooldownRef.current = Date.now();
|
||||
setLastSubmitTs(cooldownRef.current);
|
||||
|
||||
console.log("submitted", value);
|
||||
setCode(value);
|
||||
setStep("1");
|
||||
|
||||
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) {
|
||||
alert("Falscher Code oder ein momentan angewendeter Code. Bitte einen Moment warten.");
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(data);
|
||||
setDemoMode(false);
|
||||
setRiddleData(data["riddles"]);
|
||||
if (data["session"] !== undefined && data["session"] !== null) {
|
||||
const s = JSON.parse(data["session"]);
|
||||
setSessionData(s);
|
||||
setStep("2");
|
||||
} else {
|
||||
setStep("1");
|
||||
}
|
||||
};
|
||||
|
||||
const handleChange = (event: ChangeEvent<HTMLInputElement>): boolean => {
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
isolation: isolate;
|
||||
cursor: pointer;
|
||||
background: transparent;
|
||||
color: white;
|
||||
color: black;
|
||||
transition: box-shadow 120ms ease, transform 120ms ease, 150ms ease-out filter, 150ms ease-out color;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
user-select: none;
|
||||
@@ -67,3 +67,29 @@
|
||||
|
||||
/*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;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 3;
|
||||
pointer-events: none;
|
||||
font-size: 1.1rem;
|
||||
color: white;
|
||||
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
|
||||
will-change: clip-path;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
.permission-container {
|
||||
.container {
|
||||
text-align: center;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
@@ -25,6 +25,10 @@
|
||||
-moz-user-select: none; /* Firefox */
|
||||
-ms-user-select: none; /* IE10+/Edge */
|
||||
user-select: none; /* Standard */
|
||||
|
||||
p {
|
||||
max-width: 100% !important;
|
||||
}
|
||||
}
|
||||
|
||||
.button-disabled {
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
.container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
text-align: center;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.outro-video-container {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.outro-video-container video {
|
||||
display: block;
|
||||
position: relative;
|
||||
top: 0;
|
||||
left: 0;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
0% {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.rewatch-controls {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
row-gap: 3rem;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.75);
|
||||
animation: fadeIn 0.5s ease-out 0s 1 normal forwards;
|
||||
}
|
||||
|
||||
.pause-screen {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
row-gap: 3rem;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.25);
|
||||
animation: fadeIn 200ms ease-out 0s 1 normal forwards;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.result-page {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
padding-top: 1rem;
|
||||
padding-bottom: 2rem;
|
||||
|
||||
h2 {
|
||||
font-size: 2rem;
|
||||
color: var(--blue);
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 1.3rem;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
}
|
||||
|
||||
.action-bookmark {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 9.5%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
background-image: url("/buttons/lesezeichen-ohne icons.webp");
|
||||
background-repeat: no-repeat;
|
||||
background-position: top center;
|
||||
background-size: contain;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
-webkit-filter: drop-shadow(2px 2px 4px black);
|
||||
filter: drop-shadow(2px 2px 4px black);
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
|
||||
.bookmark-icon {
|
||||
|
||||
}
|
||||
@@ -19,6 +19,6 @@
|
||||
}
|
||||
|
||||
.status-icon {
|
||||
width: 32px;
|
||||
margin-left: 8px;
|
||||
width: 24px;
|
||||
margin-right: 8px;
|
||||
}
|
||||
@@ -8,13 +8,14 @@
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
bottom: 5dvh;
|
||||
row-gap: 1rem;
|
||||
}
|
||||
|
||||
.content {
|
||||
height: 100%;
|
||||
max-height: 50dvh;
|
||||
p {
|
||||
font-size: 1.2rem;
|
||||
font-size: 1.3rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
}
|
||||
@@ -24,3 +25,9 @@
|
||||
max-height: 35dvh;
|
||||
}
|
||||
}
|
||||
|
||||
.backButton {
|
||||
img {
|
||||
width: 180px;
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
.content-bar {
|
||||
width: 100%;
|
||||
/*height: 100%; Causes Problems! */
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
|
||||
@@ -10,4 +10,5 @@ export interface Riddle {
|
||||
failPenaltyPoints: number;
|
||||
skipPenaltyPoints: number;
|
||||
hints: RiddleHint[];
|
||||
requiredDistance: number;
|
||||
}
|
||||
@@ -5,15 +5,19 @@ export function addBoughtHint(id: number) {
|
||||
if (hints.includes(id)) {
|
||||
return;
|
||||
}
|
||||
hints.push(id)
|
||||
localStorage.setItem(PREF.boughtHints, JSON.stringify(hints));
|
||||
hints.push(id);
|
||||
localStorage.setItem(PREF.bought_hints, JSON.stringify(hints));
|
||||
window.dispatchEvent(new Event('storage'));
|
||||
}
|
||||
|
||||
export function getBoughtHints(): number[] {
|
||||
const hintsList = localStorage.getItem(PREF.boughtHints);
|
||||
const hintsList = localStorage.getItem(PREF.bought_hints);
|
||||
if (hintsList === null) {
|
||||
return [];
|
||||
}
|
||||
return JSON.parse(hintsList);
|
||||
try {
|
||||
return JSON.parse(hintsList);
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { API_PREFIX, HTTP_SCHEME, PREF } from "./const";
|
||||
|
||||
export async function checkCode(code: string) {
|
||||
const res = await fetch(`${HTTP_SCHEME}://${API_PREFIX}/codes?code=${code}`, {
|
||||
"method": "GET",
|
||||
"cache": "no-cache"
|
||||
});
|
||||
if (!res.ok) {
|
||||
return null;
|
||||
}
|
||||
return await res.json();
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { PREF } from "./const";
|
||||
|
||||
export function addCompletedRiddle(step: number) {
|
||||
const riddles = getCompletedRiddles();
|
||||
if (riddles.includes(step)) {
|
||||
return;
|
||||
}
|
||||
riddles.push(step);
|
||||
localStorage.setItem(PREF.completed_riddles, JSON.stringify(riddles));
|
||||
window.dispatchEvent(new Event('storage'));
|
||||
}
|
||||
|
||||
export function getCompletedRiddles(): number[] {
|
||||
const riddleList = localStorage.getItem(PREF.completed_riddles);
|
||||
if (riddleList === null || riddleList.length < 1) {
|
||||
return [];
|
||||
}
|
||||
return JSON.parse(riddleList);
|
||||
}
|
||||
+12
-5
@@ -2,11 +2,18 @@ export enum PREF {
|
||||
code = "PREF_TOUR_CODE",
|
||||
points = "PREF_POINTS",
|
||||
players = "PREF_PLAYERS",
|
||||
riddle_data = "PREF_RIDDLE_DATA",
|
||||
completed_riddles = "PREF_COMPLETED_RIDDLES",
|
||||
step = "PREF_APP_SCREEN_STEP",
|
||||
playerCount = "PREF_PLAYER_COUNT",
|
||||
worthyWords = "PREF_WORTHY_ANSWERS",
|
||||
readerState = "PREF_LAST_READER_STATE",
|
||||
voiceover = "PREF_VOICEOVER_STATE",
|
||||
boughtHints = "PREF_BOUGHT_HINTS"
|
||||
player_count = "PREF_PLAYER_COUNT",
|
||||
worthy_words = "PREF_WORTHY_ANSWERS",
|
||||
voice_over = "PREF_VOICEOVER_STATE",
|
||||
bought_hints = "PREF_BOUGHT_HINTS",
|
||||
demo_mode = "PREF_DEMO_MODE",
|
||||
};
|
||||
|
||||
const isDev = process.env.NODE_ENV === "development";
|
||||
|
||||
export const HTTP_SCHEME = isDev ? "http" : "https";
|
||||
export const WS_SCHEME = isDev ? "ws" : "wss";
|
||||
export const API_PREFIX = isDev ? "192.168.0.110:8080" : "api.excaliburs-erben.de";
|
||||
@@ -0,0 +1,10 @@
|
||||
import { PREF } from "./const";
|
||||
|
||||
export function setDemoMode(demo: boolean) {
|
||||
localStorage.setItem(PREF.demo_mode, demo ? "DEMO" : "");
|
||||
window.dispatchEvent(new Event('storage'));
|
||||
}
|
||||
|
||||
export function isDemoMode(raw: string): boolean {
|
||||
return raw === "DEMO";
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
import { PREF } from "./const";
|
||||
|
||||
export function setPlayerAnswers(answers: string[]) {
|
||||
localStorage.setItem(PREF.worthyWords, JSON.stringify(answers));
|
||||
localStorage.setItem(PREF.worthy_words, JSON.stringify(answers));
|
||||
window.dispatchEvent(new Event('storage'));
|
||||
}
|
||||
|
||||
export function getAnswers(): string[] {
|
||||
const answers = localStorage.getItem(PREF.worthyWords);
|
||||
const answers = localStorage.getItem(PREF.worthy_words);
|
||||
if (answers === null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Player } from "@/types/player";
|
||||
import { PREF } from "./const";
|
||||
|
||||
export const MAX_POINTS = 10000;
|
||||
export const MIN_POINTS = 0;
|
||||
export const MIN_PLAYERS = 2;
|
||||
export const MAX_PLAYERS = 8;
|
||||
|
||||
export function setPlayers(players: Player[]) {
|
||||
localStorage.setItem(PREF.players, JSON.stringify(players));
|
||||
@@ -14,5 +14,9 @@ export function getPlayers(): Player[] {
|
||||
if (players === null) {
|
||||
return [];
|
||||
}
|
||||
return JSON.parse(players);
|
||||
try {
|
||||
return JSON.parse(players);
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import { Player } from "@/types/player";
|
||||
import { API_PREFIX, HTTP_SCHEME, PREF } from "./const";
|
||||
import { Riddle } from "@/types/riddle";
|
||||
|
||||
export function setRiddleData(riddle_data: Riddle[]) {
|
||||
localStorage.setItem(PREF.riddle_data, JSON.stringify(riddle_data));
|
||||
window.dispatchEvent(new Event('storage'));
|
||||
}
|
||||
|
||||
export function getRiddleData(): Riddle[] {
|
||||
const riddle_data = localStorage.getItem(PREF.riddle_data);
|
||||
if (riddle_data === null) {
|
||||
return [];
|
||||
}
|
||||
try {
|
||||
return JSON.parse(riddle_data);
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export async function fetchRiddleData(): Promise<Riddle[] | null> {
|
||||
const res = await fetch(`${HTTP_SCHEME}://${API_PREFIX}/riddles`, {
|
||||
"method": "GET",
|
||||
"cache": "no-cache"
|
||||
});
|
||||
try {
|
||||
return await res.json();
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import { API_PREFIX, HTTP_SCHEME, PREF } from "./const";
|
||||
|
||||
interface SessionData {
|
||||
"player_count": string;
|
||||
"players": string;
|
||||
"worthy_answers": string;
|
||||
"completed_riddles": string;
|
||||
"points": string;
|
||||
"bought_hints": string;
|
||||
"voice_over": string;
|
||||
};
|
||||
|
||||
export async function heartbeat(data: SessionData, code: string) {
|
||||
const res = await fetch(`${HTTP_SCHEME}://${API_PREFIX}/sessions?code=${code}`,
|
||||
{
|
||||
"method": "POST",
|
||||
"cache": "no-cache",
|
||||
"body": JSON.stringify(data)
|
||||
}
|
||||
);
|
||||
return res;
|
||||
}
|
||||
|
||||
export function setSessionData(data: SessionData) {
|
||||
localStorage.setItem(PREF.player_count, data.player_count);
|
||||
localStorage.setItem(PREF.players, data.players);
|
||||
localStorage.setItem(PREF.worthy_words, data.worthy_answers);
|
||||
localStorage.setItem(PREF.completed_riddles, data.completed_riddles);
|
||||
localStorage.setItem(PREF.points, data.points);
|
||||
localStorage.setItem(PREF.bought_hints, data.bought_hints);
|
||||
localStorage.setItem(PREF.voice_over, data.voice_over);
|
||||
}
|
||||
Reference in new issue
Block a user