Loads of Riddle Stuff

This commit is contained in:
LionTion committed 2026-10-04 02:07:08 +02:00
1 parent 69b730ad92
commit eaa5cc0065
18 files changed
+393 -87

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
import { PREF } from "./const";
export const MAX_POINTS = 10000;
export const MIN_POINTS = 0;
function setPoints(points: string) {
localStorage.setItem(PREF.points, points);
window.dispatchEvent(new Event('storage'));
}
function getPoints(): number {
const points = localStorage.getItem(PREF.points);
if (points === null) {
return 0;
}
return Number.parseInt(points);
}
function clampPoints(points: number) {
return Math.max(MIN_POINTS, Math.min(MAX_POINTS, points));
}
export function addPoints(points: number) {
let p = getPoints();
p += points;
p = clampPoints(p);
setPoints(p.toString());
}
export function takePoints(points: number) {
let p = getPoints();
p -= points;
p = clampPoints(p);
setPoints(p.toString());
}