Files
CHOMPStation2/tgui/packages/tgui-panel/game/reducer.ts
CHOMPStation2 c96b18a2d3 [MIRROR] [TGUI 5.0 Prep] Removes context (#7455)
Co-authored-by: Selis <sirlionfur@hotmail.de>
Co-authored-by: Selis <selis@xynolabs.com>
2024-02-07 23:37:37 +01:00

48 lines
982 B
TypeScript

/**
* @file
* @copyright 2020 Aleksej Komarov
* @license MIT
*/
import { connectionLost } from './actions';
import { connectionRestored, dismissWarning } from './actions';
const initialState = {
// TODO: This is where round info should be.
roundId: null,
roundTime: null,
roundRestartedAt: null,
connectionLostAt: null,
dismissedConnectionWarning: false,
};
export const gameReducer = (state = initialState, action) => {
const { type, meta } = action;
if (type === 'roundrestart') {
return {
...state,
roundRestartedAt: meta.now,
};
}
if (type === connectionLost.type) {
return {
...state,
connectionLostAt: meta.now,
};
}
if (type === connectionRestored.type) {
return {
...state,
connectionLostAt: null,
dismissedConnectionWarning: false,
};
}
if (type === dismissWarning.type) {
return {
...state,
dismissedConnectionWarning: true,
};
}
return state;
};