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) {
if(this.templateReference instanceof Character) {
const templateState = state as SimpleTemplateState<Character>
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);
}

View File

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

View File

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