Compare commits
6
Commits
17f2eacb4a
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7e8a7d7210 | ||
|
|
fea3401415 | ||
|
|
15927216b3 | ||
|
|
d301cf6d9a | ||
|
|
e6f2448e94 | ||
|
|
39c65927ac |
No files matched your search
@@ -28,6 +28,7 @@ export default function Main() {
|
|||||||
if (!hasAttachedListerner && step > 0) {
|
if (!hasAttachedListerner && step > 0) {
|
||||||
setHasAttachedListener(true);
|
setHasAttachedListener(true);
|
||||||
const doFullscreen = () => {
|
const doFullscreen = () => {
|
||||||
|
if (process.env.NODE_ENV === "development") return;
|
||||||
if (screenfull.isEnabled) {
|
if (screenfull.isEnabled) {
|
||||||
screenfull.request();
|
screenfull.request();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ export default function ChargedButton({
|
|||||||
className={styles["charged-button-frame"]}
|
className={styles["charged-button-frame"]}
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
style={{ backgroundImage: whiteText ? "url(/buttons/Button_weiß.png)" : "url(/buttons/Button_leer.webp)" }}
|
style={{ backgroundImage: whiteText ? "url(/buttons/Button_weiß.png)" : "url(/buttons/Button_leer.webp)" }}
|
||||||
|
onContextMenu={() => false}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<span
|
<span
|
||||||
@@ -118,6 +119,7 @@ export default function ChargedButton({
|
|||||||
clipPath: `inset(0 ${clipPercent}% 0 0)`,
|
clipPath: `inset(0 ${clipPercent}% 0 0)`,
|
||||||
WebkitClipPath: `inset(0 ${clipPercent}% 0 0)`,
|
WebkitClipPath: `inset(0 ${clipPercent}% 0 0)`,
|
||||||
}}
|
}}
|
||||||
|
onContextMenu={() => false}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<span className={clsx(styles["charged-button-label"], "lancelot-regular", whiteText && styles["charged-button-label-whiteText"])}>{children}</span>
|
<span className={clsx(styles["charged-button-label"], "lancelot-regular", whiteText && styles["charged-button-label-whiteText"])}>{children}</span>
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ export default function OldButton({children, long=true, red=true, disabled=false
|
|||||||
style={style}
|
style={style}
|
||||||
onClick={(disabled ? undefined : onAction)}
|
onClick={(disabled ? undefined : onAction)}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
|
onContextMenu={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
src={
|
src={
|
||||||
|
|||||||
@@ -29,15 +29,24 @@ export default function PermissionCheck({
|
|||||||
const requestGPSPermission = () => {
|
const requestGPSPermission = () => {
|
||||||
if (gpsStatus === "granted") return;
|
if (gpsStatus === "granted") return;
|
||||||
setIsGPSPermissionLoading(true);
|
setIsGPSPermissionLoading(true);
|
||||||
|
|
||||||
navigator.geolocation.getCurrentPosition((pos) => {
|
navigator.geolocation.getCurrentPosition((pos) => {
|
||||||
setIsGPSPermissionLoading(false);
|
setIsGPSPermissionLoading(false);
|
||||||
refresh();
|
refresh();
|
||||||
}, (e) => {
|
}, (e) => {
|
||||||
setIsGPSPermissionLoading(false);
|
setIsGPSPermissionLoading(false);
|
||||||
|
console.error("GPS Error Code:", e.code, "Message:", e.message);
|
||||||
|
|
||||||
|
if (e.code === 3) {
|
||||||
|
alert("GPS-Timeout: Das Erfassen des Standorts hat zu lange gedauert. Bitte im Freien erneut versuchen.");
|
||||||
|
} else if (e.code === 1) {
|
||||||
|
alert("GPS-Berechtigung verweigert. Bitte in den Safari-Einstellungen für diese Website erlauben.");
|
||||||
|
}
|
||||||
refresh();
|
refresh();
|
||||||
}, {
|
}, {
|
||||||
enableHighAccuracy: true,
|
enableHighAccuracy: true,
|
||||||
timeout: 3000
|
timeout: 15000,
|
||||||
|
maximumAge: 0
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,8 +73,29 @@ export default function Riddle_2({
|
|||||||
const [ isSwordOnline, setIsSwordOnline ] = useState(true);
|
const [ isSwordOnline, setIsSwordOnline ] = useState(true);
|
||||||
const [ wasSwordTakenOffline, setWasSwordTakenOffline ] = useState(false);
|
const [ wasSwordTakenOffline, setWasSwordTakenOffline ] = useState(false);
|
||||||
|
|
||||||
|
|
||||||
|
const [swordStatus, setSwordStatus] = useState<string | null>(null);
|
||||||
|
// lE == true && sE == true
|
||||||
|
const checkSwordStatusForIdealState = (state: string) => {
|
||||||
|
// M:2,snd:true,sS:true,sE:true,sP:false,lE:true,v:50,pD:150s
|
||||||
|
if (state == null) return false;
|
||||||
|
let sE = false;
|
||||||
|
let lE = false;
|
||||||
|
const tokens = state.split(",");
|
||||||
|
for (const token of tokens) {
|
||||||
|
if (token === "sE:true") {
|
||||||
|
sE = true;
|
||||||
|
} else if (token === "lE:true") {
|
||||||
|
lE = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sE && lE;
|
||||||
|
};
|
||||||
|
const [ isSwordIdealState, setIsSwordIdealState ] = useState(false);
|
||||||
|
|
||||||
const [ demoModeStr, ] = useLocalStorage(PREF.demo_mode, "");
|
const [ demoModeStr, ] = useLocalStorage(PREF.demo_mode, "");
|
||||||
const demoMode = useMemo(() => isDemoMode(demoModeStr), [demoModeStr]);
|
const demoMode = useMemo(() => isDemoMode(demoModeStr), [demoModeStr]);
|
||||||
|
//const demoMode = false;
|
||||||
|
|
||||||
const [ playerIndex, setPlayerIndex ] = useState(0);
|
const [ playerIndex, setPlayerIndex ] = useState(0);
|
||||||
const players = useMemo(() => getPlayers(), [playersStr]);
|
const players = useMemo(() => getPlayers(), [playersStr]);
|
||||||
@@ -96,9 +117,16 @@ export default function Riddle_2({
|
|||||||
const isNextIndexLastPlayer = players.length-2 <= playerIndex;
|
const isNextIndexLastPlayer = players.length-2 <= playerIndex;
|
||||||
|
|
||||||
const [status, setStatus] = useState<ConnectionStatus>("disconnected");
|
const [status, setStatus] = useState<ConnectionStatus>("disconnected");
|
||||||
const [swordStatus, setSwordStatus] = useState<string>('N/A');
|
const statusRef = useRef(false);
|
||||||
//const [throneStatus, setThroneStatus] = useState<string>('N/A');
|
|
||||||
const [ soundInput, setSoundInput ] = useState("Chosen");
|
useEffect(() => {
|
||||||
|
if (status === "connected") {
|
||||||
|
statusRef.current = true;
|
||||||
|
} else {
|
||||||
|
statusRef.current = false;
|
||||||
|
}
|
||||||
|
}, [status]);
|
||||||
|
|
||||||
const wsRef = useRef<WebSocket | null>(null);
|
const wsRef = useRef<WebSocket | null>(null);
|
||||||
|
|
||||||
const sendCommand = (topic: string, payload: string) => {
|
const sendCommand = (topic: string, payload: string) => {
|
||||||
@@ -135,6 +163,7 @@ export default function Riddle_2({
|
|||||||
|
|
||||||
if (data.topic === `${TOPIC_PREFIX}/stat`) {
|
if (data.topic === `${TOPIC_PREFIX}/stat`) {
|
||||||
setSwordStatus(data.payload);
|
setSwordStatus(data.payload);
|
||||||
|
setIsSwordIdealState(checkSwordStatusForIdealState(data.payload));
|
||||||
} else if (data.topic.includes('/event')) {
|
} else if (data.topic.includes('/event')) {
|
||||||
console.log(`Event received on ${data.topic}:`, data.payload);
|
console.log(`Event received on ${data.topic}:`, data.payload);
|
||||||
if (data.payload === "pull-denied") {
|
if (data.payload === "pull-denied") {
|
||||||
@@ -170,6 +199,10 @@ export default function Riddle_2({
|
|||||||
if (!isCancelled) {
|
if (!isCancelled) {
|
||||||
setStatus("disconnected");
|
setStatus("disconnected");
|
||||||
reconnectTimeout = setTimeout(connect, 3000);
|
reconnectTimeout = setTimeout(connect, 3000);
|
||||||
|
if (statusRef.current) {
|
||||||
|
setPage(0);
|
||||||
|
alert("Die Internet-Verbindung wurde verloren!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -231,6 +264,10 @@ export default function Riddle_2({
|
|||||||
setPage(3);
|
setPage(3);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!isSwordIdealState) {
|
||||||
|
alert("Eine wahre Prüfung kann erst gestarten werden, wenn das Schwert richtig im Felsen ist!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!sendCommand(`${TOPIC_PREFIX}/set`, 'stayLocked')) {
|
if (!sendCommand(`${TOPIC_PREFIX}/set`, 'stayLocked')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ export default function Intro() {
|
|||||||
const [ videoPaused, setVideoPaused ] = useState(false);
|
const [ videoPaused, setVideoPaused ] = useState(false);
|
||||||
const [ voiceOverState, setVoiceOverState ] = useLocalStorage(PREF.voice_over, "off");
|
const [ voiceOverState, setVoiceOverState ] = useLocalStorage(PREF.voice_over, "off");
|
||||||
const [ boughtHintsStr, setBoughtHints ] = useLocalStorage(PREF.bought_hints, "");
|
const [ boughtHintsStr, setBoughtHints ] = useLocalStorage(PREF.bought_hints, "");
|
||||||
|
const [ reachedRiddlesStr, setReachedRiddles ] = useLocalStorage(PREF.reached_riddles, "");
|
||||||
const introVideoRef = useRef<HTMLVideoElement | null>(null);
|
const introVideoRef = useRef<HTMLVideoElement | null>(null);
|
||||||
const [ granted, setGranted ] = useState(false);
|
const [ granted, setGranted ] = useState(false);
|
||||||
|
|
||||||
@@ -38,6 +39,7 @@ export default function Intro() {
|
|||||||
setBoughtHints("");
|
setBoughtHints("");
|
||||||
setPlayers("");
|
setPlayers("");
|
||||||
setWorthyWords("");
|
setWorthyWords("");
|
||||||
|
setReachedRiddles("");
|
||||||
setVoiceOverState("on");
|
setVoiceOverState("on");
|
||||||
setStep("2");
|
setStep("2");
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import { fetchRiddleData, getRiddleData, setRiddleData } from "@/utils/riddledat
|
|||||||
import { heartbeat } from "@/utils/sessionHandler";
|
import { heartbeat } from "@/utils/sessionHandler";
|
||||||
import { getCompletedRiddles } from "@/utils/completedRiddles";
|
import { getCompletedRiddles } from "@/utils/completedRiddles";
|
||||||
import { isDemoMode } from "@/utils/demoMode";
|
import { isDemoMode } from "@/utils/demoMode";
|
||||||
|
import { addReachedRiddle, getReachedRiddles } from "@/utils/reachedRiddles";
|
||||||
|
|
||||||
export default function Tour() {
|
export default function Tour() {
|
||||||
const [ demoModeStr, ] = useLocalStorage(PREF.demo_mode, "");
|
const [ demoModeStr, ] = useLocalStorage(PREF.demo_mode, "");
|
||||||
@@ -91,6 +92,7 @@ export default function Tour() {
|
|||||||
const [ boughtHintsStr, ] = useLocalStorage(PREF.bought_hints, "");
|
const [ boughtHintsStr, ] = useLocalStorage(PREF.bought_hints, "");
|
||||||
const [ playerCountStr, ] = useLocalStorage(PREF.player_count, "");
|
const [ playerCountStr, ] = useLocalStorage(PREF.player_count, "");
|
||||||
const [ voiceOverStr, ] = useLocalStorage(PREF.voice_over, "");
|
const [ voiceOverStr, ] = useLocalStorage(PREF.voice_over, "");
|
||||||
|
const [ reachedRiddlesStr, ] = useLocalStorage(PREF.reached_riddles, "");
|
||||||
|
|
||||||
const permissionsGranted = gpsStatus === "granted" && cameraStatus === "granted";
|
const permissionsGranted = gpsStatus === "granted" && cameraStatus === "granted";
|
||||||
|
|
||||||
@@ -121,7 +123,8 @@ export default function Tour() {
|
|||||||
"completed_riddles": completedRiddlesStr,
|
"completed_riddles": completedRiddlesStr,
|
||||||
"points": pointsStr,
|
"points": pointsStr,
|
||||||
"bought_hints": boughtHintsStr,
|
"bought_hints": boughtHintsStr,
|
||||||
"voice_over": voiceOverStr
|
"voice_over": voiceOverStr,
|
||||||
|
"reached_riddles": reachedRiddlesStr,
|
||||||
}, code);
|
}, code);
|
||||||
// TODO: Check if Code is valid.
|
// TODO: Check if Code is valid.
|
||||||
};
|
};
|
||||||
@@ -190,9 +193,14 @@ export default function Tour() {
|
|||||||
|
|
||||||
const distanceMeters = userLngLat.distanceTo(markerLngLat);
|
const distanceMeters = userLngLat.distanceTo(markerLngLat);
|
||||||
const isNearby = distanceMeters <= r.requiredDistance;
|
const isNearby = distanceMeters <= r.requiredDistance;
|
||||||
|
const reachedRiddles = getReachedRiddles();
|
||||||
|
const reachedAlready = reachedRiddles.includes(r.step);
|
||||||
|
|
||||||
if (isNearby || demoMode) {
|
if (isNearby || demoMode || reachedAlready) {
|
||||||
setClickedMarker(marker.id);
|
setClickedMarker(marker.id);
|
||||||
|
if (!reachedAlready) {
|
||||||
|
addReachedRiddle(r.step);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
setShowTooFar(true);
|
setShowTooFar(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,12 +8,17 @@
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
transition: 150ms ease-out filter;
|
transition: 150ms ease-out filter;
|
||||||
-webkit-filter: var(--shadow);
|
-webkit-filter: var(--shadow);
|
||||||
|
cursor: pointer;
|
||||||
filter: var(--shadow);
|
filter: var(--shadow);
|
||||||
}
|
}
|
||||||
|
|
||||||
.image {
|
.image {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 220px;
|
width: 220px;
|
||||||
|
-webkit-user-select: none; /* Safari */
|
||||||
|
-moz-user-select: none; /* Firefox */
|
||||||
|
-ms-user-select: none; /* IE10+/Edge */
|
||||||
|
user-select: none; /* Standard */
|
||||||
}
|
}
|
||||||
|
|
||||||
.label {
|
.label {
|
||||||
|
|||||||
+2
-1
@@ -10,10 +10,11 @@ export enum PREF {
|
|||||||
voice_over = "PREF_VOICEOVER_STATE",
|
voice_over = "PREF_VOICEOVER_STATE",
|
||||||
bought_hints = "PREF_BOUGHT_HINTS",
|
bought_hints = "PREF_BOUGHT_HINTS",
|
||||||
demo_mode = "PREF_DEMO_MODE",
|
demo_mode = "PREF_DEMO_MODE",
|
||||||
|
reached_riddles = "PREF_REACHED_RIDDLES",
|
||||||
};
|
};
|
||||||
|
|
||||||
const isDev = process.env.NODE_ENV === "development";
|
const isDev = process.env.NODE_ENV === "development";
|
||||||
|
|
||||||
export const HTTP_SCHEME = isDev ? "http" : "https";
|
export const HTTP_SCHEME = isDev ? "http" : "https";
|
||||||
export const WS_SCHEME = isDev ? "ws" : "wss";
|
export const WS_SCHEME = isDev ? "ws" : "wss";
|
||||||
export const API_PREFIX = isDev ? "192.168.0.110:8080" : "api.excaliburs-erben.de";
|
export const API_PREFIX = isDev ? "localhost:8080" : "api.excaliburs-erben.de";
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import { PREF } from "./const";
|
||||||
|
|
||||||
|
export function addReachedRiddle(step: number) {
|
||||||
|
const riddles = getReachedRiddles();
|
||||||
|
if (riddles.includes(step)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
riddles.push(step);
|
||||||
|
localStorage.setItem(PREF.reached_riddles, JSON.stringify(riddles));
|
||||||
|
window.dispatchEvent(new Event('storage'));
|
||||||
|
return riddles;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getReachedRiddles(): number[] {
|
||||||
|
const riddleList = localStorage.getItem(PREF.reached_riddles);
|
||||||
|
if (riddleList === null || riddleList.length < 1) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return JSON.parse(riddleList);
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ interface SessionData {
|
|||||||
"points": string;
|
"points": string;
|
||||||
"bought_hints": string;
|
"bought_hints": string;
|
||||||
"voice_over": string;
|
"voice_over": string;
|
||||||
|
"reached_riddles": string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function heartbeat(data: SessionData, code: string) {
|
export async function heartbeat(data: SessionData, code: string) {
|
||||||
@@ -29,6 +30,7 @@ export function setSessionData(data: SessionData) {
|
|||||||
localStorage.setItem(PREF.points, data.points);
|
localStorage.setItem(PREF.points, data.points);
|
||||||
localStorage.setItem(PREF.bought_hints, data.bought_hints);
|
localStorage.setItem(PREF.bought_hints, data.bought_hints);
|
||||||
localStorage.setItem(PREF.voice_over, data.voice_over);
|
localStorage.setItem(PREF.voice_over, data.voice_over);
|
||||||
|
localStorage.setItem(PREF.reached_riddles, data.reached_riddles);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function finishSession(code: string): Promise<Response> {
|
export async function finishSession(code: string): Promise<Response> {
|
||||||
|
|||||||
Reference in new issue
Block a user