Add UI improvements + refactor frontend to event-driven architecture
Some checks failed
CI / ci (push) Failing after 1m9s

Features: disabled place button during cooldown, beep on cooldown end,
hand/paint mode toggle with Space shortcut, soldier count pop animation.

Architecture: centralized DOM refs, AppState store replacing localStorage
polling, event bus decoupling socket from handlers, keyboard manager,
tool manager with Strategy pattern (paint-tool, hand-tool).
This commit is contained in:
2026-08-18 10:49:16 +02:00
parent 3fbae1bd95
commit dc6bff027a
13 changed files with 475 additions and 138 deletions

View File

@@ -0,0 +1,20 @@
export const createAppState = (initial) => {
const state = { ...initial };
const listeners = {};
return {
get: (key) => state[key],
set: (key, value) => {
const old = state[key];
state[key] = value;
(listeners[key] || []).forEach((fn) => fn(value, old));
},
subscribe: (key, fn) => {
if (!listeners[key]) listeners[key] = [];
listeners[key].push(fn);
return () => {
listeners[key] = listeners[key].filter((f) => f !== fn);
};
},
};
};