2024-03-20 09:26:52 +01:00
|
|
|
"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");
|
2024-03-20 11:19:32 +01:00
|
|
|
const GamesystemLoader_1 = require("./GamesystemLoader");
|
2024-03-22 10:13:50 +01:00
|
|
|
const CharacterLoader_1 = require("./CharacterLoader");
|
2024-05-09 13:33:26 +02:00
|
|
|
const ItemLoader_1 = require("./ItemLoader");
|
2024-03-20 09:26:52 +01:00
|
|
|
class GameModelLoader {
|
|
|
|
constructor(gameModelDir) {
|
2024-05-09 16:03:52 +02:00
|
|
|
this.loadedItemgroups = [];
|
|
|
|
this.loadedItems = [];
|
2024-03-20 09:26:52 +01:00
|
|
|
this.gameModelDir = gameModelDir;
|
|
|
|
}
|
|
|
|
loadGameModel() {
|
|
|
|
const gameModelName = path.basename(this.gameModelDir);
|
2024-03-20 15:15:08 +01:00
|
|
|
const storedScriptAccounts = this.loadScriptAccountComponents();
|
|
|
|
const storedGamesystems = this.loadGamesystems();
|
2024-03-22 10:13:50 +01:00
|
|
|
const storedCharacters = this.loadCharacters();
|
2024-05-09 16:03:52 +02:00
|
|
|
this.loadItemsAndItemgroups();
|
|
|
|
return new StoredGameModel_1.StoredGameModel(gameModelName, storedScriptAccounts, storedGamesystems, storedCharacters, this.loadedItemgroups, this.loadedItems);
|
2024-03-20 09:26:52 +01:00
|
|
|
}
|
|
|
|
loadScriptAccountComponents() {
|
|
|
|
const scriptAccountDir = path.join(this.gameModelDir, ModelComponentFileDirectory_1.ModelComponentFileDirectory.SCRIPTACCOUNT_DIR_NAME);
|
|
|
|
const scriptAccountLoader = new ScriptAccountLoader_1.ScriptAccountLoader(scriptAccountDir);
|
|
|
|
return scriptAccountLoader.loadScriptAccounts();
|
|
|
|
}
|
|
|
|
loadGamesystems() {
|
2024-03-20 11:19:32 +01:00
|
|
|
const gamesystemDir = path.join(this.gameModelDir, ModelComponentFileDirectory_1.ModelComponentFileDirectory.GAMESYSTEM_DIR_NAME);
|
|
|
|
const gamesystemLoader = new GamesystemLoader_1.GamesystemLoader(gamesystemDir);
|
|
|
|
return gamesystemLoader.loadGamesystems();
|
2024-03-20 09:26:52 +01:00
|
|
|
}
|
2024-03-22 10:13:50 +01:00
|
|
|
loadCharacters() {
|
|
|
|
const characterDir = path.join(this.gameModelDir, ModelComponentFileDirectory_1.ModelComponentFileDirectory.CHARACTER_DIR_NAME);
|
|
|
|
const characterLoader = new CharacterLoader_1.CharacterLoader(characterDir);
|
|
|
|
return characterLoader.loadCharacters();
|
|
|
|
}
|
2024-05-09 16:03:52 +02:00
|
|
|
loadItemsAndItemgroups() {
|
2024-05-09 13:33:26 +02:00
|
|
|
const itemgroupDir = path.join(this.gameModelDir, ModelComponentFileDirectory_1.ModelComponentFileDirectory.ITEMGROUP_DIR_NAME);
|
|
|
|
const itemgroupLoader = new ItemLoader_1.ItemLoader(itemgroupDir);
|
2024-05-09 16:03:52 +02:00
|
|
|
itemgroupLoader.loadItemgroups();
|
|
|
|
this.loadedItems = itemgroupLoader.loadedItems;
|
|
|
|
this.loadedItemgroups = itemgroupLoader.loadedItemgroups;
|
2024-05-09 13:33:26 +02:00
|
|
|
}
|
2024-03-20 09:26:52 +01:00
|
|
|
}
|
|
|
|
exports.GameModelLoader = GameModelLoader;
|
|
|
|
//# sourceMappingURL=GameModelLoader.js.map
|