refac: 재정비
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
export interface IReservedTurn {
|
||||
action: string;
|
||||
arg: Record<string, unknown>;
|
||||
}
|
||||
@@ -18,4 +18,5 @@ export type ValidEntityList = {
|
||||
};
|
||||
|
||||
export type ValidEntity = ValuesOf<ValidEntityList>;
|
||||
export type ValidEntityType<Entity> = Entity extends ValidEntityList[infer T extends keyof ValidEntityList] ? T : never;
|
||||
export type ValidEntityType = keyof ValidEntityList;
|
||||
export type EntityType<Entity> = Entity extends ValidEntityList[infer T extends keyof ValidEntityList] ? T : never;
|
||||
|
||||
@@ -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<Entity extends ValidEntity>{
|
||||
protected abstract readonly _indirectNames: ReadonlyArray<keyof Entity>;
|
||||
protected abstract readonly _entityType: ValidEntityType<Entity>;
|
||||
protected abstract readonly _entityType: EntityType<Entity>;
|
||||
|
||||
protected abstract readonly _raw: Entity;
|
||||
|
||||
@@ -13,7 +13,7 @@ export abstract class LazyEntityUpdater<Entity extends ValidEntity>{
|
||||
return this._raw;
|
||||
}
|
||||
|
||||
public get entityType(): ValidEntityType<Entity> {
|
||||
public get entityType(): EntityType<Entity> {
|
||||
return this._entityType;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<any>}_${number}`, ['new'|'update'|'delete', LazyEntityUpdater<any>]>;
|
||||
|
||||
setDirty(entity: LazyEntityUpdater<any>): void;
|
||||
reserveDelete(entity: LazyEntityUpdater<any>): void;
|
||||
|
||||
@@ -48,6 +46,14 @@ export interface IResourceController{
|
||||
createNation(raw: INationEntity): Nation;
|
||||
createTroop(raw: ITroopEntity): Troop;
|
||||
|
||||
_getAllChanges(): Record<ValidEntityType, Map<number, ['new'|'update'|'delete', LazyEntityUpdater<any>]>>;
|
||||
|
||||
//---- DB 접근 ---
|
||||
|
||||
//예턴은 호출마다 DB에서 조회
|
||||
getReservedTurn(general: General): Promise<IReservedTurn>;
|
||||
getNationReservedTurn(general: General): Promise<IReservedTurn | undefined>;
|
||||
|
||||
resetAndFill(): Promise<void>;
|
||||
saveAll(): Promise<void>;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export * from "./generalStats.js";
|
||||
export * from "./LogicFunc/generalStats.js";
|
||||
export * as defs from "./defs.js";
|
||||
|
||||
// NOTE: game_logic은 client, server 모두에서 사용되는 라이브러리이다.
|
||||
|
||||
Reference in New Issue
Block a user