diff --git a/src/controllers/EffectMap.ts b/src/controllers/EffectMap.ts index 847cf28..f8775ea 100644 --- a/src/controllers/EffectMap.ts +++ b/src/controllers/EffectMap.ts @@ -1,15 +1,21 @@ +import { Convertion } from '../config/Convertion' +import { parseData } from '../tools/parseData' import type { IEffectMap, IXML } from '../types' export class EffectMap { - public effects: IEffectMap['effects'] = [] + public data: IEffectMap = { effects: [] } - constructor(XML: IXML) { + constructor(XML: IXML, fileName: string) { this.parseLibrairies(XML.map.effect) + + parseData(Convertion.gamedataConfigDir, fileName, this.data).catch((error) => { + return console.error(error) + }) } private parseLibrairies(effects: any[]): void { for (const libraryXML of effects) { - this.effects.push({ + this.data.effects.push({ id: Number(libraryXML.id), lib: libraryXML.lib, type: libraryXML.type, diff --git a/src/controllers/FigureData.ts b/src/controllers/FigureData.ts index 0411a25..8a8c470 100644 --- a/src/controllers/FigureData.ts +++ b/src/controllers/FigureData.ts @@ -1,3 +1,4 @@ +import { parseData } from '../tools/parseData' import type { IFigureData, IFigureDataColor, @@ -6,13 +7,18 @@ import type { IFigureDataSetType, IXML } from '../types' +import { Convertion } from '../config/Convertion' export class FigureData { public data: IFigureData = { palettes: [], setTypes: [] } - constructor(XML: IXML) { + constructor(XML: IXML, fileName: string) { this.parsePalettes(XML.figuredata.colors.palette) this.parseSetTypes(XML.figuredata.sets.settype) + + parseData(Convertion.gamedataConfigDir, fileName, this.data).catch((error) => { + return console.error(error) + }) } private parsePalettes(palettes: any[]): void { diff --git a/src/controllers/FigureMap.ts b/src/controllers/FigureMap.ts index f62c98e..e088177 100644 --- a/src/controllers/FigureMap.ts +++ b/src/controllers/FigureMap.ts @@ -1,10 +1,16 @@ +import { Convertion } from '../config/Convertion' +import { parseData } from '../tools/parseData' import type { IFigureMap, IFigureMapLibrary, IXML } from '../types' export class FigureMap { public data: IFigureMap = { libraries: [] } - constructor(XML: IXML) { + constructor(XML: IXML, fileName: string) { this.parseLibrairies(XML.map.lib) + + parseData(Convertion.gamedataConfigDir, fileName, this.data).catch((error) => { + return console.error(error) + }) } private parseLibrairies(librairies: any[]): void { diff --git a/src/controllers/FurniData.ts b/src/controllers/FurniData.ts index e2b1121..bb83cd6 100644 --- a/src/controllers/FurniData.ts +++ b/src/controllers/FurniData.ts @@ -1,11 +1,17 @@ +import { parseData } from '../tools/parseData' import type { IFurni, IFurniData, IXML, KeyValuePairs } from '../types' +import { Convertion } from '../config/Convertion' export class FurniData { public data: IFurniData = { roomItemTypes: [], wallItemTypes: [] } - constructor(data: IXML) { + constructor(data: IXML, fileName: string) { this.parseRoomItemTypes(data.roomitemtypes.furnitype) this.parseWallItemTypes(data.roomitemtypes.furnitype) + + parseData(Convertion.gamedataConfigDir, fileName, this.data).catch((error) => { + return console.error(error) + }) } private parseRoomItemTypes(roomItems: IFurni[]): void {