ResourceController 란 것이 있을 것
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import type { General } from "./General.js";
|
||||
import type { City } from "./City.js";
|
||||
import type { Nation } from "./Nation.js";
|
||||
import type { CityID, GeneralID, NationID } from "./defs.js";
|
||||
import type { GameEnv } from "./GameEnv.js";
|
||||
|
||||
export interface IResourceController{
|
||||
addCity(city: City): Promise<boolean>;
|
||||
addNation(nation: Nation): Promise<boolean>;
|
||||
addGeneral(general: General): Promise<boolean>;
|
||||
|
||||
getCity(id: CityID, allowFromDB?: boolean): Promise<City | undefined>;
|
||||
getNation(id: NationID, allowFromDB?: boolean): Promise<Nation | undefined>;
|
||||
getGeneral(id: GeneralID, allowFromDB?: boolean): Promise<General | undefined>;
|
||||
|
||||
getGameEnv(): Promise<GameEnv>;
|
||||
|
||||
findAllNations(): Promise<Map<NationID, Nation>>;
|
||||
findAllCities(): Promise<Map<CityID, City>>;
|
||||
findAllGenerals(): Promise<Map<GeneralID, General>>;
|
||||
|
||||
findCityByNation(id: NationID): Promise<Map<CityID, City>>;
|
||||
findGeneralByNation(id: NationID): Promise<Map<GeneralID, General>>;
|
||||
findGeneralByCity(id: CityID, nationID?: NationID): Promise<Map<GeneralID, General>>;
|
||||
|
||||
findGeneralByQuery(query: unknown): Promise<Map<GeneralID, General>>;
|
||||
findCityByQuery(query: unknown): Promise<Map<CityID, City>>;
|
||||
findNationByQuery(query: unknown): Promise<Map<NationID, Nation>>;
|
||||
|
||||
reset(): void;
|
||||
save(): Promise<void>;
|
||||
}
|
||||
|
||||
let _resourceController: IResourceController | undefined = undefined;
|
||||
|
||||
export const setResourceController = (resourceController: IResourceController) => {
|
||||
_resourceController = resourceController;
|
||||
}
|
||||
|
||||
export const getResourceController = () => {
|
||||
if (_resourceController === undefined) {
|
||||
throw new Error("ResourceController not set");
|
||||
}
|
||||
return _resourceController;
|
||||
}
|
||||
Reference in New Issue
Block a user