DEMO stuff and symbol renames
This commit is contained in:
1 parent
51e5a98a92
commit
45acdd3400
15 files changed
+193
-69
No files matched your search
@@ -14,6 +14,7 @@ import RiddleHintPage from "../RiddleHintPage";
|
||||
import { Player } from "@/types/player";
|
||||
import { addCompletedRiddle } from "@/utils/completedRiddles";
|
||||
import ChargedButton from "../ChargedButton";
|
||||
import { isDemoMode } from "@/utils/demoMode";
|
||||
|
||||
export const TOPIC_PREFIX = (process.env.NODE_ENV === "development") ? "staging/outdoor/king-arthur/sword" : "outdoor/king-arthur/sword";
|
||||
|
||||
@@ -69,6 +70,9 @@ export default function Riddle_2({
|
||||
const [ playersStr, ] = useLocalStorage(PREF.players, "");
|
||||
const [ tourCode, ] = useLocalStorage(PREF.code, "");
|
||||
|
||||
const [ demoModeStr, ] = useLocalStorage(PREF.demo_mode, "");
|
||||
const demoMode = useMemo(() => isDemoMode(demoModeStr), [demoModeStr]);
|
||||
|
||||
const [ playerIndex, setPlayerIndex ] = useState(0);
|
||||
const players = useMemo(() => getPlayers(), [playersStr]);
|
||||
const playerOrder = useMemo(() => {
|
||||
@@ -96,6 +100,7 @@ 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;
|
||||
@@ -105,6 +110,8 @@ export default function Riddle_2({
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (demoMode) return;
|
||||
|
||||
let isCancelled = false;
|
||||
let reconnectTimeout: NodeJS.Timeout;
|
||||
|
||||
@@ -281,8 +288,12 @@ export default function Riddle_2({
|
||||
setCanGoNext(false);
|
||||
setPlayerIndex(playerIndex+1);
|
||||
}
|
||||
}} disabled={!canGoNext}>{(playerIndex >= players.length-1) ? "PRÜFUNG BEENDEN" : "NÄCHSTER PRÜFLING"}</ChargedButton>
|
||||
}} 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(() => {
|
||||
@@ -308,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>
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user