Fix undefined error when adding conditions to freshly added templatestate
All checks were successful
E2E Testing / test (push) Successful in 2m0s

This commit is contained in:
Sebastian Böckelmann 2024-04-11 18:13:03 +02:00
parent 803d0d4443
commit 859f207503
3 changed files with 21 additions and 3 deletions

View File

@ -102,9 +102,11 @@ export class SimpleStateEditorComponent implements OnInit{
onCreateCondition(state: SimpleState, condition: ScriptAccountCondition) { onCreateCondition(state: SimpleState, condition: ScriptAccountCondition) {
if(this.templateReference instanceof Character) { if(this.templateReference instanceof Character) {
const templateState = state as SimpleTemplateState<Character> const templateState = state as SimpleTemplateState<Character>
console.log("CharacterRef: ", this.templateReference); if(templateState.conditionMap.has(this.templateReference)) {
templateState.conditionMap.get(this.templateReference as Character)!.push(condition) templateState.conditionMap.get(this.templateReference as Character)!.push(condition)
console.log(templateState) } else {
templateState.conditionMap.set(this.templateReference as Character, [condition])
}
} else { } else {
state.addScriptAccountCondition(condition); state.addScriptAccountCondition(condition);
} }

View File

@ -18,6 +18,16 @@
{ {
"stateLabel": "Wütend", "stateLabel": "Wütend",
"conditionMap": [] "conditionMap": []
},
{
"stateLabel": "Enttäuscht",
"conditionMap": [
{
"scriptAccount": "Luftfeuchtigkeit",
"minValue": 0,
"maxValue": "10"
}
]
} }
], ],
"transitions": [ "transitions": [

View File

@ -13,6 +13,12 @@
"conditions": [], "conditions": [],
"stateLabel": "Wütend", "stateLabel": "Wütend",
"stateDescription": "" "stateDescription": ""
},
{
"initial": false,
"conditions": [],
"stateLabel": "Enttäuscht",
"stateDescription": ""
} }
], ],
"transitions": [ "transitions": [