import {Character, CharacterId, CharacterSide, SPType} from "./Character"; export enum ClockMode { HEROES_FILL = "fill", HEROES_EMPTY = "empty", } export interface Clock { readonly id: string readonly text: string readonly segments: number readonly filled: number readonly mode: ClockMode } export interface SessionState { readonly usedSp: {readonly [key in SPType]?: number} } export interface ConflictState { readonly round: number readonly activeSide: CharacterSide readonly activeCharacterId: string|null readonly timers: readonly TimerState[] } export interface BaseTimerState { readonly type: string readonly id: string readonly text: string } export interface CountupTimerState extends BaseTimerState { readonly type: "up" readonly timeStartAt: number } export interface CountdownTimerState extends BaseTimerState { readonly type: "down" readonly timeEndAt: number readonly timeStartAt: number|null } export type TimerState = CountupTimerState|CountdownTimerState; export interface GameState { readonly session: SessionState readonly conflict?: ConflictState readonly clocks: readonly Clock[] readonly characters: readonly Character[] } export interface PastState { // The unix timestamp in ms when changing _away_ from this state. readonly timestamp: number readonly logMarkdown: string readonly state: GameState } export function getCharacterById(state: GameState, id: CharacterId): Character|undefined { return state.characters.find((character) => character.id === id) }