alt-templatesystem-impl #29
@ -2,9 +2,12 @@ import {Character} from "../game-model/characters/Character";
|
||||
import {StoreComponent} from "../../../../app/storage/StoreComponent";
|
||||
import {SerializeConstants} from "./SerializeConstants";
|
||||
import {ModelComponentType} from "../game-model/ModelComponentType";
|
||||
import {Gamesystem} from "../game-model/gamesystems/Gamesystem";
|
||||
|
||||
export class CharacterSerializer {
|
||||
|
||||
private static ignoredKeys: string[] = ['unsaved', 'type', 'incomingTransitions', 'outgoingTransitions', 'initial', 'conditions', 'stateDescription', 'templateType']
|
||||
|
||||
public static serializeCharacters(characters: Character[]): StoreComponent[] {
|
||||
const storedCharacters: StoreComponent[] = []
|
||||
characters.forEach(character => storedCharacters.push(this.serializeSingleCharacter(character)))
|
||||
@ -14,7 +17,14 @@ 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(value instanceof Gamesystem) {
|
||||
return {
|
||||
...value,
|
||||
componentDescription: undefined
|
||||
}
|
||||
}
|
||||
|
||||
if(this.ignoredKeys.includes(key)) {
|
||||
return undefined
|
||||
} else {
|
||||
return value;
|
||||
|
@ -1,5 +1,4 @@
|
||||
{
|
||||
"componentName": "Astrid Hofferson",
|
||||
"componentDescription": "",
|
||||
"characterSpecificGamesystems": []
|
||||
}
|
@ -1,32 +1,20 @@
|
||||
{
|
||||
"componentName": "Hicks Haddock",
|
||||
"componentDescription": "",
|
||||
"componentDescription": "Das ist ein Test",
|
||||
"characterSpecificGamesystems": [
|
||||
{
|
||||
"componentName": "Characterstimmung",
|
||||
"componentDescription": "",
|
||||
"states": [
|
||||
{
|
||||
"incomingTransitions": [],
|
||||
"outgoingTransitions": [],
|
||||
"initial": true,
|
||||
"conditions": [],
|
||||
"stateLabel": "Fröhlich",
|
||||
"stateDescription": "",
|
||||
"conditionMap": {}
|
||||
},
|
||||
{
|
||||
"incomingTransitions": [],
|
||||
"outgoingTransitions": [],
|
||||
"initial": false,
|
||||
"conditions": [],
|
||||
"stateLabel": "Wütend",
|
||||
"stateDescription": "",
|
||||
"conditionMap": {}
|
||||
}
|
||||
],
|
||||
"transitions": [],
|
||||
"templateType": 1
|
||||
"transitions": []
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user