+ console.log("CharacterRef: ", this.templateReference);
+ templateState.conditionMap.get(this.templateReference as Character)!.push(condition)
+ console.log(templateState)
+ } else {
+ state.addScriptAccountCondition(condition);
+ }
}
deleteCondition(state: SimpleState, condition: ScriptAccountCondition) {
state.removeScriptAccountCondition(condition.scriptAccount);
}
+
+ getStateConditions(state: SimpleState) {
+ if(state instanceof SimpleTemplateState) {
+ if(this.templateReference instanceof Character) {
+ const referenceSpecificConditions = state.conditionMap.get(this.templateReference as Character)
+ if(referenceSpecificConditions == undefined) {
+ return []
+ } else {
+ return referenceSpecificConditions;
+ }
+ }
+ }
+
+ return state.conditions;
+ }
}
diff --git a/src/app/editor/gamesystem-editor/template-creator/template-creator.component.html b/src/app/editor/gamesystem-editor/template-creator/template-creator.component.html
new file mode 100644
index 0000000..feb02e7
--- /dev/null
+++ b/src/app/editor/gamesystem-editor/template-creator/template-creator.component.html
@@ -0,0 +1,13 @@
+Specify Gamesystem
+
+
+ Referencesystem
+
+ {{gamesystem.componentName}}
+
+
+
+
+
+
+
diff --git a/src/app/editor/gamesystem-editor/template-creator/template-creator.component.scss b/src/app/editor/gamesystem-editor/template-creator/template-creator.component.scss
new file mode 100644
index 0000000..e69de29
diff --git a/src/app/editor/gamesystem-editor/template-creator/template-creator.component.spec.ts b/src/app/editor/gamesystem-editor/template-creator/template-creator.component.spec.ts
new file mode 100644
index 0000000..354ea63
--- /dev/null
+++ b/src/app/editor/gamesystem-editor/template-creator/template-creator.component.spec.ts
@@ -0,0 +1,23 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { TemplateCreatorComponent } from './template-creator.component';
+
+describe('TemplateCreatorComponent', () => {
+ let component: TemplateCreatorComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ imports: [TemplateCreatorComponent]
+ })
+ .compileComponents();
+
+ fixture = TestBed.createComponent(TemplateCreatorComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/editor/gamesystem-editor/template-creator/template-creator.component.ts b/src/app/editor/gamesystem-editor/template-creator/template-creator.component.ts
new file mode 100644
index 0000000..ef9d86a
--- /dev/null
+++ b/src/app/editor/gamesystem-editor/template-creator/template-creator.component.ts
@@ -0,0 +1,26 @@
+import {Component, Inject} from '@angular/core';
+import {MAT_DIALOG_DATA, MatDialogRef, MatDialogTitle} from "@angular/material/dialog";
+import {SimpleTemplateGamesystem} from "../../../project/game-model/gamesystems/SimpleTemplateGamesystem";
+import {FormControl, Validators} from "@angular/forms";
+
+@Component({
+ selector: 'app-template-creator',
+ templateUrl: './template-creator.component.html',
+ styleUrl: './template-creator.component.scss'
+})
+export class TemplateCreatorComponent {
+
+ templateCtrl = new FormControl('', [Validators.required]);
+
+ constructor(@Inject(MAT_DIALOG_DATA) public templateGamesystems: SimpleTemplateGamesystem[],
+ private dialogRef: MatDialogRef) {
+ }
+
+ cancel() {
+ this.dialogRef.close();
+ }
+
+ save() {
+ this.dialogRef.close(this.templateCtrl.value)
+ }
+}
diff --git a/src/app/project/game-model/GameModel.ts b/src/app/project/game-model/GameModel.ts
index e565728..2fb19a5 100644
--- a/src/app/project/game-model/GameModel.ts
+++ b/src/app/project/game-model/GameModel.ts
@@ -5,10 +5,11 @@ import {State} from "./gamesystems/states/State";
import {ProductGamesystem} from "./gamesystems/ProductGamesystem";
import {SimpleGamesystem} from "./gamesystems/SimpleGamesystem";
import {Character} from "./characters/Character";
-import {ModelComponentType} from "./ModelComponentType";
-import {TemplateType} from "./gamesystems/TemplateType";
+import {TemplateType} from "./TemplateType";
+import {SimpleTemplateGamesystem} from "./gamesystems/SimpleTemplateGamesystem";
export class GameModel {
+
gameModelName: string
gamesystems: Gamesystem[] = [];
@@ -46,9 +47,14 @@ export class GameModel {
return undefined;
}
- createGamesystem(gamesystemName: string, parentGamesystemName: string | undefined) {
+ createGamesystem(gamesystemName: string, parentGamesystemName: string | undefined, templateType: TemplateType) {
if(gamesystemName != undefined && this.findGamesystem(gamesystemName) == undefined) {
- const simpleGamesystem = new SimpleGamesystem(gamesystemName, "");
+ let simpleGamesystem = new SimpleGamesystem(gamesystemName, "");
+ if(templateType == TemplateType.CHARACTER) {
+ simpleGamesystem = new SimpleTemplateGamesystem(gamesystemName, "")
+ }
+
+
if(parentGamesystemName != undefined) {
const parentGamesystem = this.findGamesystem(parentGamesystemName);
if(parentGamesystem instanceof SimpleGamesystem) {
@@ -117,22 +123,24 @@ export class GameModel {
})
}
- getTemplateGamesystems(templateType: TemplateType) {
- const gamesystems = this.getGamesystemsAsList()
- return gamesystems.filter(gamesystem => gamesystem.template === templateType);
- }
-
- private getGamesystemsAsList() : Gamesystem[]{
- const gamesystemList: Gamesystem[] = []
-
- const gamesystemQueue : Gamesystem[] = this.gamesystems.map(gamesystem => gamesystem)
+ listGamesystems(templateType: TemplateType): SimpleTemplateGamesystem[] {
+ const gamesystemList: SimpleTemplateGamesystem[] = []
+ const gamesystemQueue: Gamesystem[] = this.gamesystems.concat()
while(gamesystemQueue.length > 0) {
const currentGamesystem = gamesystemQueue.shift()!;
- gamesystemList.push(currentGamesystem)
+
+ if(currentGamesystem.templateType === templateType) {
+ gamesystemList.push(currentGamesystem as SimpleTemplateGamesystem)
+ }
+
if(currentGamesystem instanceof ProductGamesystem) {
- currentGamesystem.innerGamesystems.forEach(innerGamesystem => gamesystemQueue.push(innerGamesystem))
+ currentGamesystem.innerGamesystems.forEach(innerGamesystem => {
+ gamesystemQueue.push(innerGamesystem)
+ })
}
}
- return gamesystemList
+
+ console.log(gamesystemList)
+ return gamesystemList;
}
}
diff --git a/src/app/project/game-model/TemplateType.ts b/src/app/project/game-model/TemplateType.ts
new file mode 100644
index 0000000..c7dd90a
--- /dev/null
+++ b/src/app/project/game-model/TemplateType.ts
@@ -0,0 +1,3 @@
+export enum TemplateType {
+ NORMAL, CHARACTER
+}
diff --git a/src/app/project/game-model/TemplateTypeUtilities.ts b/src/app/project/game-model/TemplateTypeUtilities.ts
new file mode 100644
index 0000000..39deafa
--- /dev/null
+++ b/src/app/project/game-model/TemplateTypeUtilities.ts
@@ -0,0 +1,11 @@
+import {TemplateType} from "./TemplateType";
+
+export class TemplateTypeUtilities {
+ static fromString(value: string) {
+ if(value === 'character') {
+ return TemplateType.CHARACTER
+ } else {
+ return TemplateType.NORMAL
+ }
+ }
+}
diff --git a/src/app/project/game-model/characters/Character.ts b/src/app/project/game-model/characters/Character.ts
index 7b87f7b..d1a1ed2 100644
--- a/src/app/project/game-model/characters/Character.ts
+++ b/src/app/project/game-model/characters/Character.ts
@@ -1,35 +1,24 @@
import {ModelComponent} from "../ModelComponent";
import {ModelComponentType} from "../ModelComponentType";
-import { Gamesystem } from "../gamesystems/Gamesystem";
-import { ProductGamesystem } from "../gamesystems/ProductGamesystem";
-import { ProductTemplateGamesystem } from "../gamesystems/ProductTemplateGamesystem";
-import { SimpleGamesystem } from "../gamesystems/SimpleGamesystem";
-import { SimpleTemplateGamesystem } from "../gamesystems/SimpleTemplateGamesystem";
+import {SimpleTemplateGamesystem} from "../gamesystems/SimpleTemplateGamesystem";
export class Character extends ModelComponent{
- characterSpecificGamesystems: Gamesystem[] = []
+ characterSpecificGamesystems: SimpleTemplateGamesystem[] = []
constructor(componentName: string, componentDescription: string) {
super(componentName, componentDescription, ModelComponentType.CHARACTER);
}
- addCharacterSpecificSimpleGamesystem(referenceSystem: SimpleGamesystem) {
- if(!this.findCharacterSpecificGameystemByName(referenceSystem.componentName)) {
- const templateGamesystem = new SimpleTemplateGamesystem(referenceSystem);
- this.characterSpecificGamesystems.push(templateGamesystem)
+ addCharacterSpecificGamesystem(templateGamesystem: SimpleTemplateGamesystem) {
+ if(!this.isGamesystemCharacterSpecific(templateGamesystem.componentName)) {
+ this.characterSpecificGamesystems.push(templateGamesystem);
+ templateGamesystem.addReferenceKey(this);
}
}
- addCharacterSpecificProductTemplateGamesystem(referenceSystem: ProductGamesystem) {
- if(!this.findCharacterSpecificGameystemByName(referenceSystem.componentName)) {
- const templateGamesystem = new ProductTemplateGamesystem(referenceSystem);
- this.characterSpecificGamesystems.push(templateGamesystem)
- }
- }
-
-
- findCharacterSpecificGameystemByName(referenceName: string) {
- return this.characterSpecificGamesystems.find(gamesystem => gamesystem.componentName === referenceName) != undefined
+ private isGamesystemCharacterSpecific(gamesystemName: string) {
+ const characterSpecificGamesystem = this.characterSpecificGamesystems.find(gamesystem => gamesystem.componentName === gamesystemName);
+ return characterSpecificGamesystem != undefined
}
}
diff --git a/src/app/project/game-model/gamesystems/Gamesystem.ts b/src/app/project/game-model/gamesystems/Gamesystem.ts
index 41e13f1..e41d1a0 100644
--- a/src/app/project/game-model/gamesystems/Gamesystem.ts
+++ b/src/app/project/game-model/gamesystems/Gamesystem.ts
@@ -2,14 +2,16 @@ import {SimpleGamesystem} from "./SimpleGamesystem";
import {ProductGamesystem} from "./ProductGamesystem";
import {ModelComponent} from "../ModelComponent";
import {ModelComponentType} from "../ModelComponentType";
-import {TemplateType} from "./TemplateType";
+import {TemplateType} from "../TemplateType";
export abstract class Gamesystem extends ModelComponent{
states: S[] = [];
transitions: T[] = [];
parentGamesystem: ProductGamesystem | undefined
- template: TemplateType = TemplateType.NONE
+
+ templateType: TemplateType = TemplateType.NORMAL
+
constructor(gamesystemName: string, gamesystemDescription: string) {
super(gamesystemName, gamesystemDescription, ModelComponentType.GAMESYTEM);
diff --git a/src/app/project/game-model/gamesystems/SimpleTemplateGamesystem.ts b/src/app/project/game-model/gamesystems/SimpleTemplateGamesystem.ts
index 61184e4..022a703 100644
--- a/src/app/project/game-model/gamesystems/SimpleTemplateGamesystem.ts
+++ b/src/app/project/game-model/gamesystems/SimpleTemplateGamesystem.ts
@@ -1,42 +1,70 @@
-import { SimpleGamesystem } from "./SimpleGamesystem";
-import { ScriptAccountAction } from "./actions/ScriptAccountAction";
-import { ScriptAccountCondition } from "./conditions/ScriptAccountCondition";
-import { SimpleState } from "./states/SimpleState";
-import { SimpleTransition } from "./transitions/SimpleTransition";
+import {SimpleTemplateState} from "./states/SimpleTemplateState";
+import {Gamesystem} from "./Gamesystem";
+import {SimpleState} from "./states/SimpleState";
+import {SimpleTemplateTransition} from "./transitions/SimpleTemplateTransition";
+import {TemplateType} from "../TemplateType";
-export class SimpleTemplateGamesystem extends SimpleGamesystem {
- referenceSystem: SimpleGamesystem
+export class SimpleTemplateGamesystem extends Gamesystem, SimpleTemplateTransition> {
+ createState(label: string, description: string): SimpleState | undefined {
+ if(label == null) {
+ return undefined;
+ }
- constructor(referenceSystem: SimpleGamesystem) {
- super(referenceSystem.componentName, referenceSystem.componentDescription)
- this.referenceSystem = referenceSystem;
+ if(description == null) {
+ description = "";
+ }
- this.referenceSystem.states.forEach(state => {
- const templateState = new SimpleState(state.stateLabel, state.stateDescription)
- templateState.initial = state.initial;
- templateState.conditions = state.conditions.map(condition => ScriptAccountCondition.constructScriptAccountCondition(condition.scriptAccount, condition.minValue, condition.maxValue)!)
-
- this.states.push(templateState);
- });
-
- this.referenceSystem.transitions.forEach(transition => {
- const startingState = this.findStateByStateLabel(transition.startingState.stateLabel);
- const endingState = this.findStateByStateLabel(transition.endingState.stateLabel);
-
- const templateTransition = new SimpleTransition(startingState!, endingState!)
-
- templateTransition.scriptAccountConditions = transition.scriptAccountConditions.map(condition =>
- ScriptAccountCondition.constructScriptAccountCondition(condition.scriptAccount, condition.minValue, condition.maxValue)!)
-
- templateTransition.scriptAccountActions = transition.scriptAccountActions.map(action => {
- return new ScriptAccountAction(action.scriptAccount, action.changingValue);
- });
-
- this.transitions.push(templateTransition);
- })
-
- this.referenceSystem.addTemplateSystem(this)
+ const state = new SimpleTemplateState(label, description);
+ if(this.states.find(s => s.stateLabel == label) == undefined) {
+ this.states.push(state);
+ return state;
+ } else {
+ return undefined
+ }
}
+ createTransition(startingState: SimpleTemplateState, endingState: SimpleTemplateState): SimpleTemplateTransition | undefined {
+ if((startingState == null || endingState == null) || startingState === endingState) {
+ return undefined;
+ }
+
+ const transition = new SimpleTemplateTransition(startingState, endingState);
+ if(this.transitions.find(t => t.startingState === startingState && t.endingState === endingState) == undefined) {
+ this.transitions.push(transition)
+ return transition;
+ } else {
+ startingState.removeOutgoingTransition(transition);
+ endingState.removeIncomingTransition(transition);
+ return undefined
+ }
+ }
+
+ removeState(state: SimpleTemplateState): boolean {
+ const updatedStates = this.states.filter(s => s !== state);
+ const updated = updatedStates.length != this.states.length;
+ this.states = updatedStates;
+
+ this.transitions = this.transitions.filter(t => t.startingState !== state && t.endingState !== state);
+
+ return updated;
+ }
+
+ addReferenceKey(reference: ReferenceType) {
+ this.states.forEach(state => {
+ if(!state.conditionMap.has(reference)) {
+ state.conditionMap.set(reference, state.conditions.concat())
+ }
+ })
+
+ this.transitions.forEach(transition => {
+ if(!transition.conditions.has(reference)) {
+ transition.conditions.set(reference, transition.scriptAccountConditions.concat())
+ }
+
+ if(!transition.actions.has(reference)) {
+ transition.actions.set(reference, transition.scriptAccountActions.concat())
+ }
+ })
+ }
}
diff --git a/src/app/project/game-model/gamesystems/states/SimpleTemplateState.ts b/src/app/project/game-model/gamesystems/states/SimpleTemplateState.ts
new file mode 100644
index 0000000..52bb80c
--- /dev/null
+++ b/src/app/project/game-model/gamesystems/states/SimpleTemplateState.ts
@@ -0,0 +1,8 @@
+import {SimpleState} from "./SimpleState";
+import {ScriptAccountCondition} from "../conditions/ScriptAccountCondition";
+
+export class SimpleTemplateState extends SimpleState {
+
+ conditionMap: Map = new Map()
+
+}
diff --git a/src/app/project/game-model/gamesystems/transitions/SimpleTemplateTransition.ts b/src/app/project/game-model/gamesystems/transitions/SimpleTemplateTransition.ts
new file mode 100644
index 0000000..72d267a
--- /dev/null
+++ b/src/app/project/game-model/gamesystems/transitions/SimpleTemplateTransition.ts
@@ -0,0 +1,9 @@
+import {SimpleTransition} from "./SimpleTransition";
+import {ScriptAccountCondition} from "../conditions/ScriptAccountCondition";
+import {ScriptAccountAction} from "../actions/ScriptAccountAction";
+
+export class SimpleTemplateTransition extends SimpleTransition {
+
+ conditions: Map = new Map();
+ actions: Map = new Map();
+}
diff --git a/src/app/project/parser/characterParser/CharacterParser.ts b/src/app/project/parser/characterParser/CharacterParser.ts
index 07d7378..d1323f9 100644
--- a/src/app/project/parser/characterParser/CharacterParser.ts
+++ b/src/app/project/parser/characterParser/CharacterParser.ts
@@ -1,9 +1,21 @@
import {StoreComponent} from "../../../../../app/storage/StoreComponent";
import {Character} from "../../game-model/characters/Character";
+import {SimpleTemplateGamesystem} from "../../game-model/gamesystems/SimpleTemplateGamesystem";
+import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount";
+import {ScriptAccountParser} from "../ScriptAccountParser";
+import {ScriptAccountConditionParser} from "../gamesystemParser/ScriptAccountConditionParser";
export class CharacterParser {
+ characterSpecificGamesystems: SimpleTemplateGamesystem[]
+ scriptAccountConditionParser: ScriptAccountConditionParser
+
+ constructor(characterSpecificGamesystems: SimpleTemplateGamesystem[], scriptAccounts: ScriptAccount[]) {
+ this.characterSpecificGamesystems = characterSpecificGamesystems;
+ this.scriptAccountConditionParser = new ScriptAccountConditionParser(scriptAccounts)
+ }
+
public parseCharacters(characters: StoreComponent[]): Character[] {
const loadedCharacters: Character[] = []
characters.forEach(character => loadedCharacters.push(this.parseSingleCharacter(JSON.parse(character.jsonString))))
@@ -11,6 +23,41 @@ export class CharacterParser {
}
private parseSingleCharacter(characterData: any): Character {
- return new Character(characterData.componentName, characterData.componentDescription);
+ const character = new Character(characterData.componentName, characterData.componentDescription);
+ character.characterSpecificGamesystems = this.parseCharacterSpecificGamesystems(character, characterData.characterSpecificGamesystems);
+ return character;
+ }
+
+ private parseCharacterSpecificGamesystems(character: Character, characterSpecificGamesystems: any): SimpleTemplateGamesystem[] {
+ const result: SimpleTemplateGamesystem[] = []
+ for(let i=0; i | undefined{
+ const referencedGamesystem = this.findCharacterSpecificGamesystem(characterSpecificGamesystem.componentName)
+
+ if(referencedGamesystem != undefined) {
+ for(let i=0; i | undefined{
+ return this.characterSpecificGamesystems.find(gamesystem => gamesystem.componentName === componentName)
+ }
+
+ private findReferencedState(gamesystem: SimpleTemplateGamesystem, stateLabel: string) {
+ return gamesystem.states.find(state => state.stateLabel === stateLabel);
}
}
diff --git a/src/app/project/parser/gamesystemParser/GamesystemParser.ts b/src/app/project/parser/gamesystemParser/GamesystemParser.ts
index cc6ee69..eec11c1 100644
--- a/src/app/project/parser/gamesystemParser/GamesystemParser.ts
+++ b/src/app/project/parser/gamesystemParser/GamesystemParser.ts
@@ -6,6 +6,9 @@ import {SimpleGamesystem} from "../../game-model/gamesystems/SimpleGamesystem";
import {StateParser} from "./StateParser";
import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount";
import {TransitionParser} from "./TransitionParser";
+import {TemplateType} from "../../game-model/TemplateType";
+import {SimpleTemplateGamesystem} from "../../game-model/gamesystems/SimpleTemplateGamesystem";
+import {Character} from "../../game-model/characters/Character";
export class GamesystemParser {
@@ -40,15 +43,20 @@ export class GamesystemParser {
}
parseSimpleGamesystem(gamesystemData: any): SimpleGamesystem {
- const simpleGamesystem = new SimpleGamesystem(gamesystemData.componentName, gamesystemData.componentDescription)
+ const templateType = gamesystemData.templateType
+ let simpleGamesystem = new SimpleGamesystem(gamesystemData.componentName, gamesystemData.componentDescription)
+ if(templateType == TemplateType.CHARACTER) {
+ simpleGamesystem = new SimpleTemplateGamesystem(gamesystemData.componentName, gamesystemData.componentDescription)
+ simpleGamesystem.templateType = TemplateType.CHARACTER
+ }
const stateParser = new StateParser(this.scriptAccounts);
- simpleGamesystem.states = stateParser.parseStates(gamesystemData.states)
+ simpleGamesystem.states = stateParser.parseStates(gamesystemData.states, templateType)
const transitionParser = new TransitionParser(simpleGamesystem.states, this.scriptAccounts)
simpleGamesystem.transitions = transitionParser.parseTransitions(gamesystemData.transitions)
- simpleGamesystem.template = gamesystemData.template;
+
return simpleGamesystem
}
@@ -86,4 +94,8 @@ export class GamesystemParser {
return undefined
}
+ getParsedTemplateGamesystems(templateType: TemplateType) {
+ const templateGamesystems = this.parsedGamesystems.filter(gamesystem => gamesystem.templateType === templateType);
+ return templateGamesystems.map(gamesystem => gamesystem as SimpleTemplateGamesystem)
+ }
}
diff --git a/src/app/project/parser/gamesystemParser/StateParser.ts b/src/app/project/parser/gamesystemParser/StateParser.ts
index 8da602a..fce00ce 100644
--- a/src/app/project/parser/gamesystemParser/StateParser.ts
+++ b/src/app/project/parser/gamesystemParser/StateParser.ts
@@ -2,6 +2,9 @@ import {SimpleState} from "../../game-model/gamesystems/states/SimpleState";
import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount";
import {ScriptAccountCondition} from "../../game-model/gamesystems/conditions/ScriptAccountCondition";
import {ScriptAccountConditionParser} from "./ScriptAccountConditionParser";
+import {TemplateType} from "../../game-model/TemplateType";
+import {SimpleTemplateState} from "../../game-model/gamesystems/states/SimpleTemplateState";
+import {Character} from "../../game-model/characters/Character";
export class StateParser {
@@ -12,23 +15,29 @@ export class StateParser {
this.conditionParser = new ScriptAccountConditionParser(scriptAccounts)
}
- public parseStates(stateData: any): SimpleState[] {
+ public parseStates(stateData: any, templateType: TemplateType): SimpleState[] {
const parsedStates: SimpleState[] = []
for(let i=0; i(stateLabel, stateDescription);
+ }
+
simpleState.initial = initial;
simpleState.conditions = conditions;
diff --git a/src/app/project/serializer/CharacterSerializer.ts b/src/app/project/serializer/CharacterSerializer.ts
index 4923004..09e1028 100644
--- a/src/app/project/serializer/CharacterSerializer.ts
+++ b/src/app/project/serializer/CharacterSerializer.ts
@@ -2,9 +2,13 @@ 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";
+import {ScriptAccount} from "../game-model/scriptAccounts/ScriptAccount";
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 +18,22 @@ 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(key === 'scriptAccount') {
+ return value.componentName
+ }
+
+ if(key === 'conditionMap') {
+ return value.get(character)
+ }
+
+ if(this.ignoredKeys.includes(key)) {
return undefined
} else {
return value;
diff --git a/src/app/project/serializer/GamesystemSerializer.ts b/src/app/project/serializer/GamesystemSerializer.ts
index 8ffcafc..717da47 100644
--- a/src/app/project/serializer/GamesystemSerializer.ts
+++ b/src/app/project/serializer/GamesystemSerializer.ts
@@ -4,10 +4,11 @@ import {SimpleGamesystem} from "../game-model/gamesystems/SimpleGamesystem";
import {ProductGamesystem} from "../game-model/gamesystems/ProductGamesystem";
import {SerializeConstants} from "./SerializeConstants";
import {ModelComponentType} from "../game-model/ModelComponentType";
+import {SimpleTemplateGamesystem} from "../game-model/gamesystems/SimpleTemplateGamesystem";
export class GamesystemSerializer {
- private static IGNORED_SIMPLE_ATTRIBUTES = ["parentGamesystem", 'incomingTransitions', "outgoingTransitions", "unsaved", "type"]
+ private static IGNORED_SIMPLE_ATTRIBUTES = ["parentGamesystem", 'incomingTransitions', "outgoingTransitions", "unsaved", "type", "conditionMap"]
public static serializeGamesystems(gamesystems: Gamesystem[]): StoreComponent[] {
let storedGamesystems: StoreComponent[] = []
@@ -16,7 +17,7 @@ export class GamesystemSerializer {
}
private static serializeSingleGamesystem(gamesystem: Gamesystem): StoreComponent[] {
- if(gamesystem instanceof SimpleGamesystem) {
+ if(gamesystem instanceof SimpleGamesystem || gamesystem instanceof SimpleTemplateGamesystem) {
console.log("Simple Gamesystem")
return [this.serializeSimpleGamesystem(gamesystem as SimpleGamesystem)]
} else {
diff --git a/testModel/characters/Astrid Hofferson.json b/testModel/characters/Astrid Hofferson.json
index c0c32fc..c5a973f 100644
--- a/testModel/characters/Astrid Hofferson.json
+++ b/testModel/characters/Astrid Hofferson.json
@@ -1,5 +1,4 @@
{
"componentName": "Astrid Hofferson",
- "componentDescription": "",
"characterSpecificGamesystems": []
}
\ No newline at end of file
diff --git a/testModel/characters/Hicks Haddock.json b/testModel/characters/Hicks Haddock.json
index e11ab14..30e3fe8 100644
--- a/testModel/characters/Hicks Haddock.json
+++ b/testModel/characters/Hicks Haddock.json
@@ -1,5 +1,26 @@
{
"componentName": "Hicks Haddock",
- "componentDescription": "",
- "characterSpecificGamesystems": []
+ "componentDescription": "Das ist ein Test",
+ "characterSpecificGamesystems": [
+ {
+ "componentName": "Characterstimmung",
+ "states": [
+ {
+ "stateLabel": "Fröhlich",
+ "conditionMap": [
+ {
+ "scriptAccount": "Luftfeuchtigkeit",
+ "minValue": 0,
+ "maxValue": "10"
+ }
+ ]
+ },
+ {
+ "stateLabel": "Wütend",
+ "conditionMap": []
+ }
+ ],
+ "transitions": []
+ }
+ ]
}
\ No newline at end of file
diff --git a/testModel/gamesystems/Characterstimmung.json b/testModel/gamesystems/Characterstimmung.json
index 8ff9ec1..fe49734 100644
--- a/testModel/gamesystems/Characterstimmung.json
+++ b/testModel/gamesystems/Characterstimmung.json
@@ -1,7 +1,20 @@
{
"componentName": "Characterstimmung",
"componentDescription": "",
- "states": [],
+ "states": [
+ {
+ "initial": true,
+ "conditions": [],
+ "stateLabel": "Fröhlich",
+ "stateDescription": ""
+ },
+ {
+ "initial": false,
+ "conditions": [],
+ "stateLabel": "Wütend",
+ "stateDescription": ""
+ }
+ ],
"transitions": [],
- "template": 1
+ "templateType": 1
}
\ No newline at end of file
diff --git a/testModel/gamesystems/Testsystem.json b/testModel/gamesystems/Testsystem.json
index 71ada4d..9c53926 100644
--- a/testModel/gamesystems/Testsystem.json
+++ b/testModel/gamesystems/Testsystem.json
@@ -34,5 +34,5 @@
"endingState": "B"
}
],
- "template": 0
+ "templateType": 0
}
\ No newline at end of file
diff --git a/testModel/gamesystems/Weathersystem/Season.json b/testModel/gamesystems/Weathersystem/Season.json
index 0d38734..246c9ab 100644
--- a/testModel/gamesystems/Weathersystem/Season.json
+++ b/testModel/gamesystems/Weathersystem/Season.json
@@ -77,5 +77,5 @@
"endingState": "Frühling"
}
],
- "template": 0
+ "templateType": 0
}
\ No newline at end of file
diff --git a/testModel/gamesystems/Weathersystem/Weather.json b/testModel/gamesystems/Weathersystem/Weather.json
index 39afb9f..4a0388d 100644
--- a/testModel/gamesystems/Weathersystem/Weather.json
+++ b/testModel/gamesystems/Weathersystem/Weather.json
@@ -77,5 +77,5 @@
"endingState": "Wolke"
}
],
- "template": 0
+ "templateType": 0
}
\ No newline at end of file