도메인 엔티티 및 포트 추가: 기본 모델 및 인터페이스 정의
This commit is contained in:
@@ -0,0 +1,80 @@
|
|||||||
|
// 도메인 기본 엔티티: 서비스/DB에 의존하지 않는 공통 모델.
|
||||||
|
|
||||||
|
export type GeneralId = number;
|
||||||
|
export type CityId = number;
|
||||||
|
export type NationId = number;
|
||||||
|
|
||||||
|
export type ColorCode = string;
|
||||||
|
|
||||||
|
export interface StatBlock {
|
||||||
|
leadership: number;
|
||||||
|
strength: number;
|
||||||
|
intelligence: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type TriggerValue = boolean | number | string;
|
||||||
|
|
||||||
|
export interface GeneralTriggerState {
|
||||||
|
// Trigger 시스템에서 사용하는 확장 슬롯.
|
||||||
|
flags: Record<string, boolean>;
|
||||||
|
counters: Record<string, number>;
|
||||||
|
modifiers: Record<string, number>;
|
||||||
|
meta: Record<string, TriggerValue>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface General<TriggerState extends GeneralTriggerState = GeneralTriggerState> {
|
||||||
|
id: GeneralId;
|
||||||
|
name: string;
|
||||||
|
nationId: NationId;
|
||||||
|
cityId: CityId;
|
||||||
|
troopId: number;
|
||||||
|
stats: StatBlock;
|
||||||
|
experience: number;
|
||||||
|
dedication: number;
|
||||||
|
officerLevel: number;
|
||||||
|
injury: number;
|
||||||
|
gold: number;
|
||||||
|
rice: number;
|
||||||
|
crew: number;
|
||||||
|
train: number;
|
||||||
|
age: number;
|
||||||
|
npcState: number;
|
||||||
|
triggerState: TriggerState;
|
||||||
|
meta: Record<string, TriggerValue>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface City {
|
||||||
|
id: CityId;
|
||||||
|
name: string;
|
||||||
|
nationId: NationId;
|
||||||
|
level: number;
|
||||||
|
population: number;
|
||||||
|
populationMax: number;
|
||||||
|
agriculture: number;
|
||||||
|
agricultureMax: number;
|
||||||
|
commerce: number;
|
||||||
|
commerceMax: number;
|
||||||
|
security: number;
|
||||||
|
securityMax: number;
|
||||||
|
supplyState: number;
|
||||||
|
frontState: number;
|
||||||
|
defence: number;
|
||||||
|
defenceMax: number;
|
||||||
|
wall: number;
|
||||||
|
wallMax: number;
|
||||||
|
meta: Record<string, TriggerValue>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Nation {
|
||||||
|
id: NationId;
|
||||||
|
name: string;
|
||||||
|
color: ColorCode;
|
||||||
|
capitalCityId: CityId | null;
|
||||||
|
chiefGeneralId: GeneralId | null;
|
||||||
|
gold: number;
|
||||||
|
rice: number;
|
||||||
|
power: number;
|
||||||
|
level: number;
|
||||||
|
typeCode: string;
|
||||||
|
meta: Record<string, TriggerValue>;
|
||||||
|
}
|
||||||
@@ -1 +1,2 @@
|
|||||||
export {};
|
export * from './domain/entities';
|
||||||
|
export * from './ports/world';
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
// 도메인 로직이 DB에 직접 접근하지 않도록 하는 인터페이스.
|
||||||
|
|
||||||
|
import type {
|
||||||
|
City,
|
||||||
|
CityId,
|
||||||
|
General,
|
||||||
|
GeneralId,
|
||||||
|
Nation,
|
||||||
|
NationId,
|
||||||
|
} from '../domain/entities';
|
||||||
|
|
||||||
|
export interface GeneralRepository<GeneralType extends General = General> {
|
||||||
|
getById(id: GeneralId): Promise<GeneralType | null>;
|
||||||
|
listByNation(nationId: NationId): Promise<GeneralType[]>;
|
||||||
|
save(general: GeneralType): Promise<void>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CityRepository<CityType extends City = City> {
|
||||||
|
getById(id: CityId): Promise<CityType | null>;
|
||||||
|
listByNation(nationId: NationId): Promise<CityType[]>;
|
||||||
|
save(city: CityType): Promise<void>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface NationRepository<NationType extends Nation = Nation> {
|
||||||
|
getById(id: NationId): Promise<NationType | null>;
|
||||||
|
listAll(): Promise<NationType[]>;
|
||||||
|
save(nation: NationType): Promise<void>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface WorldStateReader<
|
||||||
|
GeneralType extends General = General,
|
||||||
|
CityType extends City = City,
|
||||||
|
NationType extends Nation = Nation
|
||||||
|
> {
|
||||||
|
getGeneralById(id: GeneralId): Promise<GeneralType | null>;
|
||||||
|
getCityById(id: CityId): Promise<CityType | null>;
|
||||||
|
getNationById(id: NationId): Promise<NationType | null>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface WorldStateWriter<
|
||||||
|
GeneralType extends General = General,
|
||||||
|
CityType extends City = City,
|
||||||
|
NationType extends Nation = Nation
|
||||||
|
> {
|
||||||
|
saveGeneral(general: GeneralType): Promise<void>;
|
||||||
|
saveCity(city: CityType): Promise<void>;
|
||||||
|
saveNation(nation: NationType): Promise<void>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface WorldStateRepository<
|
||||||
|
GeneralType extends General = General,
|
||||||
|
CityType extends City = City,
|
||||||
|
NationType extends Nation = Nation
|
||||||
|
> extends WorldStateReader<GeneralType, CityType, NationType>,
|
||||||
|
WorldStateWriter<GeneralType, CityType, NationType> {}
|
||||||
Reference in New Issue
Block a user