feat: Action 호출 타입 설계

- 호출 시점에선 강타입으로.
This commit is contained in:
2024-03-09 17:45:14 +00:00
parent fb68d9be22
commit b449cf3a11
5 changed files with 120 additions and 18 deletions
+11 -3
View File
@@ -1,12 +1,20 @@
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>,
stop: () => Promise<void>,
pushAPIAction: (action: ActionRequest) => Promise<ActionResult>,
pushServerAction: (action: ActionRequest) => Promise<ActionResult>,
};