From 859f2075037a9001f0f604a0142f37b64b72ab23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Thu, 11 Apr 2024 18:13:03 +0200 Subject: [PATCH] Fix undefined error when adding conditions to freshly added templatestate --- .../simple-state-editor.component.ts | 8 +++++--- testModel/characters/Hicks Haddock.json | 10 ++++++++++ testModel/gamesystems/Characterstimmung.json | 6 ++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts index 802cac1..8aadd6c 100644 --- a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts +++ b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts @@ -102,9 +102,11 @@ export class SimpleStateEditorComponent implements OnInit{ onCreateCondition(state: SimpleState, condition: ScriptAccountCondition) { if(this.templateReference instanceof Character) { const templateState = state as SimpleTemplateState - console.log("CharacterRef: ", this.templateReference); - templateState.conditionMap.get(this.templateReference as Character)!.push(condition) - console.log(templateState) + if(templateState.conditionMap.has(this.templateReference)) { + templateState.conditionMap.get(this.templateReference as Character)!.push(condition) + } else { + templateState.conditionMap.set(this.templateReference as Character, [condition]) + } } else { state.addScriptAccountCondition(condition); } diff --git a/testModel/characters/Hicks Haddock.json b/testModel/characters/Hicks Haddock.json index b3934ab..7cfe07a 100644 --- a/testModel/characters/Hicks Haddock.json +++ b/testModel/characters/Hicks Haddock.json @@ -18,6 +18,16 @@ { "stateLabel": "Wütend", "conditionMap": [] + }, + { + "stateLabel": "Enttäuscht", + "conditionMap": [ + { + "scriptAccount": "Luftfeuchtigkeit", + "minValue": 0, + "maxValue": "10" + } + ] } ], "transitions": [ diff --git a/testModel/gamesystems/Characterstimmung.json b/testModel/gamesystems/Characterstimmung.json index 26fca23..1d92b66 100644 --- a/testModel/gamesystems/Characterstimmung.json +++ b/testModel/gamesystems/Characterstimmung.json @@ -13,6 +13,12 @@ "conditions": [], "stateLabel": "Wütend", "stateDescription": "" + }, + { + "initial": false, + "conditions": [], + "stateLabel": "Enttäuscht", + "stateDescription": "" } ], "transitions": [