refac: 값 정리
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
export type UnitedGameState = 'onGame' | 'united' | 'onEvent' | 'endEvent';
|
||||
|
||||
export interface IGameEnvEntity {
|
||||
startTime: Date;
|
||||
lastExecuted: Date;
|
||||
|
||||
initYear: number;
|
||||
initMonth: number;
|
||||
|
||||
gameStartYear: number;
|
||||
gameStartMonth: number;
|
||||
|
||||
year: number;
|
||||
month: number;
|
||||
|
||||
turntermSec: number;
|
||||
|
||||
refreshedKillTurn: number;
|
||||
|
||||
isFictionMode: boolean;
|
||||
unitedGameState: UnitedGameState;
|
||||
blockGeneralCreate: boolean;
|
||||
|
||||
mapTheme: string;
|
||||
prevWinnerName?: string;
|
||||
|
||||
scenarioID: number;
|
||||
scenarioName: string;
|
||||
gameSeason: number;
|
||||
|
||||
maxGeneralCnt: number;
|
||||
maxNationCnt: number;
|
||||
|
||||
remainGeniusCnt: number;
|
||||
autorunUserPolicy: Record<string, unknown>;
|
||||
|
||||
//게임 외부는 다른 엔티티로 분리
|
||||
}
|
||||
@@ -55,7 +55,12 @@ export interface IGeneralEntity {
|
||||
specialityDomestic: SpecialityDomesticType;
|
||||
specialityWar: SpecialityWarType;
|
||||
|
||||
defenceTrain: number;
|
||||
defenceTrained: number;
|
||||
|
||||
crewType: number;
|
||||
crew: number;
|
||||
trained: number;
|
||||
morale: number;
|
||||
|
||||
npcSpec?: {
|
||||
msg?: string;
|
||||
|
||||
@@ -3,6 +3,7 @@ import type { ICityEntity } from './CityEntity.js';
|
||||
import type { IGeneralEntity } from './GeneralEntity.js';
|
||||
import type { INationEntity } from './NationEntity.js';
|
||||
import type { ITroopEntity } from './TroopEntity.js';
|
||||
import type { IGameEnvEntity } from './GameEnvEntity.js';
|
||||
|
||||
export type { IGeneralEntity } from './GeneralEntity.js';
|
||||
export type { ICityEntity } from './CityEntity.js';
|
||||
@@ -11,10 +12,12 @@ export type { INationEntity } from './NationEntity.js';
|
||||
|
||||
|
||||
export type ValidEntityList = {
|
||||
'General': IGeneralEntity;
|
||||
'City': ICityEntity;
|
||||
'Nation': INationEntity;
|
||||
'City': ICityEntity;
|
||||
'Troop': ITroopEntity;
|
||||
'General': IGeneralEntity;
|
||||
|
||||
'GameEnv': IGameEnvEntity;
|
||||
};
|
||||
|
||||
export type ValidEntity = ValuesOf<ValidEntityList>;
|
||||
|
||||
@@ -1,3 +1,20 @@
|
||||
export class GameEnv{
|
||||
import type { IGameEnvEntity } from "./Entity/GameEnvEntity.js";
|
||||
import { LazyEntityUpdater } from "./LazyEntityUpdater.js";
|
||||
import type { IResourceController } from "./ResourceController.js";
|
||||
|
||||
export class GameEnv extends LazyEntityUpdater<IGameEnvEntity>{
|
||||
protected readonly _indirectNames: readonly (keyof IGameEnvEntity)[] = [
|
||||
//사실상 모두.
|
||||
];
|
||||
protected readonly _entityType = "GameEnv";
|
||||
protected readonly _raw: IGameEnvEntity;
|
||||
|
||||
constructor(
|
||||
raw: IGameEnvEntity,
|
||||
protected readonly resourceController: IResourceController
|
||||
){
|
||||
super();
|
||||
this._raw = raw;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import { must } from "@sammo/util";
|
||||
import { Nation } from "./Nation.js";
|
||||
import { Troop } from "./Troop.js";
|
||||
import { LazyEntityUpdater } from "./LazyEntityUpdater.js";
|
||||
import type { IAction, IActionKey } from "./IAction.js";
|
||||
|
||||
export class General extends LazyEntityUpdater<IGeneralEntity> {
|
||||
protected readonly _indirectNames: (keyof IGeneralEntity)[] = ["id", "nationID", "troopID", "nationID"];
|
||||
@@ -17,6 +18,8 @@ export class General extends LazyEntityUpdater<IGeneralEntity> {
|
||||
protected _troop: WeakRef<Troop> | undefined;
|
||||
protected _nation: WeakRef<Nation>;
|
||||
|
||||
protected readonly iActionHandlers: Map<IActionKey, IAction>;
|
||||
|
||||
constructor(
|
||||
raw: IGeneralEntity,
|
||||
protected readonly resourceController: IResourceController
|
||||
@@ -29,6 +32,9 @@ export class General extends LazyEntityUpdater<IGeneralEntity> {
|
||||
if(raw.troopID){
|
||||
this._troop = new WeakRef(must(resourceController.troop(raw.troopID, raw.nationID)));
|
||||
}
|
||||
|
||||
//TODO: iAction 처리해야함
|
||||
this.iActionHandlers = new Map();
|
||||
}
|
||||
|
||||
public get id(): GeneralID {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import type { ValuesOf } from "@sammo/util";
|
||||
import type * as IMethod from "./IActionMethod.js";
|
||||
import type { ItemKeyType } from "./defs.js";
|
||||
export type * as IMethod from "./IActionMethod.js";
|
||||
|
||||
export interface IActionMethod extends
|
||||
@@ -20,4 +22,21 @@ export interface IAction extends Partial<IActionMethod> {
|
||||
|
||||
getName(): string;
|
||||
getInfo(): string[] | string;
|
||||
}
|
||||
}
|
||||
|
||||
export const IActionOrder = [
|
||||
'nationType',
|
||||
'officerLevel',
|
||||
'specialityDomestic',
|
||||
'specialityWar',
|
||||
'personlity',
|
||||
'crewType',
|
||||
'inheritBuff',
|
||||
'scenarioEffect',
|
||||
'horse',
|
||||
'weapon',
|
||||
'book',
|
||||
'item',
|
||||
];
|
||||
|
||||
export type IActionKey = ValuesOf<IAction>;
|
||||
@@ -13,22 +13,29 @@ import type { EntityType, ValidEntityType } from "./Entity/index.js";
|
||||
import type { IReservedTurn } from "./Entity/ReservedTurn.js";
|
||||
|
||||
export interface IResourceController {
|
||||
city(id: CityID): City | undefined;
|
||||
|
||||
nation(id: NationID): Nation | undefined;
|
||||
city(id: CityID): City | undefined;
|
||||
troop(id: TroopID, nation: NationID): Troop | undefined;
|
||||
general(id: GeneralID): General | undefined;
|
||||
|
||||
getGameEnv(): GameEnv;
|
||||
gameEnv(): GameEnv;
|
||||
|
||||
allNations(): Map<NationID, Nation>;
|
||||
allCities(): Map<CityID, City>;
|
||||
allCitiesByNation(): Map<NationID, Map<CityID, City>>;
|
||||
allTroops(): Map<NationID, Map<TroopID, Troop>>;
|
||||
allGenerals(): Map<GeneralID, General>;
|
||||
|
||||
generalByNation(id: NationID): Map<GeneralID, General>;
|
||||
generalByCity(id: CityID, nationID?: NationID): Map<GeneralID, General>;
|
||||
generalByTroop(id: TroopID): Map<GeneralID, General>;
|
||||
|
||||
cityByNation(id: NationID): Map<CityID, City>;
|
||||
generalByNation(id: NationID): Map<GeneralID, General>;
|
||||
generalByCity(id: CityID, nationID?: NationID): Map<GeneralID, General>;
|
||||
|
||||
troopByNation(id: NationID): Map<TroopID, Troop>;
|
||||
|
||||
//----Insert, Update, Delete
|
||||
|
||||
reserveUpdate(entity: LazyEntityUpdater<any>): void;
|
||||
reserveDelete(entity: LazyEntityUpdater<any>): void;
|
||||
|
||||
Reference in New Issue
Block a user