R7, R2, Heartbeat, Sessions, Code, cleanup, Outro
This commit is contained in:
1 parent
b5e5cc502d
commit
5b9fe3ea21
25 files changed
+345
-115
No files matched your search
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 (
|
||||
|
||||
@@ -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")}
|
||||
|
||||
@@ -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 {
|
||||
@@ -40,8 +41,14 @@ export default function RiddleScreen({ riddle, onDismiss }: RiddleScreenProps) {
|
||||
const [ voiceOverState, setVoiceOverState ] = useLocalStorage(PREF.voiceover, "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' },
|
||||
];
|
||||
|
||||
|
||||
@@ -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,44 @@ 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";
|
||||
|
||||
export type ConnectionStatus = "disconnected" | "connected";
|
||||
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 +59,12 @@ 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 [ playerIndex, setPlayerIndex ] = useState(0);
|
||||
const players = useMemo(() => getPlayers(), [playersStr]);
|
||||
@@ -68,52 +97,90 @@ export default function Riddle_2({
|
||||
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}`);
|
||||
let isCancelled = false;
|
||||
let reconnectTimeout: NodeJS.Timeout;
|
||||
|
||||
wsRef.current.onopen = () => {
|
||||
setStatus("connected");
|
||||
};
|
||||
const connect = () => {
|
||||
if (isCancelled) return;
|
||||
setStatus("connecting");
|
||||
|
||||
wsRef.current.onmessage = (event) => {
|
||||
const data: MQTTMessage = JSON.parse(event.data);
|
||||
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 === '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);
|
||||
}
|
||||
} 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('outdoor/king-arthur/sword/set', 'abortTry');
|
||||
waitUntilTrue(() => {
|
||||
return awaitTryAbort
|
||||
});
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
onRegisterCloseInterceptor(handleIntercept);
|
||||
}, [onRegisterCloseInterceptor]);
|
||||
|
||||
const pages = [
|
||||
(
|
||||
<div key={0}>
|
||||
@@ -135,7 +202,7 @@ export default function Riddle_2({
|
||||
}
|
||||
setCanGoNext(false);
|
||||
setPage(1);
|
||||
}}>WEITER</OldButton>
|
||||
}}>PRÜFUNG STARTEN</OldButton>
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
@@ -213,7 +280,7 @@ export default function Riddle_2({
|
||||
setCanGoNext(false);
|
||||
setPlayerIndex(playerIndex+1);
|
||||
}
|
||||
}} disabled={!canGoNext}>WEITER</OldButton>
|
||||
}} disabled={!canGoNext}>{(playerIndex >= players.length-1) ? "PRÜFUNG BEENDEN" : "NÄCHSTER PRÜFLING"}</OldButton>
|
||||
{playerIndex < 1 ? <OldButton red={true} onAction={() => setPage(0)} className={styles["backButton"]}>ZURÜCK</OldButton> : null}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -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>
|
||||
)
|
||||
|
||||
@@ -10,9 +10,8 @@ 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";
|
||||
|
||||
export default function Intro() {
|
||||
const [ stepStr, setStep ] = useLocalStorage(PREF.step, "0");
|
||||
@@ -24,6 +23,8 @@ export default function Intro() {
|
||||
const [ enterPlayerCount, setEnterPlayerCount ] = useState(false);
|
||||
const [ videoEnded, setVideoEnded ] = useState(false);
|
||||
const [ videoPaused, setVideoPaused ] = useState(false);
|
||||
const [ voiceOverState, setVoiceOverState ] = useLocalStorage(PREF.voiceover, "off");
|
||||
const [ boughtHintsStr, setBoughtHints ] = useLocalStorage(PREF.boughtHints, "");
|
||||
const introVideoRef = useRef<HTMLVideoElement | null>(null);
|
||||
const [ granted, setGranted ] = useState(false);
|
||||
|
||||
@@ -72,7 +73,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 +112,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"]}>
|
||||
@@ -154,8 +156,10 @@ export default function Intro() {
|
||||
<ChargedButton holdDuration={500} onAction={() => {
|
||||
setPoints("0");
|
||||
setCompletedRiddles("");
|
||||
setBoughtHints("");
|
||||
setPlayers("");
|
||||
setWorthyWords("");
|
||||
setVoiceOverState("on");
|
||||
setStep("2");
|
||||
}}>Wir sind bereit!</ChargedButton>
|
||||
</div> : null }
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
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, 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";
|
||||
|
||||
export default function Outro() {
|
||||
const [ resultPage, setResultPage ] = useState(0);
|
||||
const [ stepStr, setStep ] = useLocalStorage(PREF.step, "0");
|
||||
const [ , setPoints ] = useLocalStorage(PREF.points, "0");
|
||||
const [ , setPlayers ] = useLocalStorage(PREF.players, "");
|
||||
const [ , setWorthyWords ] = useLocalStorage(PREF.worthyWords, "");
|
||||
const [ rewatchScreen, setRewatchScreen ] = useState(false);
|
||||
const [ videoEnded, setVideoEnded ] = useState(false);
|
||||
const [ videoPaused, setVideoPaused ] = useState(false);
|
||||
const [ voiceOverState, setVoiceOverState ] = useLocalStorage(PREF.voiceover, "off");
|
||||
const [ boughtHintsStr, setBoughtHints ] = useLocalStorage(PREF.boughtHints, "");
|
||||
const outroVideoRef = useRef<HTMLVideoElement | null>(null);
|
||||
|
||||
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>
|
||||
{ !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>
|
||||
)
|
||||
];
|
||||
|
||||
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"]}>
|
||||
{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";
|
||||
@@ -76,26 +76,26 @@ export default function Tour() {
|
||||
|
||||
const [ code, ] = useLocalStorage(PREF.code, "");
|
||||
|
||||
/*useEffect(() => {
|
||||
useEffect(() => {
|
||||
if (code.length === 0) {
|
||||
return;
|
||||
}
|
||||
const intervalId = setInterval(() => {
|
||||
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);
|
||||
}, 50000);
|
||||
|
||||
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;
|
||||
|
||||
@@ -152,7 +152,7 @@ export default function Tour() {
|
||||
if (isNearby) {
|
||||
setClickedMarker(marker.id);
|
||||
} else {
|
||||
alert(`Ihr seid noch zu weit entfernt!`);
|
||||
alert(`Ihr seid noch zu weit entfernt!`); // TODO: Change to OldPopUp
|
||||
}
|
||||
}}></MapView>
|
||||
</div>
|
||||
|
||||
@@ -11,6 +11,7 @@ import OldButton from "../OldButton";
|
||||
import OldTextInput from "../OldTextInput";
|
||||
import { checkCode } from "@/utils/codeChecker";
|
||||
import { setRiddleData } from "@/utils/riddledata";
|
||||
import { setSessionData } from "@/utils/sessionHandler";
|
||||
|
||||
const CODE_LENGTH = 9;
|
||||
const COOLDOWN_MS = 3000;
|
||||
@@ -80,42 +81,13 @@ export default function WelcomeScreen() {
|
||||
|
||||
console.log(data);
|
||||
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,60 @@
|
||||
.container {
|
||||
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;
|
||||
}
|
||||
@@ -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"
|
||||
});
|
||||
|
||||
+5
-2
@@ -7,9 +7,12 @@ export enum PREF {
|
||||
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"
|
||||
};
|
||||
|
||||
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";
|
||||
@@ -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'));
|
||||
|
||||
@@ -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",
|
||||
@@ -10,3 +20,13 @@ export async function heartbeat(data: any, code: string) {
|
||||
);
|
||||
return res;
|
||||
}
|
||||
|
||||
export function setSessionData(data: SessionData) {
|
||||
localStorage.setItem(PREF.playerCount, data.player_count);
|
||||
localStorage.setItem(PREF.players, data.players);
|
||||
localStorage.setItem(PREF.worthyWords, data.worthy_answers);
|
||||
localStorage.setItem(PREF.completed_riddles, data.completed_riddles);
|
||||
localStorage.setItem(PREF.points, data.points);
|
||||
localStorage.setItem(PREF.boughtHints, data.bought_hints);
|
||||
localStorage.setItem(PREF.voiceover, data.voice_over);
|
||||
}
|
||||
@@ -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