49 lines
2.6 KiB
JavaScript
49 lines
2.6 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.GameModelLoader = void 0;
|
|
const StoredGameModel_1 = require("../StoredGameModel");
|
|
const path = require("node:path");
|
|
const ModelComponentFileDirectory_1 = require("../ModelComponentFileDirectory");
|
|
const ScriptAccountLoader_1 = require("./ScriptAccountLoader");
|
|
const GamesystemLoader_1 = require("./GamesystemLoader");
|
|
const CharacterLoader_1 = require("./CharacterLoader");
|
|
const ItemLoader_1 = require("./ItemLoader");
|
|
class GameModelLoader {
|
|
constructor(gameModelDir) {
|
|
this.loadedItemgroups = [];
|
|
this.loadedItems = [];
|
|
this.gameModelDir = gameModelDir;
|
|
}
|
|
loadGameModel() {
|
|
const gameModelName = path.basename(this.gameModelDir);
|
|
const storedScriptAccounts = this.loadScriptAccountComponents();
|
|
const storedGamesystems = this.loadGamesystems();
|
|
const storedCharacters = this.loadCharacters();
|
|
this.loadItemsAndItemgroups();
|
|
return new StoredGameModel_1.StoredGameModel(gameModelName, storedScriptAccounts, storedGamesystems, storedCharacters, this.loadedItemgroups, this.loadedItems);
|
|
}
|
|
loadScriptAccountComponents() {
|
|
const scriptAccountDir = path.join(this.gameModelDir, ModelComponentFileDirectory_1.ModelComponentFileDirectory.SCRIPTACCOUNT_DIR_NAME);
|
|
const scriptAccountLoader = new ScriptAccountLoader_1.ScriptAccountLoader(scriptAccountDir);
|
|
return scriptAccountLoader.loadScriptAccounts();
|
|
}
|
|
loadGamesystems() {
|
|
const gamesystemDir = path.join(this.gameModelDir, ModelComponentFileDirectory_1.ModelComponentFileDirectory.GAMESYSTEM_DIR_NAME);
|
|
const gamesystemLoader = new GamesystemLoader_1.GamesystemLoader(gamesystemDir);
|
|
return gamesystemLoader.loadGamesystems();
|
|
}
|
|
loadCharacters() {
|
|
const characterDir = path.join(this.gameModelDir, ModelComponentFileDirectory_1.ModelComponentFileDirectory.CHARACTER_DIR_NAME);
|
|
const characterLoader = new CharacterLoader_1.CharacterLoader(characterDir);
|
|
return characterLoader.loadCharacters();
|
|
}
|
|
loadItemsAndItemgroups() {
|
|
const itemgroupDir = path.join(this.gameModelDir, ModelComponentFileDirectory_1.ModelComponentFileDirectory.ITEMGROUP_DIR_NAME);
|
|
const itemgroupLoader = new ItemLoader_1.ItemLoader(itemgroupDir);
|
|
itemgroupLoader.loadItemgroups();
|
|
this.loadedItems = itemgroupLoader.loadedItems;
|
|
this.loadedItemgroups = itemgroupLoader.loadedItemgroups;
|
|
}
|
|
}
|
|
exports.GameModelLoader = GameModelLoader;
|
|
//# sourceMappingURL=GameModelLoader.js.map
|