primordial-soup/viewer/state.js

11 lines
372 B
JavaScript

export function viewerState(data) {
// BGS sends the raw saved state after a game ends or is cancelled. Only
// active games carry the moves and actor fields added by stripSecret.
const closed = !!data.finished || !Array.isArray(data.moves);
return {
...data,
closed,
actor: closed ? undefined : data.actor,
moves: closed ? [] : data.moves,
};
}