feat: v1 prototype — core game systems #30

Merged
naomi merged 84 commits from feat/prototype into main 2026-03-08 15:53:39 -07:00
Showing only changes of commit 4e32709e07 - Show all commits
+3 -2
View File
@@ -154,10 +154,10 @@ export const GameProvider = ({ children }: { children: React.ReactNode }): React
newlyUnlockedRef.current = [];
}
// Auto-save every 30 seconds
// Auto-save every 30 seconds (skip if a force sync is in-flight to avoid signature collisions)
if (Date.now() - lastSaveRef.current >= AUTO_SAVE_INTERVAL_MS) {
lastSaveRef.current = Date.now();
if (stateRef.current) {
if (stateRef.current && !isSyncingRef.current) {
void saveGame({
state: stateRef.current,
signature: signatureRef.current ?? undefined,
@@ -203,6 +203,7 @@ export const GameProvider = ({ children }: { children: React.ReactNode }): React
const forceSync = useCallback(async () => {
if (!stateRef.current || isSyncingRef.current) return;
isSyncingRef.current = true;
lastSaveRef.current = Date.now(); // push auto-save timer back so it doesn't fire concurrently
setIsSyncing(true);
try {
const response = await saveGame({