35 lines
1.1 KiB
TypeScript
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; |