feat: Action 호출 타입 설계
- 호출 시점에선 강타입으로.
This commit is contained in:
@@ -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>,
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user