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

+1
View File
@@ -6,4 +6,5 @@ export enum PREF {
step = "PREF_APP_SCREEN_STEP",
playerCount = "PREF_PLAYER_COUNT",
worthyWords = "PREF_WORTHY_ANSWERS",
readerState = "PREF_LAST_READER_STATE"
};
+1 -1
View File
@@ -18,4 +18,4 @@ export function formatPlayerData(arr: Array<Player>): string {
s += JSON.stringify(player);
}
return s;
}
}
+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());
}