Files
core_ng/@sammo/server/src/GameEngineDefs.ts
T
Hide_D b449cf3a11 feat: Action 호출 타입 설계
- 호출 시점에선 강타입으로.
2024-03-09 17:45:14 +00:00

35 lines
1.1 KiB
TypeScript

import type { RPCLists } from "@sammo/server_util";
import type { ActionRequest, ActionResult } from "./GameEngine.js";
import type { MessagePort } from "node:worker_threads";
import type { CityID, GeneralID, NationID, TroopID } from "@sammo/game_logic/src/defs.js";
import type { ActionPackDef } from "@sammo/game_logic";
import type { ActionRequestList, QueueType } from "@sammo/game_logic/src/ActionRequest/index.js";
//Remove Third argument. Use Infer
export type MapRscActionRequest<T extends ActionPackDef> = {
[P in keyof T]: (invoker: Parameters<T[P]>[1] & QueueType, arg: Parameters<T[P]>[1]) => ReturnType<T[P]>
}
export type ActionPack = MapRscActionRequest<typeof ActionRequestList>;
export type GameEngineRPCDefs = {
stop: () => Promise<void>,
pushAPIAction: (action: ActionRequest) => Promise<ActionResult>,
pushServerAction: (action: ActionRequest) => Promise<ActionResult>,
};
type WorkerUpdate = {
type: 'update',
lastExecuted: string,
}
export type GameEngineMsg = WorkerUpdate;
type WorkerInit = {
type: 'init',
port: MessagePort,
guid: string,
}
export type GameEngineWorkerMsg = WorkerInit;