Story 4.1 completed
This commit is contained in:
Vendored
+33
-2
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user