alt-templatesystem-impl #29

Closed
sebastian wants to merge 23 commits from alt-templatesystem-impl into character-specific-gamesystems
3 changed files with 13 additions and 16 deletions
Showing only changes of commit d31182cf36 - Show all commits

View File

@ -2,9 +2,12 @@ import {Character} from "../game-model/characters/Character";
import {StoreComponent} from "../../../../app/storage/StoreComponent"; import {StoreComponent} from "../../../../app/storage/StoreComponent";
import {SerializeConstants} from "./SerializeConstants"; import {SerializeConstants} from "./SerializeConstants";
import {ModelComponentType} from "../game-model/ModelComponentType"; import {ModelComponentType} from "../game-model/ModelComponentType";
import {Gamesystem} from "../game-model/gamesystems/Gamesystem";
export class CharacterSerializer { export class CharacterSerializer {
private static ignoredKeys: string[] = ['unsaved', 'type', 'incomingTransitions', 'outgoingTransitions', 'initial', 'conditions', 'stateDescription', 'templateType']
public static serializeCharacters(characters: Character[]): StoreComponent[] { public static serializeCharacters(characters: Character[]): StoreComponent[] {
const storedCharacters: StoreComponent[] = [] const storedCharacters: StoreComponent[] = []
characters.forEach(character => storedCharacters.push(this.serializeSingleCharacter(character))) characters.forEach(character => storedCharacters.push(this.serializeSingleCharacter(character)))
@ -14,7 +17,14 @@ export class CharacterSerializer {
private static serializeSingleCharacter(character: Character): StoreComponent{ private static serializeSingleCharacter(character: Character): StoreComponent{
const fileName = character.componentName const fileName = character.componentName
const jsonString = JSON.stringify(character, (key, value) => { 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 return undefined
} else { } else {
return value; return value;

View File

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

View File

@ -1,32 +1,20 @@
{ {
"componentName": "Hicks Haddock", "componentName": "Hicks Haddock",
"componentDescription": "", "componentDescription": "Das ist ein Test",
"characterSpecificGamesystems": [ "characterSpecificGamesystems": [
{ {
"componentName": "Characterstimmung", "componentName": "Characterstimmung",
"componentDescription": "",
"states": [ "states": [
{ {
"incomingTransitions": [],
"outgoingTransitions": [],
"initial": true,
"conditions": [],
"stateLabel": "Fröhlich", "stateLabel": "Fröhlich",
"stateDescription": "",
"conditionMap": {} "conditionMap": {}
}, },
{ {
"incomingTransitions": [],
"outgoingTransitions": [],
"initial": false,
"conditions": [],
"stateLabel": "Wütend", "stateLabel": "Wütend",
"stateDescription": "",
"conditionMap": {} "conditionMap": {}
} }
], ],
"transitions": [], "transitions": []
"templateType": 1
} }
] ]
} }