Compare commits
10
Commits
b5e5cc502d
...
307b6fc77c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
307b6fc77c | ||
|
|
ff6f3e6f4f | ||
|
|
c70141b26a | ||
|
|
cc9fadd30d | ||
|
|
45acdd3400 | ||
|
|
51e5a98a92 | ||
|
|
dbfa9788a7 | ||
|
|
70fb9e4850 | ||
|
|
62cbffdd3f | ||
|
|
5b9fe3ea21 |
No files matched your search
@@ -0,0 +1,5 @@
|
||||
docker build -t git.excaliburs-erben.de/exodus/burg-stett-game:latest .
|
||||
docker push git.excaliburs-erben.de/exodus/burg-stett-game:latest
|
||||
|
||||
# docker save <my_image> | ssh -C user@my.remote.host.com docker load
|
||||
# https://stackoverflow.com/a/31575909
|
||||
@@ -0,0 +1,12 @@
|
||||
services:
|
||||
exodus-burg-stett-game:
|
||||
image: git.excaliburs-erben.de/exodus/burg-stett-game:latest
|
||||
container_name: exodus-burg-stett-game
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "80:80"
|
||||
|
||||
networks:
|
||||
default:
|
||||
name: proxy_net
|
||||
external: true
|
||||
+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.
+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,6 +12,7 @@ interface ChargedButtonProps {
|
||||
onAction?: () => void;
|
||||
disabled?: boolean;
|
||||
red?: boolean;
|
||||
whiteText?: boolean;
|
||||
}
|
||||
|
||||
export default function ChargedButton({
|
||||
@@ -22,6 +23,7 @@ export default function ChargedButton({
|
||||
onAction,
|
||||
disabled = false,
|
||||
red = false,
|
||||
whiteText = false,
|
||||
}: ChargedButtonProps) {
|
||||
const [progress, setProgress] = useState(0);
|
||||
const [, setIsCharging] = useState(false);
|
||||
@@ -118,7 +120,7 @@ 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")}
|
||||
|
||||
+26
-19
@@ -20,6 +20,7 @@ export interface MapViewProps {
|
||||
onMarkerClick?: (marker: PlaceMarker, currentPosition?: [number, number] | null) => void;
|
||||
// Default vector tile source or tile pattern
|
||||
tileUrlTemplate?: string;
|
||||
triggerGeolocation?: boolean;
|
||||
}
|
||||
|
||||
// MapTile calculations for Bounding Box precaching (Slippy Map Tile Names)
|
||||
@@ -38,11 +39,12 @@ const TILE_CACHE_NAME = 'excalibur-offline-map-tiles-v1';
|
||||
const DEFAULT_TILE_URL = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png';
|
||||
|
||||
export default function MapView({
|
||||
initialCenter = [9.282050, 49.090165],
|
||||
initialCenter = [9.283050, 49.091765],
|
||||
initialZoom = 15,
|
||||
markers = [],
|
||||
onMarkerClick,
|
||||
tileUrlTemplate = DEFAULT_TILE_URL,
|
||||
triggerGeolocation = true,
|
||||
}: MapViewProps) {
|
||||
const mapContainerRef = useRef<HTMLDivElement>(null);
|
||||
const mapRef = useRef<maplibregl.Map | null>(null);
|
||||
@@ -84,6 +86,7 @@ export default function MapView({
|
||||
style: mapStyle,
|
||||
center: initialCenter,
|
||||
zoom: initialZoom,
|
||||
maxZoom: 18,
|
||||
});
|
||||
|
||||
map.addControl(new maplibregl.NavigationControl({ visualizePitch: true }), 'bottom-right');
|
||||
@@ -94,33 +97,37 @@ export default function MapView({
|
||||
el.width = 42;
|
||||
el.className = styles["sword"];
|
||||
|
||||
const geolocate = new maplibregl.GeolocateControl({
|
||||
positionOptions: {
|
||||
enableHighAccuracy: true,
|
||||
},
|
||||
trackUserLocation: true,
|
||||
showUserLocation: true,
|
||||
showAccuracyCircle: false,
|
||||
});
|
||||
geolocate._dotElement = el;
|
||||
let geolocate = null;
|
||||
if (triggerGeolocation) {
|
||||
geolocate = new maplibregl.GeolocateControl({
|
||||
positionOptions: {
|
||||
enableHighAccuracy: true,
|
||||
},
|
||||
trackUserLocation: true,
|
||||
showUserLocation: true,
|
||||
showAccuracyCircle: false,
|
||||
});
|
||||
geolocate._dotElement = el;
|
||||
|
||||
geolocate.on('geolocate', (e: any) => {
|
||||
console.log(e);
|
||||
userPositionRef.current = [e.coords.longitude, e.coords.latitude];
|
||||
});
|
||||
geolocate.on('geolocate', (e: any) => {
|
||||
userPositionRef.current = [e.coords.longitude, e.coords.latitude];
|
||||
});
|
||||
|
||||
map.addControl(geolocate, 'bottom-right');
|
||||
map.addControl(geolocate, 'bottom-right');
|
||||
}
|
||||
|
||||
map.addControl(new maplibregl.ScaleControl({ unit: 'metric' }), 'bottom-left');
|
||||
|
||||
map.on('load', async () => {
|
||||
setMapReady(true);
|
||||
navigator.geolocation.getCurrentPosition((pos) => {
|
||||
userPositionRef.current = [pos.coords.longitude, pos.coords.latitude];
|
||||
map.setCenter([pos.coords.longitude, pos.coords.latitude]);
|
||||
geolocate.trigger();
|
||||
if (triggerGeolocation && geolocate) {
|
||||
userPositionRef.current = [pos.coords.longitude, pos.coords.latitude];
|
||||
map.setCenter([pos.coords.longitude, pos.coords.latitude]);
|
||||
geolocate.trigger();
|
||||
}
|
||||
}, () => {
|
||||
geolocate.trigger();
|
||||
if (triggerGeolocation && geolocate) geolocate.trigger();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ export default function RiddleHintPage({
|
||||
voiceOverMode
|
||||
}: RiddleHintProps) {
|
||||
//const [ pointsStr, ] = useLocalStorage(PREF.points, "");
|
||||
const [ boughtHintsStr, ] = useLocalStorage(PREF.boughtHints, "");
|
||||
const [ boughtHintsStr, ] = useLocalStorage(PREF.bought_hints, "");
|
||||
const [ showBuyHint, setShowBuyHint ] = useState(false);
|
||||
const [ showSkipRiddle, setShowSkipRiddle ] = useState(false);
|
||||
const [ currentVoiceOver, setCurrentVoiceOver ] = useState(-1);
|
||||
@@ -68,8 +68,8 @@ export default function RiddleHintPage({
|
||||
<img src={"/icons/hinweis-dunkel.svg"} className={styles["hint-icon"]}/>
|
||||
<p className={clsx(styles["hint-p"], "eisenkraft-regular")}>Hinweise</p>
|
||||
</div>
|
||||
{ nextHintToBuy && nextHintToBuy.penaltyPoints > 0 && <p>Ein {boughtHintObjects.length > 0 ? "weiterer" : ""} Hinweis kostet euch {nextHintToBuy.penaltyPoints} Rufpunkte.</p> }
|
||||
{ nextHintToBuy && nextHintToBuy.penaltyPoints === 0 && <p>Ein {boughtHintObjects.length > 0 ? "weiterer" : ""} Hinweis kostet euch zum Glück keine Rufpunkte.</p> }
|
||||
{ (nextHintToBuy && nextHintToBuy.penaltyPoints > 0) ? <p>Ein {boughtHintObjects.length > 0 ? "weiterer" : ""} Hinweis kostet euch {nextHintToBuy.penaltyPoints} Rufpunkte.</p> : null }
|
||||
{ (nextHintToBuy && nextHintToBuy.penaltyPoints === 0) ? <p>Ein {boughtHintObjects.length > 0 ? "weiterer" : ""} Hinweis kostet euch zum Glück keine Rufpunkte.</p> : null }
|
||||
{ riddle.hints.length === 0 && <p>Für das Rätsel gibt es keine Hinweise!</p> }
|
||||
{ riddle.skipPenaltyPoints === 0 && <p>Überspringt ihr das Rätsel, bekommt ihr keine Rufpunkte.</p> }
|
||||
{ riddle.skipPenaltyPoints > 0 && <p>Überspringt ihr das Rätsel, bekommt ihr {riddle.skipPenaltyPoints} Rufpunkte abgezogen.</p> }
|
||||
|
||||
@@ -20,13 +20,14 @@ import { createStationName } from "@/utils/stringer";
|
||||
|
||||
export interface RiddleScreenControls {
|
||||
riddle: Riddle;
|
||||
exitFunction: () => void;
|
||||
exitFunction: () => Promise<void>;
|
||||
showBanner: Dispatch<SetStateAction<boolean>>;
|
||||
page: number;
|
||||
setPage: (pageIndex: number) => void;
|
||||
voiceOverMode: VoiceOverMode;
|
||||
requestingHint: boolean;
|
||||
dismissHint: () => void;
|
||||
onRegisterCloseInterceptor: (closeInterceptor: () => Promise<boolean>) => void;
|
||||
};
|
||||
|
||||
interface RiddleScreenProps {
|
||||
@@ -37,11 +38,17 @@ interface RiddleScreenProps {
|
||||
export default function RiddleScreen({ riddle, onDismiss }: RiddleScreenProps) {
|
||||
const [page, setPage ] = useState(0);
|
||||
const [ showHintPage, setShowHintPage ] = useState(false);
|
||||
const [ voiceOverState, setVoiceOverState ] = useLocalStorage(PREF.voiceover, "off");
|
||||
const [ voiceOverState, setVoiceOverState ] = useLocalStorage(PREF.voice_over, "off");
|
||||
const [ showBanner, setShowBanner ] = useState(true);
|
||||
const contentRef = useRef<HTMLDivElement | null>(null);
|
||||
const closeInterceptorRef = useRef<(() => Promise<boolean>) | null>(null);
|
||||
|
||||
const exitFunction = () => {
|
||||
const exitFunction = async () => {
|
||||
if (closeInterceptorRef.current) {
|
||||
if (!await closeInterceptorRef.current()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
onDismiss();
|
||||
};
|
||||
|
||||
@@ -62,6 +69,9 @@ export default function RiddleScreen({ riddle, onDismiss }: RiddleScreenProps) {
|
||||
"requestingHint": showHintPage,
|
||||
"dismissHint": () => {
|
||||
setShowHintPage(false);
|
||||
},
|
||||
"onRegisterCloseInterceptor": (fn) => {
|
||||
closeInterceptorRef.current = fn;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -30,7 +30,7 @@ export default function Riddle_1({
|
||||
requestingHint,
|
||||
dismissHint,
|
||||
}: RiddleScreenControls) {
|
||||
const [ playerCountStr, setPlayerCount ] = useLocalStorage(PREF.playerCount, "");
|
||||
const [ playerCountStr, setPlayerCount ] = useLocalStorage(PREF.player_count, "");
|
||||
const playerCount = Number.parseInt(playerCountStr) || 0;
|
||||
|
||||
const [ nameScreen, setNameScreen ] = useState(0);
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useEffect, useMemo, useRef, useState } from "react";
|
||||
import OldButton from "../OldButton";
|
||||
import styles from "@/css/RiddleStyles.module.css";
|
||||
import { useLocalStorage } from "@/hooks/useLocalStorage";
|
||||
import { PREF } from "@/utils/const";
|
||||
import { API_PREFIX, PREF, WS_SCHEME } from "@/utils/const";
|
||||
import { RiddleScreenControls } from "../RiddleScreen";
|
||||
import { addPoints } from "@/utils/points";
|
||||
import RiddleCompleteBanner from "../RiddleCompleteBanner";
|
||||
@@ -12,17 +12,48 @@ import { getPlayers } from "@/utils/players";
|
||||
import VoiceOver from "../VoiceOver";
|
||||
import RiddleHintPage from "../RiddleHintPage";
|
||||
import { Player } from "@/types/player";
|
||||
import { getSwordState } from "@/utils/swordTalk";
|
||||
import GameController from "../GameController";
|
||||
import { addCompletedRiddle } from "@/utils/completedRiddles";
|
||||
import ChargedButton from "../ChargedButton";
|
||||
import { isDemoMode } from "@/utils/demoMode";
|
||||
|
||||
export type ConnectionStatus = "disconnected" | "connected";
|
||||
export const TOPIC_PREFIX = (process.env.NODE_ENV === "development") ? "staging/outdoor/king-arthur/sword" : "outdoor/king-arthur/sword";
|
||||
|
||||
export type ConnectionStatus = "disconnected" | "connected" | "connecting";
|
||||
|
||||
interface MQTTMessage {
|
||||
topic: string;
|
||||
payload: string;
|
||||
}
|
||||
|
||||
let awaitTryAbort = false;
|
||||
|
||||
/**
|
||||
* Waits until a condition function returns true or a timeout occurs.
|
||||
*
|
||||
* @param {Function} conditionFn - A function that returns a boolean.
|
||||
* @param {number} timeoutMs - Timeout in milliseconds (default: 3000ms).
|
||||
* @param {number} intervalMs - Polling interval in milliseconds (default: 100ms).
|
||||
* @returns {Promise<boolean>} Resolves to true if condition is met, rejects on timeout.
|
||||
*/
|
||||
function waitUntilTrue(conditionFn: () => boolean, timeoutMs = 3000, intervalMs = 100) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const startTime = Date.now();
|
||||
|
||||
const intervalId = setInterval(() => {
|
||||
if (conditionFn()) {
|
||||
clearInterval(intervalId);
|
||||
resolve(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Date.now() - startTime >= timeoutMs) {
|
||||
clearInterval(intervalId);
|
||||
reject(new Error("Timeout"));
|
||||
}
|
||||
}, intervalMs);
|
||||
});
|
||||
}
|
||||
|
||||
export default function Riddle_2({
|
||||
page,
|
||||
setPage,
|
||||
@@ -32,10 +63,15 @@ 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]);
|
||||
@@ -64,56 +100,95 @@ export default function Riddle_2({
|
||||
const [ showControls, setShowControls ] = useState(false);
|
||||
|
||||
const sendCommand = (topic: string, payload: string) => {
|
||||
if (demoMode) return true;
|
||||
if (wsRef.current && wsRef.current.readyState === WebSocket.OPEN) {
|
||||
wsRef.current.send(JSON.stringify({ topic, payload }));
|
||||
return true;
|
||||
} else {
|
||||
alert('WebSocket is not connected.');
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const tourCode = "TESTTEST!";
|
||||
wsRef.current = new WebSocket(`ws://localhost:8080/ws/bridge?tourCode=${tourCode}`);
|
||||
if (demoMode) return;
|
||||
|
||||
wsRef.current.onopen = () => {
|
||||
setStatus("connected");
|
||||
};
|
||||
let isCancelled = false;
|
||||
let reconnectTimeout: NodeJS.Timeout;
|
||||
|
||||
wsRef.current.onmessage = (event) => {
|
||||
const data: MQTTMessage = JSON.parse(event.data);
|
||||
const connect = () => {
|
||||
if (isCancelled) return;
|
||||
setStatus("connecting");
|
||||
|
||||
const ws = new WebSocket(`${WS_SCHEME}://${API_PREFIX}/ws/bridge?tourCode=${tourCode}`);
|
||||
wsRef.current = ws;
|
||||
|
||||
if (data.topic === 'outdoor/king-arthur/sword/stat') {
|
||||
setSwordStatus(data.payload);
|
||||
} else if (data.topic === 'outdoor/king-arthur/throne/stat') {
|
||||
//setThroneStatus(data.payload);
|
||||
} else if (data.topic.includes('/event')) {
|
||||
console.log(`Event received on ${data.topic}:`, data.payload);
|
||||
if (data.payload === "pull-denied") {
|
||||
setCanGoNext(true);
|
||||
} else if (data.payload === "pulled-out") {
|
||||
setIsSwordBackIn(false);
|
||||
} else if (data.payload === "locked") {
|
||||
setIsSwordBackIn(true);
|
||||
} else if (data.payload === "ceremonyDone") {
|
||||
setCanGoNext(true);
|
||||
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();
|
||||
};
|
||||
};
|
||||
|
||||
wsRef.current.onclose = () => {
|
||||
sendCommand('outdoor/king-arthur/sword/set', 'abortTry');
|
||||
setStatus("disconnected");
|
||||
};
|
||||
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 = [
|
||||
(
|
||||
<div key={0}>
|
||||
@@ -130,12 +205,12 @@ export default function Riddle_2({
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
<OldButton red={false} onAction={() => {
|
||||
if (!sendCommand('outdoor/king-arthur/sword/set', 'stayLocked')) {
|
||||
if (!sendCommand(`${TOPIC_PREFIX}/set`, 'stayLocked')) {
|
||||
return;
|
||||
}
|
||||
setCanGoNext(false);
|
||||
setPage(1);
|
||||
}}>WEITER</OldButton>
|
||||
}}>PRÜFUNG STARTEN</OldButton>
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
@@ -156,28 +231,28 @@ export default function Riddle_2({
|
||||
<p style={{ fontSize: '0.6rem' }}><strong>Stat:<br></br></strong> {swordStatus}</p>
|
||||
<button
|
||||
style={{ fontSize: '0.6rem', padding: '4px 8px' }}
|
||||
onClick={() => sendCommand('outdoor/king-arthur/sword/set', 'releaseLock')}
|
||||
onClick={() => sendCommand(`${TOPIC_PREFIX}/set`, 'releaseLock')}
|
||||
>
|
||||
Release Lock
|
||||
</button>
|
||||
<br/><br/>
|
||||
<button
|
||||
style={{ fontSize: '0.6rem', padding: '4px 8px' }}
|
||||
onClick={() => sendCommand('outdoor/king-arthur/sword/set', 'stayLocked')}
|
||||
onClick={() => sendCommand(`${TOPIC_PREFIX}/set`, 'stayLocked')}
|
||||
>
|
||||
Stay Locked
|
||||
</button>
|
||||
<br/><br/>
|
||||
<button
|
||||
style={{ fontSize: '0.6rem', padding: '4px 8px' }}
|
||||
onClick={() => sendCommand('outdoor/king-arthur/sword/set', 'gameStarted')}
|
||||
onClick={() => sendCommand(`${TOPIC_PREFIX}/set`, 'gameStarted')}
|
||||
>
|
||||
Game Started
|
||||
</button>
|
||||
<br/><br/>
|
||||
<button
|
||||
style={{ fontSize: '0.6rem', padding: '4px 8px' }}
|
||||
onClick={() => sendCommand('outdoor/king-arthur/sword/set', 'gameFinished')}
|
||||
onClick={() => sendCommand(`${TOPIC_PREFIX}/set`, 'gameFinished')}
|
||||
>
|
||||
Game Stopped
|
||||
</button>
|
||||
@@ -186,7 +261,7 @@ export default function Riddle_2({
|
||||
<br/><br/>
|
||||
<button
|
||||
style={{ fontSize: '0.6rem', padding: '4px 8px' }}
|
||||
onClick={() => sendCommand('outdoor/king-arthur/sword/cfg', 'playSound:' + soundInput)}
|
||||
onClick={() => sendCommand(`${TOPIC_PREFIX}/cfg`, 'playSound:' + soundInput)}
|
||||
>
|
||||
Play Sound
|
||||
</button>
|
||||
@@ -195,26 +270,37 @@ export default function Riddle_2({
|
||||
</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('outdoor/king-arthur/sword/set', 'releaseLock')) {
|
||||
if (!sendCommand(`${TOPIC_PREFIX}/set`, 'releaseLock')) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (!sendCommand('outdoor/king-arthur/sword/set', 'stayLocked')) {
|
||||
if (!sendCommand(`${TOPIC_PREFIX}/set`, 'stayLocked')) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
setCanGoNext(false);
|
||||
setPlayerIndex(playerIndex+1);
|
||||
}
|
||||
}} disabled={!canGoNext}>WEITER</OldButton>
|
||||
{playerIndex < 1 ? <OldButton red={true} onAction={() => setPage(0)} className={styles["backButton"]}>ZURÜCK</OldButton> : null}
|
||||
}} disabled={!canGoNext && !demoMode}>{(playerIndex >= players.length-1) ? "PRÜFUNG BEENDEN" : "NÄCHSTER PRÜFLING"}</ChargedButton>
|
||||
{playerIndex < 1 ? <OldButton red={true} onAction={async () => {
|
||||
if (demoMode) {
|
||||
setPage(0);
|
||||
return;
|
||||
}
|
||||
awaitTryAbort = false;
|
||||
sendCommand(`${TOPIC_PREFIX}/set`, 'abortTry');
|
||||
await waitUntilTrue(() => {
|
||||
return awaitTryAbort;
|
||||
});
|
||||
setPage(0);
|
||||
}} className={styles["backButton"]}>ZURÜCK</OldButton> : null}
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
@@ -233,7 +319,7 @@ 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={!isSwordBackIn} onAction={() => exitFunction()}>ZURÜCK ZUR KARTE</OldButton>
|
||||
<OldButton red={false} disabled={!isSwordBackIn && !demoMode} onAction={() => exitFunction()}>ZURÜCK ZUR KARTE</OldButton>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -13,6 +13,7 @@ import OldTextInput from "../OldTextInput";
|
||||
import VoiceOver from "../VoiceOver";
|
||||
import RiddleHintPage from "../RiddleHintPage";
|
||||
import { addCompletedRiddle } from "@/utils/completedRiddles";
|
||||
import ChargedButton from "../ChargedButton";
|
||||
|
||||
export default function Riddle_5({
|
||||
page,
|
||||
@@ -64,7 +65,7 @@ export default function Riddle_5({
|
||||
onChange={(e) => setSolution(e.target.value)}
|
||||
value={solution}
|
||||
/>
|
||||
<OldButton red={false} onAction={() => {
|
||||
<ChargedButton red={false} onAction={() => {
|
||||
const s = solution.toLowerCase().trim();
|
||||
if (s.length < 2) {
|
||||
return;
|
||||
@@ -78,7 +79,7 @@ export default function Riddle_5({
|
||||
setPage(2);
|
||||
}
|
||||
addCompletedRiddle(riddle.step);
|
||||
}} disabled={false}>EINREICHEN</OldButton>
|
||||
}} disabled={false}>EINREICHEN</ChargedButton>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
|
||||
@@ -12,6 +12,7 @@ import VoiceOver from "../VoiceOver";
|
||||
import { addPoints, takePoints } from "@/utils/points";
|
||||
import RiddleHintPage from "../RiddleHintPage";
|
||||
import { addCompletedRiddle } from "@/utils/completedRiddles";
|
||||
import ChargedButton from "../ChargedButton";
|
||||
|
||||
const Riddle_7_AR_View = dynamic(
|
||||
() => import('../Riddle_7_AR_View'),
|
||||
@@ -104,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);
|
||||
@@ -113,7 +114,7 @@ export default function Riddle_7({
|
||||
setPage(5);
|
||||
}
|
||||
addCompletedRiddle(riddle.step);
|
||||
}}>ÜBERPRÜFEN!</OldButton>
|
||||
}}>ÜBERPRÜFEN!</ChargedButton>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
|
||||
@@ -11,6 +11,8 @@ import { addPoints, takePoints } from "@/utils/points";
|
||||
import RiddleHintPage from "../RiddleHintPage";
|
||||
import ChargedButton from "../ChargedButton";
|
||||
import { addCompletedRiddle } from "@/utils/completedRiddles";
|
||||
import { useLocalStorage } from "@/hooks/useLocalStorage";
|
||||
import { PREF } from "@/utils/const";
|
||||
|
||||
export default function Riddle_9({
|
||||
page,
|
||||
@@ -22,6 +24,7 @@ export default function Riddle_9({
|
||||
requestingHint,
|
||||
dismissHint,
|
||||
}: RiddleScreenControls) {
|
||||
const [ screenPageStr, setScreenPage ] = useLocalStorage(PREF.step, "");
|
||||
const [answer, setAnswer] = useState("");
|
||||
|
||||
const pages = [
|
||||
@@ -103,7 +106,9 @@ export default function Riddle_9({
|
||||
<p>Ein weiterer Schritt zur Krone ist getan.</p>
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
<ChargedButton red={false} disabled={false} onAction={() => exitFunction()}>ERGEBNIS ANZEIGEN</ChargedButton>
|
||||
<ChargedButton red={false} disabled={false} onAction={() => {
|
||||
setScreenPage("3");
|
||||
}}>ERGEBNIS ANZEIGEN</ChargedButton>
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
@@ -122,7 +127,9 @@ export default function Riddle_9({
|
||||
<p>Euer Fehler kostet euch Ansehen, doch die Bedeutung des Vermächtnisses ist nun klar.</p>
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
<ChargedButton red={false} disabled={false} onAction={() => exitFunction()}>ERGEBNIS ANZEIGEN</ChargedButton>
|
||||
<ChargedButton red={false} disabled={false} onAction={() => {
|
||||
setScreenPage("3");
|
||||
}}>ERGEBNIS ANZEIGEN</ChargedButton>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
- [ ] Turn Riddles into seperate, dynamically loaded, components
|
||||
- [ ] Create script to update riddles
|
||||
- [ ] Link components to Database
|
||||
- [ ] Preload required riddles at start of tour
|
||||
@@ -3,31 +3,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,189 @@
|
||||
import { useLocalStorage } from "@/hooks/useLocalStorage"
|
||||
import { PREF } from "@/utils/const"
|
||||
import ChargedButton from "../ChargedButton";
|
||||
import styles from "@/css/Outro.module.css";
|
||||
import { ChangeEvent, InputEvent, MouseEvent, MouseEventHandler, PointerEvent, useEffect, useMemo, useRef, useState } from "react";
|
||||
import Image from "next/image";
|
||||
import StyledContainer from "../StyledContainer";
|
||||
import OldButton from "../OldButton";
|
||||
import OldTextInput from "../OldTextInput";
|
||||
import clsx from "clsx";
|
||||
import { getPoints } from "@/utils/points";
|
||||
import VoiceOver from "../VoiceOver";
|
||||
import { VoiceOverMode } from "@/types/voiceOverMode";
|
||||
import { isDemoMode } from "@/utils/demoMode";
|
||||
import { finishSession } from "@/utils/sessionHandler";
|
||||
|
||||
export default function Outro() {
|
||||
const [ tourCode, setTourCode ] = useLocalStorage(PREF.code, "");
|
||||
const [ resultPage, setResultPage ] = useState(0);
|
||||
const [ stepStr, setStep ] = useLocalStorage(PREF.step, "0");
|
||||
const [ pointsStr, setPoints ] = useLocalStorage(PREF.points, "0");
|
||||
const [ playersStr, setPlayers ] = useLocalStorage(PREF.players, "");
|
||||
const [ worthyWordsStr, setWorthyWords ] = useLocalStorage(PREF.worthy_words, "");
|
||||
const [ rewatchScreen, setRewatchScreen ] = useState(false);
|
||||
const [ videoEnded, setVideoEnded ] = useState(false);
|
||||
const [ videoPaused, setVideoPaused ] = useState(false);
|
||||
const [ voiceOverState, setVoiceOverState ] = useLocalStorage(PREF.voice_over, "off");
|
||||
const [ boughtHintsStr, setBoughtHints ] = useLocalStorage(PREF.bought_hints, "");
|
||||
const points = useMemo(() => {
|
||||
return getPoints();
|
||||
}, [pointsStr]);
|
||||
const outroVideoRef = useRef<HTMLVideoElement | null>(null);
|
||||
|
||||
const [ demoModeStr, ] = useLocalStorage(PREF.demo_mode, "");
|
||||
const demoMode = useMemo(() => isDemoMode(demoModeStr), [demoModeStr]);
|
||||
|
||||
const handleVideoClick = (e: PointerEvent<HTMLVideoElement>): boolean => {
|
||||
e.currentTarget.play();
|
||||
return true;
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!tourCode || tourCode.length === 0 || demoMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
finishSession(tourCode).then((res) => {
|
||||
if (!res.ok) {
|
||||
finishSession(tourCode).finally(() => {
|
||||
setTourCode("");
|
||||
});
|
||||
} else {
|
||||
setTourCode("");
|
||||
}
|
||||
}).catch(() => {
|
||||
setTourCode("");
|
||||
});
|
||||
}, [tourCode]);
|
||||
|
||||
const pages = [
|
||||
(
|
||||
<div className={styles["outro-video-container"]} key={0}>
|
||||
<video
|
||||
ref={outroVideoRef}
|
||||
disablePictureInPicture={true}
|
||||
autoPlay={true}
|
||||
loop={false}
|
||||
autoFocus={true}
|
||||
width={"100%"}
|
||||
onEnded={() => setVideoEnded(true)}
|
||||
onAbort={() => setVideoEnded(true)}
|
||||
onError={() => setVideoEnded(true)}
|
||||
onPause={() => setVideoPaused(true)}
|
||||
onPlay={() => setVideoPaused(false)}
|
||||
onClick={handleVideoClick}
|
||||
onContextMenu={(e) => {
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}}
|
||||
playsInline={true}
|
||||
>
|
||||
<source src="/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>
|
||||
)
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { useLocalStorage } from "@/hooks/useLocalStorage"
|
||||
import { PREF } from "@/utils/const"
|
||||
import { API_PREFIX, PREF } from "@/utils/const"
|
||||
import ChargedButton from "../ChargedButton";
|
||||
import styles from "@/css/Tour.module.css";
|
||||
import MapView, { PlaceMarker } from "../MapView";
|
||||
@@ -16,21 +16,50 @@ import { MAX_POINTS, MIN_POINTS } from "@/utils/points";
|
||||
import { Riddle } from "@/types/riddle";
|
||||
import * as maplibregl from 'maplibre-gl';
|
||||
import { createStationName } from "@/utils/stringer";
|
||||
import { getRiddleData } from "@/utils/riddledata";
|
||||
import { fetchRiddleData, getRiddleData, setRiddleData } from "@/utils/riddledata";
|
||||
import { heartbeat } from "@/utils/sessionHandler";
|
||||
import { getCompletedRiddles } from "@/utils/completedRiddles";
|
||||
import { isDemoMode } from "@/utils/demoMode";
|
||||
|
||||
export default function Tour() {
|
||||
const [ demoModeStr, ] = useLocalStorage(PREF.demo_mode, "");
|
||||
const demoMode = useMemo(() => isDemoMode(demoModeStr), [demoModeStr]);
|
||||
|
||||
const [ showTooFar, setShowTooFar ] = useState(false);
|
||||
const [ completedRiddlesStr, ] = useLocalStorage(PREF.completed_riddles, "");
|
||||
const [ riddleDataStr, ] = useLocalStorage(PREF.riddle_data, "");
|
||||
const riddleData: Riddle[] = useMemo(() => {
|
||||
return getRiddleData();
|
||||
}, [riddleDataStr]);
|
||||
|
||||
useEffect(() => {
|
||||
fetchRiddleData().then((riddleData) => {
|
||||
if (riddleData === null) {
|
||||
alert("Could not update Riddle Data!");
|
||||
return;
|
||||
}
|
||||
setRiddleData(riddleData["riddles"]);
|
||||
});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!riddleData) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (demoMode) {
|
||||
const markers = [];
|
||||
const riddles = riddleData.sort((a, b) => a.step - b.step)
|
||||
for (let i = 0; i < riddles.length; ++i) {
|
||||
markers.push({
|
||||
id: riddles[i].id,
|
||||
lng: riddles[i].longitude,
|
||||
lat: riddles[i].latitude
|
||||
});
|
||||
}
|
||||
setMarkers(markers);
|
||||
return;
|
||||
}
|
||||
|
||||
const completedRiddles = getCompletedRiddles();
|
||||
const nextStep = completedRiddles.length;
|
||||
@@ -45,7 +74,7 @@ export default function Tour() {
|
||||
});
|
||||
}
|
||||
setMarkers(markers);
|
||||
}, [riddleData, completedRiddlesStr]);
|
||||
}, [riddleData, completedRiddlesStr, demoMode]);
|
||||
|
||||
const [ stepStr, setStep ] = useLocalStorage(PREF.step, "0");
|
||||
const [ activeRiddle, setActiveRiddle ] = useState<Riddle | null>(null);
|
||||
@@ -57,10 +86,10 @@ export default function Tour() {
|
||||
const [ markers, setMarkers ] = useState<PlaceMarker[]>([]);
|
||||
const { gpsStatus, cameraStatus } = usePermissions();
|
||||
const points = Number.parseInt(pointsStr);
|
||||
const [ worthyAnswersStr, ] = useLocalStorage(PREF.worthyWords, "");
|
||||
const [ boughtHintsStr, ] = useLocalStorage(PREF.boughtHints, "");
|
||||
const [ playerCountStr, ] = useLocalStorage(PREF.playerCount, "");
|
||||
const [ voiceOverStr, ] = useLocalStorage(PREF.voiceover, "");
|
||||
const [ worthyAnswersStr, ] = useLocalStorage(PREF.worthy_words, "");
|
||||
const [ boughtHintsStr, ] = useLocalStorage(PREF.bought_hints, "");
|
||||
const [ playerCountStr, ] = useLocalStorage(PREF.player_count, "");
|
||||
const [ voiceOverStr, ] = useLocalStorage(PREF.voice_over, "");
|
||||
|
||||
const permissionsGranted = gpsStatus === "granted" && cameraStatus === "granted";
|
||||
|
||||
@@ -76,26 +105,35 @@ export default function Tour() {
|
||||
|
||||
const [ code, ] = useLocalStorage(PREF.code, "");
|
||||
|
||||
/*useEffect(() => {
|
||||
useEffect(() => {
|
||||
if (demoMode) return;
|
||||
|
||||
if (code.length === 0) {
|
||||
return;
|
||||
}
|
||||
const intervalId = setInterval(() => {
|
||||
|
||||
const doHeartbeat = () => {
|
||||
heartbeat({
|
||||
"playerCount": playerCountStr,
|
||||
"player_count": playerCountStr,
|
||||
"players": players,
|
||||
"worthy_answers": worthyAnswersStr,
|
||||
"completed_riddles": completedRiddlesStr,
|
||||
"points": pointsStr,
|
||||
"boughtHints": boughtHintsStr,
|
||||
"voiceOverStr": voiceOverStr
|
||||
"bought_hints": boughtHintsStr,
|
||||
"voice_over": voiceOverStr
|
||||
}, code);
|
||||
}, 2000);
|
||||
// TODO: Check if Code is valid.
|
||||
};
|
||||
|
||||
const intervalId = setInterval(() => {
|
||||
doHeartbeat();
|
||||
}, 50000);
|
||||
doHeartbeat();
|
||||
|
||||
return () => {
|
||||
clearInterval(intervalId);
|
||||
};
|
||||
}, [playerCountStr, players, worthyAnswersStr, completedRiddlesStr, pointsStr, boughtHintsStr, voiceOverStr]);*/
|
||||
}, [playerCountStr, players, worthyAnswersStr, completedRiddlesStr, pointsStr, boughtHintsStr, voiceOverStr]);
|
||||
|
||||
const selectedActiveRiddleData = clickedMarker !== null ? riddleData.find(v => v.id === clickedMarker) as Riddle : null;
|
||||
|
||||
@@ -131,8 +169,11 @@ export default function Tour() {
|
||||
</div>
|
||||
<div className={styles["main-content"]}>
|
||||
<div className={styles["map"]}>
|
||||
<MapView markers={markers} onMarkerClick={(marker, position) => {
|
||||
console.log(marker, position);
|
||||
<MapView markers={markers} triggerGeolocation={!demoMode} onMarkerClick={(marker, position) => {
|
||||
if (demoMode) {
|
||||
setClickedMarker(marker.id);
|
||||
return;
|
||||
}
|
||||
if (!position) {
|
||||
return;
|
||||
}
|
||||
@@ -149,14 +190,14 @@ export default function Tour() {
|
||||
const distanceMeters = userLngLat.distanceTo(markerLngLat);
|
||||
const isNearby = distanceMeters <= r.requiredDistance;
|
||||
|
||||
if (isNearby) {
|
||||
if (isNearby || demoMode) {
|
||||
setClickedMarker(marker.id);
|
||||
} else {
|
||||
alert(`Ihr seid noch zu weit entfernt!`);
|
||||
setShowTooFar(true);
|
||||
}
|
||||
}}></MapView>
|
||||
</div>
|
||||
<div className={styles["riddle-overlay"]} style={{display: clickedMarker !== null ? "" : "none"}}>
|
||||
{ clickedMarker && <div className={styles["riddle-overlay"]}>
|
||||
{ activeRiddle === null ?
|
||||
<OldPopUp onDismiss={dismissFunc}>
|
||||
<div style={{textAlign: "center", width: "100%"}}>
|
||||
@@ -176,7 +217,23 @@ export default function Tour() {
|
||||
:
|
||||
<RiddleScreen onDismiss={_dismissFunc} riddle={activeRiddle}></RiddleScreen>
|
||||
}
|
||||
</div>
|
||||
</div> }
|
||||
{ showTooFar && <div className={styles["riddle-overlay"]}>
|
||||
<OldPopUp onDismiss={() => setShowTooFar(false)}>
|
||||
<div style={{textAlign: "center", width: "100%"}}>
|
||||
<p className="lancelot-regular" style={{fontSize: "1.3rem", marginTop: "8px"}}>Ihr seid leider noch zu weit von der Station entfernt!</p>
|
||||
<OldButton
|
||||
red={true}
|
||||
long={true}
|
||||
style={{margin: "auto", marginTop: "16px"}}
|
||||
onAction={(e) => {
|
||||
setShowTooFar(false);
|
||||
e.stopPropagation();
|
||||
}}
|
||||
>SCHLIEßEN</OldButton>
|
||||
</div>
|
||||
</OldPopUp>
|
||||
</div> }
|
||||
{ !permissionsGranted ?
|
||||
<div className={styles["permissions-overlay"]}>
|
||||
<PermissionCheck className={styles["permission-check"]}></PermissionCheck>
|
||||
@@ -184,6 +241,15 @@ export default function Tour() {
|
||||
: null
|
||||
}
|
||||
</div>
|
||||
{ demoMode ? <ChargedButton style={{
|
||||
position: "absolute",
|
||||
bottom: "5%",
|
||||
left: "1%",
|
||||
zIndex: 4
|
||||
}} onAction={() => {
|
||||
localStorage.clear();
|
||||
setStep("0");
|
||||
}}>DEMO BEENDEN</ChargedButton> : null }
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -4,13 +4,16 @@ import { ChangeEvent, SyntheticEvent, useEffect, useRef, useState } from "react"
|
||||
import styles from "../../css/WelcomeScreen.module.css";
|
||||
import ChargedButton from "../ChargedButton";
|
||||
import { useLocalStorage } from "@/hooks/useLocalStorage";
|
||||
import { PREF } from "@/utils/const";
|
||||
import { API_PREFIX, HTTP_SCHEME, PREF } from "@/utils/const";
|
||||
import StyledContainer from "../StyledContainer";
|
||||
import clsx from "clsx";
|
||||
import OldButton from "../OldButton";
|
||||
import OldTextInput from "../OldTextInput";
|
||||
import { checkCode } from "@/utils/codeChecker";
|
||||
import { setRiddleData } from "@/utils/riddledata";
|
||||
import { fetchRiddleData, setRiddleData } from "@/utils/riddledata";
|
||||
import { setSessionData } from "@/utils/sessionHandler";
|
||||
import { setDemoMode } from "@/utils/demoMode";
|
||||
import { Riddle } from "@/types/riddle";
|
||||
|
||||
const CODE_LENGTH = 9;
|
||||
const COOLDOWN_MS = 3000;
|
||||
@@ -26,12 +29,12 @@ export default function WelcomeScreen() {
|
||||
const [, setStep ] = useLocalStorage(PREF.step, "0");
|
||||
|
||||
const [ , setPlayers ] = useLocalStorage(PREF.players, "");
|
||||
const [ , setPlayerCount ] = useLocalStorage(PREF.playerCount, "");
|
||||
const [ , setPlayerCount ] = useLocalStorage(PREF.player_count, "");
|
||||
const [ , setPoints ] = useLocalStorage(PREF.points, "");
|
||||
const [ , setCompletedRiddles ] = useLocalStorage(PREF.completed_riddles, "");
|
||||
const [ , setWorthyAnswers ] = useLocalStorage(PREF.worthyWords, "");
|
||||
const [ , setBoughtHints ] = useLocalStorage(PREF.boughtHints, "");
|
||||
const [ , setVoiceOver ] = useLocalStorage(PREF.voiceover, "");
|
||||
const [ , setWorthyAnswers ] = useLocalStorage(PREF.worthy_words, "");
|
||||
const [ , setBoughtHints ] = useLocalStorage(PREF.bought_hints, "");
|
||||
const [ , setVoiceOver ] = useLocalStorage(PREF.voice_over, "");
|
||||
|
||||
const checkCooldown = () => {
|
||||
if (cooldownRef.current === -1) return false;
|
||||
@@ -71,6 +74,20 @@ export default function WelcomeScreen() {
|
||||
setLastSubmitTs(cooldownRef.current);
|
||||
setCode(value);
|
||||
|
||||
if (value === "6MEGZDEI2") {
|
||||
const riddleData = await fetchRiddleData();
|
||||
|
||||
if (riddleData === null) {
|
||||
alert("Could not fetch RiddleData!");
|
||||
return;
|
||||
}
|
||||
|
||||
setRiddleData(riddleData["riddles"]);
|
||||
setDemoMode(true);
|
||||
setStep("1");
|
||||
return;
|
||||
}
|
||||
|
||||
const data = await checkCode(value);
|
||||
|
||||
if (data === null || data["riddles"] === undefined || data["riddles"] === null || data["riddles"].length < 1) {
|
||||
@@ -79,43 +96,15 @@ export default function WelcomeScreen() {
|
||||
}
|
||||
|
||||
console.log(data);
|
||||
setDemoMode(false);
|
||||
setRiddleData(data["riddles"]);
|
||||
/*if (data["session"] !== undefined && data["session"] !== null) {
|
||||
if (data["session"] !== undefined && data["session"] !== null) {
|
||||
const s = JSON.parse(data["session"]);
|
||||
|
||||
"playerCount": playerCountStr,
|
||||
"players": players,
|
||||
"worthy_answers": worthyAnswersStr,
|
||||
"completed_riddles": completedRiddlesStr,
|
||||
"points": pointsStr,
|
||||
"boughtHints": boughtHintsStr,
|
||||
"voiceOverStr": voiceOverStr*/
|
||||
/*if ("playerCount" in s) {
|
||||
setPlayerCount(s["playerCount"]);
|
||||
}
|
||||
if ("players" in s) {
|
||||
setPlayers(s["players"]);
|
||||
}
|
||||
if ("worthy_answers" in s) {
|
||||
setWorthyAnswers(s["worthy_answers"]);
|
||||
}
|
||||
if ("completed_riddles" in s) {
|
||||
setCompletedRiddles(s["completed_riddles"]);
|
||||
}
|
||||
if ("points" in s) {
|
||||
setPoints(s["points"]);
|
||||
}
|
||||
if ("boughtHints" in s) {
|
||||
setBoughtHints(s["boughtHints"]);
|
||||
}
|
||||
if ("voiceOverStr" in s) {
|
||||
setVoiceOver(s["voiceOverStr"]);
|
||||
}
|
||||
setSessionData(s);
|
||||
setStep("2");
|
||||
} else {
|
||||
setStep("1");
|
||||
}*/
|
||||
setStep("1");
|
||||
}
|
||||
};
|
||||
|
||||
const handleChange = (event: ChangeEvent<HTMLInputElement>): boolean => {
|
||||
|
||||
@@ -68,6 +68,10 @@
|
||||
/*text-shadow: 0px 1px 3px rgba(0, 0, 0, 0.7);*/
|
||||
}
|
||||
|
||||
.charged-button-label-whiteText {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.charged-button-label-clipped {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.permission-container {
|
||||
.container {
|
||||
text-align: center;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
}
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
.content-bar {
|
||||
width: 100%;
|
||||
/*height: 100%; Causes Problems! */
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
|
||||
@@ -6,14 +6,18 @@ export function addBoughtHint(id: number) {
|
||||
return;
|
||||
}
|
||||
hints.push(id);
|
||||
localStorage.setItem(PREF.boughtHints, JSON.stringify(hints));
|
||||
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 [];
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { API_PREFIX, PREF } from "./const";
|
||||
import { API_PREFIX, HTTP_SCHEME, PREF } from "./const";
|
||||
|
||||
export async function checkCode(code: string) {
|
||||
const res = await fetch(`${API_PREFIX}/codes?code=${code}`, {
|
||||
const res = await fetch(`${HTTP_SCHEME}://${API_PREFIX}/codes?code=${code}`, {
|
||||
"method": "GET",
|
||||
"cache": "no-cache"
|
||||
});
|
||||
|
||||
+10
-6
@@ -5,11 +5,15 @@ export enum PREF {
|
||||
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",
|
||||
};
|
||||
|
||||
export const API_PREFIX = "https://api.excaliburs-erben.de";
|
||||
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 ? "localhost: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,6 +1,9 @@
|
||||
import { Player } from "@/types/player";
|
||||
import { PREF } from "./const";
|
||||
|
||||
export const MIN_PLAYERS = 2;
|
||||
export const MAX_PLAYERS = 8;
|
||||
|
||||
export function setPlayers(players: Player[]) {
|
||||
localStorage.setItem(PREF.players, JSON.stringify(players));
|
||||
window.dispatchEvent(new Event('storage'));
|
||||
|
||||
+13
-1
@@ -1,5 +1,5 @@
|
||||
import { Player } from "@/types/player";
|
||||
import { PREF } from "./const";
|
||||
import { API_PREFIX, HTTP_SCHEME, PREF } from "./const";
|
||||
import { Riddle } from "@/types/riddle";
|
||||
|
||||
export function setRiddleData(riddle_data: Riddle[]) {
|
||||
@@ -18,3 +18,15 @@ export function getRiddleData(): Riddle[] {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,17 @@
|
||||
import { API_PREFIX } from "./const";
|
||||
import { API_PREFIX, HTTP_SCHEME, PREF } from "./const";
|
||||
|
||||
export async function heartbeat(data: any, code: string) {
|
||||
const res = await fetch(`${API_PREFIX}/sessions?code=${code}`,
|
||||
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",
|
||||
@@ -9,4 +19,23 @@ export async function heartbeat(data: any, code: string) {
|
||||
}
|
||||
);
|
||||
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);
|
||||
}
|
||||
|
||||
export async function finishSession(code: string): Promise<Response> {
|
||||
return await fetch(`${HTTP_SCHEME}://${API_PREFIX}/sessions/finish?code=${code}`,
|
||||
{
|
||||
"method": "PATCH",
|
||||
"cache": "no-cache"
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
// TODO: THISSSSS
|
||||
|
||||
import { API_PREFIX } from "./const";
|
||||
|
||||
export async function getSwordState() {
|
||||
const response = await fetch(API_PREFIX + "/sword", {
|
||||
"method": "GET",
|
||||
"cache": "no-cache"
|
||||
});
|
||||
console.log(response);
|
||||
if (response.ok) {
|
||||
console.log(`${await response.text()}`);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
Reference in new issue
Block a user