Store Characterspecific Gamesystems
All checks were successful
E2E Testing / test (push) Successful in 2m6s
All checks were successful
E2E Testing / test (push) Successful in 2m6s
This commit is contained in:
parent
a13273b08d
commit
d31182cf36
@ -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;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
{
|
{
|
||||||
"componentName": "Astrid Hofferson",
|
"componentName": "Astrid Hofferson",
|
||||||
"componentDescription": "",
|
|
||||||
"characterSpecificGamesystems": []
|
"characterSpecificGamesystems": []
|
||||||
}
|
}
|
@ -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
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user