Tracker made in React for keeping track of HP and MP and so on.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

75 lines
2.0 KiB

import {Character, 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
}
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 StatusEffect {
readonly id: string
readonly name: string
readonly description: string
readonly iconUrl: string
}
export interface GameState {
readonly session: SessionState
readonly conflict?: ConflictState
readonly clocks: readonly Clock[]
readonly characters: readonly Character[]
readonly statuses: readonly StatusEffect[]
readonly timers: readonly TimerState[]
}
export function getClockById(state: GameState, id: string): Clock|undefined {
return state.clocks.find((clock) => clock.id === id)
}
export function getCharacterById(state: GameState, id: string): Character|undefined {
return state.characters.find((character) => character.id === id)
}
export function getStatusById(state: GameState, id: string): StatusEffect|undefined {
return state.statuses.find((status) => status.id === id)
}
export function getTimerById(state: GameState, id: string): TimerState|undefined {
return state.timers.find((timer) => timer.id === id)
}