From c9afc111cc0a283caa720bd3e32b19b09f1363dd Mon Sep 17 00:00:00 2001 From: Hide_D Date: Sat, 9 Mar 2024 05:21:50 +0000 Subject: [PATCH] =?UTF-8?q?refac:=20=EC=9E=AC=EC=A0=95=EB=B9=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- @sammo/game_logic/src/Entity/ReservedTurn.ts | 4 ++++ @sammo/game_logic/src/Entity/index.ts | 3 ++- @sammo/game_logic/src/LazyEntityUpdater.ts | 6 +++--- .../game_logic/src/{ => LogicFunc}/generalStats.ts | 0 @sammo/game_logic/src/ResourceController.ts | 14 ++++++++++---- @sammo/game_logic/src/index.ts | 2 +- 6 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 @sammo/game_logic/src/Entity/ReservedTurn.ts rename @sammo/game_logic/src/{ => LogicFunc}/generalStats.ts (100%) diff --git a/@sammo/game_logic/src/Entity/ReservedTurn.ts b/@sammo/game_logic/src/Entity/ReservedTurn.ts new file mode 100644 index 0000000..4c0bcfb --- /dev/null +++ b/@sammo/game_logic/src/Entity/ReservedTurn.ts @@ -0,0 +1,4 @@ +export interface IReservedTurn { + action: string; + arg: Record; +} \ No newline at end of file diff --git a/@sammo/game_logic/src/Entity/index.ts b/@sammo/game_logic/src/Entity/index.ts index a6d8641..b4ef2ce 100644 --- a/@sammo/game_logic/src/Entity/index.ts +++ b/@sammo/game_logic/src/Entity/index.ts @@ -18,4 +18,5 @@ export type ValidEntityList = { }; export type ValidEntity = ValuesOf; -export type ValidEntityType = Entity extends ValidEntityList[infer T extends keyof ValidEntityList] ? T : never; +export type ValidEntityType = keyof ValidEntityList; +export type EntityType = Entity extends ValidEntityList[infer T extends keyof ValidEntityList] ? T : never; diff --git a/@sammo/game_logic/src/LazyEntityUpdater.ts b/@sammo/game_logic/src/LazyEntityUpdater.ts index aec7567..44c20db 100644 --- a/@sammo/game_logic/src/LazyEntityUpdater.ts +++ b/@sammo/game_logic/src/LazyEntityUpdater.ts @@ -1,9 +1,9 @@ -import type { ValidEntity, ValidEntityType } from "./Entity/index.js"; +import type { ValidEntity, EntityType } from "./Entity/index.js"; import type { IResourceController } from "./ResourceController.js"; export abstract class LazyEntityUpdater{ protected abstract readonly _indirectNames: ReadonlyArray; - protected abstract readonly _entityType: ValidEntityType; + protected abstract readonly _entityType: EntityType; protected abstract readonly _raw: Entity; @@ -13,7 +13,7 @@ export abstract class LazyEntityUpdater{ return this._raw; } - public get entityType(): ValidEntityType { + public get entityType(): EntityType { return this._entityType; } diff --git a/@sammo/game_logic/src/generalStats.ts b/@sammo/game_logic/src/LogicFunc/generalStats.ts similarity index 100% rename from @sammo/game_logic/src/generalStats.ts rename to @sammo/game_logic/src/LogicFunc/generalStats.ts diff --git a/@sammo/game_logic/src/ResourceController.ts b/@sammo/game_logic/src/ResourceController.ts index 31009e0..2f5b5a2 100644 --- a/@sammo/game_logic/src/ResourceController.ts +++ b/@sammo/game_logic/src/ResourceController.ts @@ -9,8 +9,8 @@ import type { ITroopEntity } from "./Entity/TroopEntity.js"; import type { LazyEntityUpdater } from "./LazyEntityUpdater.js"; import type { ICityEntity } from "./Entity/CityEntity.js"; import type { INationEntity } from "./Entity/NationEntity.js"; -import type { ValuesOf } from "@sammo/util"; -import type { ValidEntityType } from "./Entity/index.js"; +import type { EntityType, ValidEntityType } from "./Entity/index.js"; +import type { IReservedTurn } from "./Entity/ReservedTurn.js"; export interface IResourceController{ addCity(city: City): boolean; @@ -35,8 +35,6 @@ export interface IResourceController{ getTroop(id: TroopID, nation: NationID): Troop | undefined; - _getAllChanges(): Map<`${ValidEntityType}_${number}`, ['new'|'update'|'delete', LazyEntityUpdater]>; - setDirty(entity: LazyEntityUpdater): void; reserveDelete(entity: LazyEntityUpdater): void; @@ -48,6 +46,14 @@ export interface IResourceController{ createNation(raw: INationEntity): Nation; createTroop(raw: ITroopEntity): Troop; + _getAllChanges(): Record]>>; + + //---- DB 접근 --- + + //예턴은 호출마다 DB에서 조회 + getReservedTurn(general: General): Promise; + getNationReservedTurn(general: General): Promise; + resetAndFill(): Promise; saveAll(): Promise; } diff --git a/@sammo/game_logic/src/index.ts b/@sammo/game_logic/src/index.ts index 0f183f4..1ba0ddd 100644 --- a/@sammo/game_logic/src/index.ts +++ b/@sammo/game_logic/src/index.ts @@ -1,4 +1,4 @@ -export * from "./generalStats.js"; +export * from "./LogicFunc/generalStats.js"; export * as defs from "./defs.js"; // NOTE: game_logic은 client, server 모두에서 사용되는 라이브러리이다.