add statuses game

This commit is contained in:
2026-08-04 02:28:16 +07:00
parent 2241c33902
commit 33cde1d28b
12 changed files with 537 additions and 143 deletions
@@ -301,6 +301,8 @@ export type Game = {
status: string | undefined;
scenario: Scenario | undefined;
teams: Team[] | undefined;
startedAt?: wellKnownTimestamp;
endedAt?: wellKnownTimestamp;
};
export type Team = {
@@ -333,6 +335,46 @@ export type UpdateGameRsp = {
error: string | undefined;
};
export type StartGameReq = {
id: number | undefined;
};
export type StartGameRsp = {
error: string | undefined;
};
export type PauseGameReq = {
id: number | undefined;
};
export type PauseGameRsp = {
error: string | undefined;
};
export type PlayGameReq = {
id: number | undefined;
};
export type PlayGameRsp = {
error: string | undefined;
};
export type FinishGameReq = {
id: number | undefined;
};
export type FinishGameRsp = {
error: string | undefined;
};
export type ResetGameReq = {
id: number | undefined;
};
export type ResetGameRsp = {
error: string | undefined;
};
export type DeleteGameReq = {
id: number | undefined;
};
@@ -438,6 +480,11 @@ export interface EveningDetectiveServer {
GetGames(request: GetGamesReq): Promise<GetGamesRsp>;
GetGame(request: GetGameReq): Promise<GetGameRsp>;
UpdateGame(request: UpdateGameReq): Promise<UpdateGameRsp>;
StartGame(request: StartGameReq): Promise<StartGameRsp>;
PauseGame(request: PauseGameReq): Promise<PauseGameRsp>;
PlayGame(request: PlayGameReq): Promise<PlayGameRsp>;
FinishGame(request: FinishGameReq): Promise<FinishGameRsp>;
ResetGame(request: ResetGameReq): Promise<ResetGameRsp>;
DeleteGame(request: DeleteGameReq): Promise<DeleteGameRsp>;
AddTeam(request: AddTeamReq): Promise<AddTeamRsp>;
UpdateTeam(request: UpdateTeamReq): Promise<UpdateTeamRsp>;
@@ -1024,6 +1071,106 @@ export function createEveningDetectiveServerClient(
method: "UpdateGame",
}) as Promise<UpdateGameRsp>;
},
StartGame(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
if (!request.id) {
throw new Error("missing required field request.id");
}
const path = `api/games/${request.id}/start`; // eslint-disable-line quotes
const body = JSON.stringify(request);
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "PUT",
body,
}, {
service: "EveningDetectiveServer",
method: "StartGame",
}) as Promise<StartGameRsp>;
},
PauseGame(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
if (!request.id) {
throw new Error("missing required field request.id");
}
const path = `api/games/${request.id}/pause`; // eslint-disable-line quotes
const body = JSON.stringify(request);
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "PUT",
body,
}, {
service: "EveningDetectiveServer",
method: "PauseGame",
}) as Promise<PauseGameRsp>;
},
PlayGame(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
if (!request.id) {
throw new Error("missing required field request.id");
}
const path = `api/games/${request.id}/play`; // eslint-disable-line quotes
const body = JSON.stringify(request);
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "PUT",
body,
}, {
service: "EveningDetectiveServer",
method: "PlayGame",
}) as Promise<PlayGameRsp>;
},
FinishGame(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
if (!request.id) {
throw new Error("missing required field request.id");
}
const path = `api/games/${request.id}/finish`; // eslint-disable-line quotes
const body = JSON.stringify(request);
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "PUT",
body,
}, {
service: "EveningDetectiveServer",
method: "FinishGame",
}) as Promise<FinishGameRsp>;
},
ResetGame(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
if (!request.id) {
throw new Error("missing required field request.id");
}
const path = `api/games/${request.id}/reset`; // eslint-disable-line quotes
const body = JSON.stringify(request);
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "PUT",
body,
}, {
service: "EveningDetectiveServer",
method: "ResetGame",
}) as Promise<ResetGameRsp>;
},
DeleteGame(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
if (!request.id) {
throw new Error("missing required field request.id");