From 5cb535a2640a6770390e8ab969d66beda07fb39e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Fri, 22 Mar 2024 17:57:38 +0100 Subject: [PATCH] Load CharacterSpecific Gamesystems (at least considered states) --- src/app/app.component.ts | 2 +- .../parser/characterParser/CharacterParser.ts | 14 +++++- .../gamesystemParser/GamesystemParser.ts | 3 ++ .../parser/templateParser/TemplateParser.ts | 45 +++++++++++++++++++ 4 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 src/app/project/parser/templateParser/TemplateParser.ts diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 41f2835..fc9e189 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -204,7 +204,7 @@ export class AppComponent implements OnInit{ const gamesystemParser = new GamesystemParser(scriptAccounts); const gamesystems = gamesystemParser.parseStoredGamesystems(storedGameModel.storedGamesystems); - const characterParser = new CharacterParser(); + const characterParser = new CharacterParser(gamesystemParser.getAllParsedGamesystems(), scriptAccounts); const characters = characterParser.parseCharacters(storedGameModel.storedCharacters); gameModel.scriptAccounts = scriptAccounts diff --git a/src/app/project/parser/characterParser/CharacterParser.ts b/src/app/project/parser/characterParser/CharacterParser.ts index 07d7378..998b26f 100644 --- a/src/app/project/parser/characterParser/CharacterParser.ts +++ b/src/app/project/parser/characterParser/CharacterParser.ts @@ -1,9 +1,18 @@ import {StoreComponent} from "../../../../../app/storage/StoreComponent"; import {Character} from "../../game-model/characters/Character"; +import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount"; +import {TemplateParser} from "../templateParser/TemplateParser"; +import {Gamesystem} from "../../game-model/gamesystems/Gamesystem"; export class CharacterParser { + private templateParser: TemplateParser + + constructor(gamesystems: Gamesystem[], scriptAccounts: ScriptAccount[]) { + this.templateParser = new TemplateParser(gamesystems, scriptAccounts) + } + public parseCharacters(characters: StoreComponent[]): Character[] { const loadedCharacters: Character[] = [] characters.forEach(character => loadedCharacters.push(this.parseSingleCharacter(JSON.parse(character.jsonString)))) @@ -11,6 +20,9 @@ export class CharacterParser { } private parseSingleCharacter(characterData: any): Character { - return new Character(characterData.componentName, characterData.componentDescription); + const character = new Character(characterData.componentName, characterData.componentDescription); + character.characterSpecificGamesystems = this.templateParser.parseTemplateGamesystems(characterData.characterSpecificGamesystems) + console.log(character.characterSpecificGamesystems) + return character; } } diff --git a/src/app/project/parser/gamesystemParser/GamesystemParser.ts b/src/app/project/parser/gamesystemParser/GamesystemParser.ts index e40fa92..c8542ea 100644 --- a/src/app/project/parser/gamesystemParser/GamesystemParser.ts +++ b/src/app/project/parser/gamesystemParser/GamesystemParser.ts @@ -86,4 +86,7 @@ export class GamesystemParser { return undefined } + getAllParsedGamesystems() { + return this.parsedGamesystems + } } diff --git a/src/app/project/parser/templateParser/TemplateParser.ts b/src/app/project/parser/templateParser/TemplateParser.ts new file mode 100644 index 0000000..9e3169e --- /dev/null +++ b/src/app/project/parser/templateParser/TemplateParser.ts @@ -0,0 +1,45 @@ +import {Gamesystem} from "../../game-model/gamesystems/Gamesystem"; +import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount"; +import {TemplateGamesystem} from "../../game-model/gamesystems/TemplateGamesystem"; +import {StateParser} from "../gamesystemParser/StateParser"; +import {ProductGamesystem} from "../../game-model/gamesystems/ProductGamesystem"; +import {SimpleGamesystem} from "../../game-model/gamesystems/SimpleGamesystem"; + +export class TemplateParser { + private gamesystems: Gamesystem[] + private stateParser: StateParser + + + constructor(gamesystems: Gamesystem[], scriptAccounts: ScriptAccount[]) { + this.gamesystems = gamesystems; + this.stateParser = new StateParser(scriptAccounts); + } + + parseTemplateGamesystems(templateGamesystemData: any): TemplateGamesystem[] { + const templateGamesystems: TemplateGamesystem[] = [] + for(let i=0; i gamesystem.componentName === gamesystemName); + } +}