From 029f27313990bbcf16a4adeadff9a87c9a2b181b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Thu, 11 Apr 2024 15:47:25 +0200 Subject: [PATCH] Load ConditionMap from Disk --- src/app/app.component.ts | 2 +- .../parser/characterParser/CharacterParser.ts | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index be0a940..221fe57 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -211,7 +211,7 @@ export class AppComponent implements OnInit{ const gamesystemParser = new GamesystemParser(scriptAccounts); const gamesystems = gamesystemParser.parseStoredGamesystems(storedGameModel.storedGamesystems); - const characterParser = new CharacterParser(gamesystemParser.getParsedTemplateGamesystems(TemplateType.CHARACTER)); + const characterParser = new CharacterParser(gamesystemParser.getParsedTemplateGamesystems(TemplateType.CHARACTER), 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 6ded01a..d1323f9 100644 --- a/src/app/project/parser/characterParser/CharacterParser.ts +++ b/src/app/project/parser/characterParser/CharacterParser.ts @@ -1,14 +1,19 @@ import {StoreComponent} from "../../../../../app/storage/StoreComponent"; import {Character} from "../../game-model/characters/Character"; import {SimpleTemplateGamesystem} from "../../game-model/gamesystems/SimpleTemplateGamesystem"; +import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount"; +import {ScriptAccountParser} from "../ScriptAccountParser"; +import {ScriptAccountConditionParser} from "../gamesystemParser/ScriptAccountConditionParser"; export class CharacterParser { characterSpecificGamesystems: SimpleTemplateGamesystem[] + scriptAccountConditionParser: ScriptAccountConditionParser - constructor(characterSpecificGamesystems: SimpleTemplateGamesystem[]) { + constructor(characterSpecificGamesystems: SimpleTemplateGamesystem[], scriptAccounts: ScriptAccount[]) { this.characterSpecificGamesystems = characterSpecificGamesystems; + this.scriptAccountConditionParser = new ScriptAccountConditionParser(scriptAccounts) } public parseCharacters(characters: StoreComponent[]): Character[] { @@ -20,7 +25,6 @@ export class CharacterParser { private parseSingleCharacter(characterData: any): Character { const character = new Character(characterData.componentName, characterData.componentDescription); character.characterSpecificGamesystems = this.parseCharacterSpecificGamesystems(character, characterData.characterSpecificGamesystems); - console.log("Parsed Character", character) return character; } @@ -41,13 +45,14 @@ export class CharacterParser { const stateReference = characterSpecificGamesystem.states[i]; const state = this.findReferencedState(referencedGamesystem, stateReference.stateLabel)! - state.conditionMap.set(character, []) + const conditions = this.scriptAccountConditionParser.parseStoredConditions(stateReference.conditionMap); + + state.conditionMap.set(character, conditions) } } return referencedGamesystem; } - private findCharacterSpecificGamesystem(componentName: string): SimpleTemplateGamesystem | undefined{ return this.characterSpecificGamesystems.find(gamesystem => gamesystem.componentName === componentName) }