mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-06 05:23:56 -07:00
gameboard fixes
This commit is contained in:
parent
88489ea2eb
commit
f534cd79b7
86 changed files with 4249 additions and 2145 deletions
35
webclient/src/store/server/server.reducer.replays.ts
Normal file
35
webclient/src/store/server/server.reducer.replays.ts
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import { CaseReducer, PayloadAction } from '@reduxjs/toolkit';
|
||||
import { Data } from '@app/types';
|
||||
import { ServerState } from './server.interfaces';
|
||||
|
||||
export const replayReducers = {
|
||||
replayList: ((state, action) => {
|
||||
const replays: { [gameId: number]: Data.ServerInfo_ReplayMatch } = {};
|
||||
for (const match of action.payload.matchList) {
|
||||
replays[match.gameId] = match;
|
||||
}
|
||||
state.replays = replays;
|
||||
}) as CaseReducer<ServerState, PayloadAction<{ matchList: Data.ServerInfo_ReplayMatch[] }>>,
|
||||
|
||||
replayAdded: ((state, action) => {
|
||||
const { matchInfo } = action.payload;
|
||||
state.replays[matchInfo.gameId] = matchInfo;
|
||||
}) as CaseReducer<ServerState, PayloadAction<{ matchInfo: Data.ServerInfo_ReplayMatch }>>,
|
||||
|
||||
replayModifyMatch: ((state, action) => {
|
||||
const { gameId, doNotHide } = action.payload;
|
||||
const existing = state.replays[gameId];
|
||||
if (!existing) {
|
||||
return;
|
||||
}
|
||||
existing.doNotHide = doNotHide;
|
||||
}) as CaseReducer<ServerState, PayloadAction<{ gameId: number; doNotHide: boolean }>>,
|
||||
|
||||
replayDeleteMatch: ((state, action) => {
|
||||
delete state.replays[action.payload.gameId];
|
||||
}) as CaseReducer<ServerState, PayloadAction<{ gameId: number }>>,
|
||||
|
||||
replayDownloaded: ((state, action) => {
|
||||
state.downloadedReplay = action.payload;
|
||||
}) as CaseReducer<ServerState, PayloadAction<{ replayId: number; replayData: Uint8Array }>>,
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue