Save States of CharacterSpecificStates
All checks were successful
E2E Testing / test (push) Successful in 1m33s

This commit is contained in:
Sebastian Böckelmann 2024-03-22 17:42:21 +01:00
parent ef489b19ef
commit 2df08661e0
3 changed files with 27 additions and 3 deletions

View File

@ -5,6 +5,8 @@ import {ModelComponentType} from "../game-model/ModelComponentType";
export class CharacterSerializer {
private static IGNORED_SIMPLE_ATTRIBUTES = ['incomingTransitions', "outgoingTransitions", "unsaved", "type", "stateDescription"]
public static serializeCharacters(characters: Character[]): StoreComponent[] {
const storedCharacters: StoreComponent[] = []
characters.forEach(character => storedCharacters.push(this.serializeSingleCharacter(character)))
@ -14,9 +16,12 @@ export class CharacterSerializer {
private static serializeSingleCharacter(character: Character): StoreComponent{
const fileName = character.componentName
const jsonString = JSON.stringify(character, (key, value) => {
if(key === 'unsaved' || key === 'type') {
if(this.IGNORED_SIMPLE_ATTRIBUTES.includes(key)) {
return undefined
} else {
if(key === 'referenceGamesystem' || key === 'scriptAccount') {
return value.componentName
}
return value;
}
}, SerializeConstants.JSON_INDENT)

View File

@ -1,4 +1,5 @@
{
"componentName": "Astrid Hofferson",
"componentDescription": ""
"componentDescription": "",
"characterSpecificGamesystems": []
}

View File

@ -1,4 +1,22 @@
{
"componentName": "Hicks Haddock",
"componentDescription": ""
"componentDescription": "",
"characterSpecificGamesystems": [
{
"templateStates": [
{
"initial": false,
"conditions": [
{
"scriptAccount": "Temperature",
"minValue": 0,
"maxValue": "5"
}
],
"stateLabel": "Wütend"
}
],
"referenceGamesystem": "Characterstimmung"
}
]
}