Story 4.1 completed

This commit is contained in:
2026-05-23 23:00:07 +02:00
parent fd0a7868f3
commit de1b33c453
10 changed files with 574 additions and 25 deletions
+33 -2
View File
@@ -28,8 +28,39 @@ const SOCKET_STUB = {
};
/** A representative user object. */
const GM_USER = Object.freeze({ id: 'gm-user-1', name: 'GM', isGM: true });
const PLAYER_USER = Object.freeze({ id: 'player-user-1', name: 'Player', isGM: false });
const createUserWithFlags = (id, name, isGM, flags = {}) => {
const flagStore = { ...flags };
return Object.freeze({
id,
name,
isGM,
/**
* Get a flag value for this user.
* @param {string} scope - The flag scope/namespace
* @param {string} key - The flag key
* @returns {unknown|null} The flag value or null if not found
*/
getFlag: (scope, key) => {
const scopeKey = `${scope}.${key}`;
return flagStore[scopeKey] ?? null;
},
/**
* Set a flag value for this user.
* @param {string} scope - The flag scope/namespace
* @param {string} key - The flag key
* @param {unknown} value - The value to set
* @returns {Promise<unknown>} Resolves when set
*/
setFlag: (scope, key, value) => {
const scopeKey = `${scope}.${key}`;
flagStore[scopeKey] = value;
return Promise.resolve(value);
},
});
};
const GM_USER = createUserWithFlags('gm-user-1', 'GM', true);
const PLAYER_USER = createUserWithFlags('player-user-1', 'Player', false);
/** Minimal game.users map-like stub. */
const USERS_STUB = {