holy shit

This commit is contained in:
LionTion committed 2026-10-15 15:14:06 +02:00
1 parent a526a24e7c
commit b5e5cc502d
20 files changed
+286 -209

No files matched your search

+1 -1
View File
@@ -5,7 +5,7 @@ export function addBoughtHint(id: number) {
if (hints.includes(id)) {
return;
}
hints.push(id)
hints.push(id);
localStorage.setItem(PREF.boughtHints, JSON.stringify(hints));
window.dispatchEvent(new Event('storage'));
}
+12 -1
View File
@@ -1 +1,12 @@
// TODO: CodeChecker
import { API_PREFIX, PREF } from "./const";
export async function checkCode(code: string) {
const res = await fetch(`${API_PREFIX}/codes?code=${code}`, {
"method": "GET",
"cache": "no-cache"
});
if (!res.ok) {
return null;
}
return await res.json();
}
+19
View File
@@ -0,0 +1,19 @@
import { PREF } from "./const";
export function addCompletedRiddle(step: number) {
const riddles = getCompletedRiddles();
if (riddles.includes(step)) {
return;
}
riddles.push(step);
localStorage.setItem(PREF.completed_riddles, JSON.stringify(riddles));
window.dispatchEvent(new Event('storage'));
}
export function getCompletedRiddles(): number[] {
const riddleList = localStorage.getItem(PREF.completed_riddles);
if (riddleList === null || riddleList.length < 1) {
return [];
}
return JSON.parse(riddleList);
}
+2 -1
View File
@@ -2,6 +2,7 @@ export enum PREF {
code = "PREF_TOUR_CODE",
points = "PREF_POINTS",
players = "PREF_PLAYERS",
riddle_data = "PREF_RIDDLE_DATA",
completed_riddles = "PREF_COMPLETED_RIDDLES",
step = "PREF_APP_SCREEN_STEP",
playerCount = "PREF_PLAYER_COUNT",
@@ -11,4 +12,4 @@ export enum PREF {
boughtHints = "PREF_BOUGHT_HINTS"
};
export const API_PREFIX = "http://localhost:8080";
export const API_PREFIX = "https://api.excaliburs-erben.de";
+5 -4
View File
@@ -1,9 +1,6 @@
import { Player } from "@/types/player";
import { PREF } from "./const";
export const MAX_POINTS = 10000;
export const MIN_POINTS = 0;
export function setPlayers(players: Player[]) {
localStorage.setItem(PREF.players, JSON.stringify(players));
window.dispatchEvent(new Event('storage'));
@@ -14,5 +11,9 @@ export function getPlayers(): Player[] {
if (players === null) {
return [];
}
return JSON.parse(players);
try {
return JSON.parse(players);
} catch {
return [];
}
}
+20
View File
@@ -0,0 +1,20 @@
import { Player } from "@/types/player";
import { PREF } from "./const";
import { Riddle } from "@/types/riddle";
export function setRiddleData(riddle_data: Riddle[]) {
localStorage.setItem(PREF.riddle_data, JSON.stringify(riddle_data));
window.dispatchEvent(new Event('storage'));
}
export function getRiddleData(): Riddle[] {
const riddle_data = localStorage.getItem(PREF.riddle_data);
if (riddle_data === null) {
return [];
}
try {
return JSON.parse(riddle_data);
} catch {
return [];
}
}
+12
View File
@@ -0,0 +1,12 @@
import { API_PREFIX } from "./const";
export async function heartbeat(data: any, code: string) {
const res = await fetch(`${API_PREFIX}/sessions?code=${code}`,
{
"method": "POST",
"cache": "no-cache",
"body": JSON.stringify(data)
}
);
return res;
}