From cd48a10084743e556b289aada1006e0700ecd504 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sat, 13 Apr 2024 12:30:42 +0200 Subject: [PATCH 01/28] Introduce Basic concept of Templates for SimpleGamesystems and Characters --- app/main.ts | 17 ++++++-- src/app/app.component.ts | 14 ++++--- src/app/project/game-model/GameModel.ts | 22 +++++++++- .../game-model/characters/Character.ts | 3 +- .../game-model/templates/TemplateElement.ts | 2 + .../templates/TemplateGamesystem.ts | 9 ++++ .../game-model/templates/TemplateType.ts | 3 ++ .../templates/TemplateTypeUtilities.ts | 9 ++++ .../SimpleTemplateGamesystem.ts | 41 +++++++++++++++++++ .../simpleGamesystem/SimpleTemplateState.ts | 16 ++++++++ .../SimpleTemplateTransition.ts | 19 +++++++++ testModel/gamesystems/NormalGamesystem.json | 6 +++ testModel/gamesystems/TemplateGamesystem.json | 7 ++++ 13 files changed, 157 insertions(+), 11 deletions(-) create mode 100644 src/app/project/game-model/templates/TemplateElement.ts create mode 100644 src/app/project/game-model/templates/TemplateGamesystem.ts create mode 100644 src/app/project/game-model/templates/TemplateType.ts create mode 100644 src/app/project/game-model/templates/TemplateTypeUtilities.ts create mode 100644 src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateGamesystem.ts create mode 100644 src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateState.ts create mode 100644 src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateTransition.ts create mode 100644 testModel/gamesystems/NormalGamesystem.json create mode 100644 testModel/gamesystems/TemplateGamesystem.json diff --git a/app/main.ts b/app/main.ts index 45b1f1a..449ef21 100644 --- a/app/main.ts +++ b/app/main.ts @@ -64,9 +64,20 @@ function createWindow(): BrowserWindow { submenu: [ { label: "Gamesystem", - click: () => { - win!.webContents.send('context-menu', "new-gamesystem"); - } + submenu: [ + { + label: "Normal", + click: () => { + win!.webContents.send('context-menu', "new-gamesystem-normal"); + } + }, + { + label: "Character", + click: () => { + win!.webContents.send('context-menu', "new-gamesystem-character"); + } + } + ] }, { label: "ScriptAccount", diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 41f2835..010b208 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -24,6 +24,8 @@ import {Character} from "./project/game-model/characters/Character"; import {CharacterOverviewComponent} from "./side-overviews/character-overview/character-overview.component"; import {CharacterSerializer} from "./project/serializer/CharacterSerializer"; import {CharacterParser} from "./project/parser/characterParser/CharacterParser"; +import {TemplateType} from "./project/game-model/templates/TemplateType"; +import {TemplateTypeUtilities} from "./project/game-model/templates/TemplateTypeUtilities"; @Component({ selector: 'app-root', @@ -76,8 +78,9 @@ export class AppComponent implements OnInit{ } else if(message.startsWith("new")) { const splittedMessage = message.split("-"); const modelComponentType = ModelComponentTypeUtillities.fromString(splittedMessage[1]); + const templateType = TemplateTypeUtilities.fromString(splittedMessage[2]); if(modelComponentType != undefined) { - this.onCreateModelComponent(modelComponentType); + this.onCreateModelComponent(modelComponentType, templateType); } else { console.log("[ERROR] [App-Component] Unknown Context-Menu Command!") } @@ -127,10 +130,10 @@ export class AppComponent implements OnInit{ }) } - private onCreateModelComponent(modelComponentType: ModelComponentType) { + private onCreateModelComponent(modelComponentType: ModelComponentType, templateType: TemplateType | undefined) { switch (modelComponentType) { case ModelComponentType.SCRIPTACCOUNT: this.onCreateNewScriptAccount(); break - case ModelComponentType.GAMESYTEM: this.onCreateNewGamesystem(); break + case ModelComponentType.GAMESYTEM: this.onCreateNewGamesystem(templateType); break case ModelComponentType.CHARACTER: this.onCreateNewCharacter(); break } } @@ -144,7 +147,7 @@ export class AppComponent implements OnInit{ } } - private onCreateNewGamesystem() { + private onCreateNewGamesystem(templateType: TemplateType | undefined) { let parentGamesystemName = undefined if(this.openContent != ModelComponentType.GAMESYTEM) { this.openGamesystemsOverview(); @@ -153,7 +156,8 @@ export class AppComponent implements OnInit{ } - const createdGamesystem = this.gameModel!.createGamesystem("New Gamesystem", parentGamesystemName); + //const createdGamesystem = this.gameModel!.createGamesystem("New Gamesystem", parentGamesystemName, templateType); + const createdGamesystem = this.gameModel!.createSimpleGamesystem("New Gamesystem", templateType) if(createdGamesystem != undefined) { this.gamesystemOverview!.refresh(); this.editor?.openGameModelComponent(createdGamesystem); diff --git a/src/app/project/game-model/GameModel.ts b/src/app/project/game-model/GameModel.ts index 8497737..99b96ac 100644 --- a/src/app/project/game-model/GameModel.ts +++ b/src/app/project/game-model/GameModel.ts @@ -6,6 +6,8 @@ import {ProductGamesystem} from "./gamesystems/ProductGamesystem"; import {SimpleGamesystem} from "./gamesystems/SimpleGamesystem"; import {Character} from "./characters/Character"; import {ModelComponentType} from "./ModelComponentType"; +import {TemplateType} from "./templates/TemplateType"; +import {SimpleTemplateGamesystem} from "./templates/simpleGamesystem/SimpleTemplateGamesystem"; export class GameModel { gameModelName: string @@ -45,9 +47,26 @@ export class GameModel { return undefined; } - createGamesystem(gamesystemName: string, parentGamesystemName: string | undefined) { + createSimpleGamesystem(gamesystemName: string, templateType: TemplateType | undefined) { + if(gamesystemName != undefined && this.findGamesystem(gamesystemName) == undefined) { + let simpleGamesystem: SimpleGamesystem + + if(templateType == undefined) { + simpleGamesystem = new SimpleGamesystem(gamesystemName, "") + } else { + simpleGamesystem = new SimpleTemplateGamesystem(gamesystemName, "", templateType) + } + + this.gamesystems.push(simpleGamesystem) + return simpleGamesystem; + } + return undefined; + } + + createGamesystem(gamesystemName: string, parentGamesystemName: string | undefined, templateType: TemplateType | undefined) { if(gamesystemName != undefined && this.findGamesystem(gamesystemName) == undefined) { const simpleGamesystem = new SimpleGamesystem(gamesystemName, ""); + if(parentGamesystemName != undefined) { const parentGamesystem = this.findGamesystem(parentGamesystemName); if(parentGamesystem instanceof SimpleGamesystem) { @@ -61,7 +80,6 @@ export class GameModel { } } else { this.gamesystems.push(simpleGamesystem); - } return simpleGamesystem; } diff --git a/src/app/project/game-model/characters/Character.ts b/src/app/project/game-model/characters/Character.ts index 07acf19..214ef4b 100644 --- a/src/app/project/game-model/characters/Character.ts +++ b/src/app/project/game-model/characters/Character.ts @@ -1,7 +1,8 @@ import {ModelComponent} from "../ModelComponent"; import {ModelComponentType} from "../ModelComponentType"; +import {TemplateElement} from "../templates/TemplateElement"; -export class Character extends ModelComponent{ +export class Character extends ModelComponent implements TemplateElement { constructor(componentName: string, componentDescription: string) { super(componentName, componentDescription, ModelComponentType.CHARACTER); diff --git a/src/app/project/game-model/templates/TemplateElement.ts b/src/app/project/game-model/templates/TemplateElement.ts new file mode 100644 index 0000000..4282a32 --- /dev/null +++ b/src/app/project/game-model/templates/TemplateElement.ts @@ -0,0 +1,2 @@ +export interface TemplateElement { +} diff --git a/src/app/project/game-model/templates/TemplateGamesystem.ts b/src/app/project/game-model/templates/TemplateGamesystem.ts new file mode 100644 index 0000000..ef16f2f --- /dev/null +++ b/src/app/project/game-model/templates/TemplateGamesystem.ts @@ -0,0 +1,9 @@ +import {Gamesystem} from "../gamesystems/Gamesystem"; +import {TemplateElement} from "./TemplateElement"; + +export interface TemplateGamesystem { + + + + addTemplateElement(templateElement: TemplateElement): void; +} diff --git a/src/app/project/game-model/templates/TemplateType.ts b/src/app/project/game-model/templates/TemplateType.ts new file mode 100644 index 0000000..6961052 --- /dev/null +++ b/src/app/project/game-model/templates/TemplateType.ts @@ -0,0 +1,3 @@ +export enum TemplateType { + CHARACTER +} diff --git a/src/app/project/game-model/templates/TemplateTypeUtilities.ts b/src/app/project/game-model/templates/TemplateTypeUtilities.ts new file mode 100644 index 0000000..7efc792 --- /dev/null +++ b/src/app/project/game-model/templates/TemplateTypeUtilities.ts @@ -0,0 +1,9 @@ +import {TemplateType} from "./TemplateType"; + +export class TemplateTypeUtilities { + static fromString(string: string) { + if(string === 'character') { + return TemplateType.CHARACTER + } + } +} diff --git a/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateGamesystem.ts b/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateGamesystem.ts new file mode 100644 index 0000000..42515ac --- /dev/null +++ b/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateGamesystem.ts @@ -0,0 +1,41 @@ +import {SimpleGamesystem} from "../../gamesystems/SimpleGamesystem"; +import {TemplateGamesystem} from "../TemplateGamesystem"; +import {TemplateElement} from "../TemplateElement"; +import {SimpleState} from "../../gamesystems/states/SimpleState"; +import {SimpleTransition} from "../../gamesystems/transitions/SimpleTransition"; +import {state, transition} from "@angular/animations"; +import {SimpleTemplateState} from "./SimpleTemplateState"; +import {SimpleTemplateTransition} from "./SimpleTemplateTransition"; +import {TemplateType} from "../TemplateType"; + +export class SimpleTemplateGamesystem extends SimpleGamesystem implements TemplateGamesystem { + + templateType: TemplateType + + constructor(gamesystemName: string, gamesystemDescription: string, templateType: TemplateType) { + super(gamesystemName, gamesystemDescription); + this.templateType = templateType; + } + + addTemplateElement(templateElement: TemplateElement): void { + this.states.forEach(state => { + (state as SimpleTemplateState).addTemplateElement(templateElement); + }) + + this.transitions.forEach(transition => { + (transition as SimpleTemplateTransition).addTemplateElement(templateElement); + }) + } + + createState(label: string, description: string): SimpleState | undefined { + return new SimpleTemplateState(label, description); + } + + createTransition(startingState: SimpleState, endingState: SimpleState): SimpleTransition | undefined { + return new SimpleTemplateTransition(startingState, endingState) + } + + removeState(state: SimpleState): boolean { + return super.removeState(state); + } +} diff --git a/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateState.ts b/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateState.ts new file mode 100644 index 0000000..b0b4f00 --- /dev/null +++ b/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateState.ts @@ -0,0 +1,16 @@ +import {SimpleState} from "../../gamesystems/states/SimpleState"; +import {TemplateElement} from "../TemplateElement"; +import {ScriptAccountCondition} from "../../gamesystems/conditions/ScriptAccountCondition"; + +export class SimpleTemplateState extends SimpleState { + + conditionMap: Map = new Map(); + + addTemplateElement(templateElement: TemplateElement) { + this.conditionMap.set(templateElement, []) + } + + removeTemplateElement(templateElement: TemplateElement) { + this.conditionMap.delete(templateElement) + } +} diff --git a/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateTransition.ts b/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateTransition.ts new file mode 100644 index 0000000..5fb492f --- /dev/null +++ b/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateTransition.ts @@ -0,0 +1,19 @@ +import {SimpleTransition} from "../../gamesystems/transitions/SimpleTransition"; +import {TemplateElement} from "../TemplateElement"; +import {ScriptAccountCondition} from "../../gamesystems/conditions/ScriptAccountCondition"; +import {ScriptAccountAction} from "../../gamesystems/actions/ScriptAccountAction"; + +export class SimpleTemplateTransition extends SimpleTransition{ + conditionMap: Map = new Map(); + actionMap: Map = new Map(); + + addTemplateElement(templateElement: TemplateElement) { + this.conditionMap.set(templateElement, []) + this.actionMap.set(templateElement, []) + } + + removeTemplateElement(templateElement: TemplateElement) { + this.conditionMap.delete(templateElement) + this.actionMap.delete(templateElement) + } +} diff --git a/testModel/gamesystems/NormalGamesystem.json b/testModel/gamesystems/NormalGamesystem.json new file mode 100644 index 0000000..7525520 --- /dev/null +++ b/testModel/gamesystems/NormalGamesystem.json @@ -0,0 +1,6 @@ +{ + "componentName": "NormalGamesystem", + "componentDescription": "", + "states": [], + "transitions": [] +} \ No newline at end of file diff --git a/testModel/gamesystems/TemplateGamesystem.json b/testModel/gamesystems/TemplateGamesystem.json new file mode 100644 index 0000000..dd2b785 --- /dev/null +++ b/testModel/gamesystems/TemplateGamesystem.json @@ -0,0 +1,7 @@ +{ + "componentName": "TemplateGamesystem", + "componentDescription": "", + "states": [], + "transitions": [], + "templateType": 0 +} \ No newline at end of file From 2c789b4cd0b18c92d422707feb10f5d2462c6f47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sat, 13 Apr 2024 12:34:43 +0200 Subject: [PATCH 02/28] Add States to SimpleTemplateGamesystem --- .../templates/simpleGamesystem/SimpleTemplateGamesystem.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateGamesystem.ts b/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateGamesystem.ts index 42515ac..17856d2 100644 --- a/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateGamesystem.ts +++ b/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateGamesystem.ts @@ -3,7 +3,6 @@ import {TemplateGamesystem} from "../TemplateGamesystem"; import {TemplateElement} from "../TemplateElement"; import {SimpleState} from "../../gamesystems/states/SimpleState"; import {SimpleTransition} from "../../gamesystems/transitions/SimpleTransition"; -import {state, transition} from "@angular/animations"; import {SimpleTemplateState} from "./SimpleTemplateState"; import {SimpleTemplateTransition} from "./SimpleTemplateTransition"; import {TemplateType} from "../TemplateType"; @@ -28,11 +27,13 @@ export class SimpleTemplateGamesystem extends SimpleGamesystem implements Templa } createState(label: string, description: string): SimpleState | undefined { - return new SimpleTemplateState(label, description); + const state = new SimpleTemplateState(label, description); + this.states.push(state) + return state; } createTransition(startingState: SimpleState, endingState: SimpleState): SimpleTransition | undefined { - return new SimpleTemplateTransition(startingState, endingState) + return new SimpleTemplateTransition(startingState, endingState); } removeState(state: SimpleState): boolean { From 7e6dd4aa27dcf8295de690155a2905a217c7334b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sat, 13 Apr 2024 12:38:26 +0200 Subject: [PATCH 03/28] Load TemplateStatus of SimpleTemplateGamesystem --- .../parser/gamesystemParser/GamesystemParser.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/app/project/parser/gamesystemParser/GamesystemParser.ts b/src/app/project/parser/gamesystemParser/GamesystemParser.ts index e085bba..eafbfa8 100644 --- a/src/app/project/parser/gamesystemParser/GamesystemParser.ts +++ b/src/app/project/parser/gamesystemParser/GamesystemParser.ts @@ -6,6 +6,7 @@ import {SimpleGamesystem} from "../../game-model/gamesystems/SimpleGamesystem"; import {StateParser} from "./StateParser"; import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount"; import {TransitionParser} from "./TransitionParser"; +import {SimpleTemplateGamesystem} from "../../game-model/templates/simpleGamesystem/SimpleTemplateGamesystem"; export class GamesystemParser { @@ -40,13 +41,21 @@ export class GamesystemParser { } parseSimpleGamesystem(gamesystemData: any): SimpleGamesystem { - const simpleGamesystem = new SimpleGamesystem(gamesystemData.componentName, gamesystemData.componentDescription) + let simpleGamesystem + if(gamesystemData.templateType != undefined) { + simpleGamesystem = new SimpleTemplateGamesystem(gamesystemData.componentName, gamesystemData.componentDescription, gamesystemData.templateType) + } else { + simpleGamesystem = new SimpleGamesystem(gamesystemData.componentName, gamesystemData.componentDescription) + } + const stateParser = new StateParser(this.scriptAccounts); simpleGamesystem.states = stateParser.parseStates(gamesystemData.states) const transitionParser = new TransitionParser(simpleGamesystem.states, this.scriptAccounts) simpleGamesystem.transitions = transitionParser.parseTransitions(gamesystemData.transitions) + + return simpleGamesystem } From 3c9efa1bd5e251b6843830abc217fe8635441086 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sat, 13 Apr 2024 12:52:55 +0200 Subject: [PATCH 04/28] Add SimpleTemplateSystems to Character --- .../project/game-model/characters/Character.ts | 17 +++++++++++++++++ .../simpleGamesystem/SimpleTemplateState.ts | 2 +- .../SimpleTemplateTransition.ts | 4 ++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/app/project/game-model/characters/Character.ts b/src/app/project/game-model/characters/Character.ts index 214ef4b..8f2fe49 100644 --- a/src/app/project/game-model/characters/Character.ts +++ b/src/app/project/game-model/characters/Character.ts @@ -1,10 +1,27 @@ import {ModelComponent} from "../ModelComponent"; import {ModelComponentType} from "../ModelComponentType"; import {TemplateElement} from "../templates/TemplateElement"; +import {TemplateGamesystem} from "../templates/TemplateGamesystem"; +import {Gamesystem} from "../gamesystems/Gamesystem"; +import {SimpleTemplateGamesystem} from "../templates/simpleGamesystem/SimpleTemplateGamesystem"; export class Character extends ModelComponent implements TemplateElement { + characterSpecificTemplateSystems: Gamesystem[] = [] + constructor(componentName: string, componentDescription: string) { super(componentName, componentDescription, ModelComponentType.CHARACTER); } + + addCharacterSpecificSimpleTemplatesystem(gamesystem: SimpleTemplateGamesystem) { + if(!this.isTemplateSystemCharacterSpecific(gamesystem.componentName)) { + this.characterSpecificTemplateSystems.push(gamesystem) + gamesystem.addTemplateElement(this) + } + } + + private isTemplateSystemCharacterSpecific(gamesystemName: string) { + return this.characterSpecificTemplateSystems.find(gamesystem => gamesystem.componentName === gamesystemName) != undefined + } + } diff --git a/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateState.ts b/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateState.ts index b0b4f00..e603b6d 100644 --- a/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateState.ts +++ b/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateState.ts @@ -7,7 +7,7 @@ export class SimpleTemplateState extends SimpleState { conditionMap: Map = new Map(); addTemplateElement(templateElement: TemplateElement) { - this.conditionMap.set(templateElement, []) + this.conditionMap.set(templateElement, this.conditions) } removeTemplateElement(templateElement: TemplateElement) { diff --git a/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateTransition.ts b/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateTransition.ts index 5fb492f..a9612d5 100644 --- a/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateTransition.ts +++ b/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateTransition.ts @@ -8,8 +8,8 @@ export class SimpleTemplateTransition extends SimpleTransition{ actionMap: Map = new Map(); addTemplateElement(templateElement: TemplateElement) { - this.conditionMap.set(templateElement, []) - this.actionMap.set(templateElement, []) + this.conditionMap.set(templateElement, this.scriptAccountConditions.concat()) + this.actionMap.set(templateElement, this.scriptAccountActions.concat()) } removeTemplateElement(templateElement: TemplateElement) { From 4868495e70ace0cd6d37cc9a31c700208926eb1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sun, 14 Apr 2024 07:50:38 +0200 Subject: [PATCH 05/28] Open TemplateSpecificatir Dialog --- src/app/app.module.ts | 16 ++++++++++--- .../character-editor.component.html | 17 ++++++++++++- .../character-editor.component.scss | 4 ++++ .../character-editor.component.ts | 24 ++++++++++++++++++- src/app/editor/editor.component.html | 5 +++- src/app/editor/editor.component.ts | 7 ++++++ .../template-specificator.component.html | 1 + .../template-specificator.component.scss | 0 .../template-specificator.component.spec.ts | 23 ++++++++++++++++++ .../template-specificator.component.ts | 10 ++++++++ src/app/project/game-model/GameModel.ts | 18 ++++++++++++++ 11 files changed, 119 insertions(+), 6 deletions(-) create mode 100644 src/app/editor/gamesystem-editor/template-specificator/template-specificator.component.html create mode 100644 src/app/editor/gamesystem-editor/template-specificator/template-specificator.component.scss create mode 100644 src/app/editor/gamesystem-editor/template-specificator/template-specificator.component.spec.ts create mode 100644 src/app/editor/gamesystem-editor/template-specificator/template-specificator.component.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 7412843..18a1e78 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -61,7 +61,7 @@ import { ProductStateEditorComponent } from "./editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component"; import {MatTooltip} from "@angular/material/tooltip"; -import {MatCard, MatCardContent} from "@angular/material/card"; +import {MatCard, MatCardContent, MatCardHeader, MatCardTitle} from "@angular/material/card"; import { ScriptaccountActionEditorComponent } from "./editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component"; @@ -70,6 +70,10 @@ import { } from "./editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component"; import {CharacterOverviewComponent} from "./side-overviews/character-overview/character-overview.component"; import {CharacterEditorComponent} from "./editor/character-editor/character-editor.component"; +import {MatAccordion, MatExpansionPanel, MatExpansionPanelTitle} from "@angular/material/expansion"; +import { + TemplateSpecificatorComponent +} from "./editor/gamesystem-editor/template-specificator/template-specificator.component"; // AoT requires an exported function for factories const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new TranslateHttpLoader(http, './assets/i18n/', '.json'); @@ -93,7 +97,8 @@ const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new Transl ScriptaccountActionEditorComponent, ScriptaccountConditionEditorComponent, CharacterOverviewComponent, - CharacterEditorComponent + CharacterEditorComponent, + TemplateSpecificatorComponent ], imports: [ BrowserModule, @@ -150,7 +155,12 @@ const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new Transl MatHint, MatTooltip, MatCard, - MatCardContent + MatCardContent, + MatCardHeader, + MatAccordion, + MatExpansionPanel, + MatExpansionPanelTitle, + MatCardTitle ], providers: [], bootstrap: [AppComponent] diff --git a/src/app/editor/character-editor/character-editor.component.html b/src/app/editor/character-editor/character-editor.component.html index 4750ae3..9fc0955 100644 --- a/src/app/editor/character-editor/character-editor.component.html +++ b/src/app/editor/character-editor/character-editor.component.html @@ -1 +1,16 @@ -

character-editor works!

+ + + Characterspecific Gamesystems + + + + + + {{templateSystem.componentName}} + + + + + + + diff --git a/src/app/editor/character-editor/character-editor.component.scss b/src/app/editor/character-editor/character-editor.component.scss index e69de29..4ce3702 100644 --- a/src/app/editor/character-editor/character-editor.component.scss +++ b/src/app/editor/character-editor/character-editor.component.scss @@ -0,0 +1,4 @@ +.specify-btn { + width: 100%; + margin-top: 10px; +} diff --git a/src/app/editor/character-editor/character-editor.component.ts b/src/app/editor/character-editor/character-editor.component.ts index 23e8438..72bd256 100644 --- a/src/app/editor/character-editor/character-editor.component.ts +++ b/src/app/editor/character-editor/character-editor.component.ts @@ -1,4 +1,11 @@ -import { Component } from '@angular/core'; +import {Component, Input} from '@angular/core'; +import {Character} from "../../project/game-model/characters/Character"; +import {GameModel} from "../../project/game-model/GameModel"; +import {MatDialog} from "@angular/material/dialog"; +import { + TemplateSpecificatorComponent +} from "../gamesystem-editor/template-specificator/template-specificator.component"; +import {TemplateType} from "../../project/game-model/templates/TemplateType"; @Component({ selector: 'app-character-editor', @@ -7,4 +14,19 @@ import { Component } from '@angular/core'; }) export class CharacterEditorComponent { + @Input() character: Character | undefined; + @Input() gameModel: GameModel | undefined; + + constructor(private dialog: MatDialog) { + } + + openTemplateSpecificator() { + const dialogRef = this.dialog.open(TemplateSpecificatorComponent, {data: this.gameModel?.getTemplateSystems(TemplateType.CHARACTER), minWidth: "400px"}); + dialogRef.afterClosed().subscribe(res => { + if(res != undefined) { + this.character!.addCharacterSpecificSimpleTemplatesystem(res); + } + }) + } + } diff --git a/src/app/editor/editor.component.html b/src/app/editor/editor.component.html index b351774..23be637 100644 --- a/src/app/editor/editor.component.html +++ b/src/app/editor/editor.component.html @@ -14,7 +14,10 @@ [gamesystem]="convertModelComponentToGamesystem(modelComponent)" (onOpenGamesystemEditor)="openGameModelComponent($event)" [scriptAccounts]="gameModel!.scriptAccounts"> - + diff --git a/src/app/editor/editor.component.ts b/src/app/editor/editor.component.ts index 887f4d8..50f44b9 100644 --- a/src/app/editor/editor.component.ts +++ b/src/app/editor/editor.component.ts @@ -6,6 +6,7 @@ import {Gamesystem} from "../project/game-model/gamesystems/Gamesystem"; import {State} from "../project/game-model/gamesystems/states/State"; import {Transition} from "../project/game-model/gamesystems/transitions/Transition"; import {ModelComponentType} from "../project/game-model/ModelComponentType"; +import {Character} from "../project/game-model/characters/Character"; @Component({ @@ -50,4 +51,10 @@ export class EditorComponent { } protected readonly ModelComponentType = ModelComponentType; + + convertModelComponentToCharacter(modelComponent: ModelComponent) { + if(modelComponent instanceof Character) + return modelComponent as Character + return undefined; + } } diff --git a/src/app/editor/gamesystem-editor/template-specificator/template-specificator.component.html b/src/app/editor/gamesystem-editor/template-specificator/template-specificator.component.html new file mode 100644 index 0000000..75f749d --- /dev/null +++ b/src/app/editor/gamesystem-editor/template-specificator/template-specificator.component.html @@ -0,0 +1 @@ +

template-specificator works!

diff --git a/src/app/editor/gamesystem-editor/template-specificator/template-specificator.component.scss b/src/app/editor/gamesystem-editor/template-specificator/template-specificator.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/editor/gamesystem-editor/template-specificator/template-specificator.component.spec.ts b/src/app/editor/gamesystem-editor/template-specificator/template-specificator.component.spec.ts new file mode 100644 index 0000000..36c46d3 --- /dev/null +++ b/src/app/editor/gamesystem-editor/template-specificator/template-specificator.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { TemplateSpecificatorComponent } from './template-specificator.component'; + +describe('TemplateSpecificatorComponent', () => { + let component: TemplateSpecificatorComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [TemplateSpecificatorComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(TemplateSpecificatorComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/editor/gamesystem-editor/template-specificator/template-specificator.component.ts b/src/app/editor/gamesystem-editor/template-specificator/template-specificator.component.ts new file mode 100644 index 0000000..df10080 --- /dev/null +++ b/src/app/editor/gamesystem-editor/template-specificator/template-specificator.component.ts @@ -0,0 +1,10 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-template-specificator', + templateUrl: './template-specificator.component.html', + styleUrl: './template-specificator.component.scss' +}) +export class TemplateSpecificatorComponent { + +} diff --git a/src/app/project/game-model/GameModel.ts b/src/app/project/game-model/GameModel.ts index 99b96ac..a50286f 100644 --- a/src/app/project/game-model/GameModel.ts +++ b/src/app/project/game-model/GameModel.ts @@ -133,4 +133,22 @@ export class GameModel { } }) } + + getTemplateSystems(templateType: TemplateType) { + const requestedTemplates: Gamesystem[] = [] + const gamesystemQueue: Gamesystem[] = this.gamesystems.concat(); + while(gamesystemQueue.length > 0) { + const currentGamesystem = gamesystemQueue.shift()!; + + if(currentGamesystem instanceof SimpleTemplateGamesystem && currentGamesystem.templateType === templateType) { + requestedTemplates.push(currentGamesystem) + } + + if(currentGamesystem instanceof ProductGamesystem) { + currentGamesystem.innerGamesystems.forEach(innerGamesystem => gamesystemQueue.push(innerGamesystem)) + } + } + + return requestedTemplates; + } } From 8a993bd93d651a7ef8c6841f734f52cf2a36581c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sun, 14 Apr 2024 07:53:13 +0200 Subject: [PATCH 06/28] Fix unkown component mat-expansion-panel-header (add import) --- src/app/app.module.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 18a1e78..0523803 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -70,7 +70,12 @@ import { } from "./editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component"; import {CharacterOverviewComponent} from "./side-overviews/character-overview/character-overview.component"; import {CharacterEditorComponent} from "./editor/character-editor/character-editor.component"; -import {MatAccordion, MatExpansionPanel, MatExpansionPanelTitle} from "@angular/material/expansion"; +import { + MatAccordion, + MatExpansionPanel, + MatExpansionPanelHeader, + MatExpansionPanelTitle +} from "@angular/material/expansion"; import { TemplateSpecificatorComponent } from "./editor/gamesystem-editor/template-specificator/template-specificator.component"; @@ -160,7 +165,8 @@ const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new Transl MatAccordion, MatExpansionPanel, MatExpansionPanelTitle, - MatCardTitle + MatCardTitle, + MatExpansionPanelHeader ], providers: [], bootstrap: [AppComponent] From 5a2282ddd31f1f31433605ef0bc1685b4f3af809 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sun, 14 Apr 2024 07:57:50 +0200 Subject: [PATCH 07/28] Specify Templatesystem --- .../template-specificator.component.html | 15 ++++++++++++++- .../template-specificator.component.scss | 3 +++ .../template-specificator.component.ts | 18 +++++++++++++++++- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/app/editor/gamesystem-editor/template-specificator/template-specificator.component.html b/src/app/editor/gamesystem-editor/template-specificator/template-specificator.component.html index 75f749d..be2c11a 100644 --- a/src/app/editor/gamesystem-editor/template-specificator/template-specificator.component.html +++ b/src/app/editor/gamesystem-editor/template-specificator/template-specificator.component.html @@ -1 +1,14 @@ -

template-specificator works!

+

Specify Templatesystem

+
+

This will not affect the properties of the Templatesystem itself!

+ + Select Templatesystem + + {{templateSystem.componentName}} + + +
+
+ + +
diff --git a/src/app/editor/gamesystem-editor/template-specificator/template-specificator.component.scss b/src/app/editor/gamesystem-editor/template-specificator/template-specificator.component.scss index e69de29..4e80027 100644 --- a/src/app/editor/gamesystem-editor/template-specificator/template-specificator.component.scss +++ b/src/app/editor/gamesystem-editor/template-specificator/template-specificator.component.scss @@ -0,0 +1,3 @@ +.long-form { + width: 100%; +} diff --git a/src/app/editor/gamesystem-editor/template-specificator/template-specificator.component.ts b/src/app/editor/gamesystem-editor/template-specificator/template-specificator.component.ts index df10080..bd85e38 100644 --- a/src/app/editor/gamesystem-editor/template-specificator/template-specificator.component.ts +++ b/src/app/editor/gamesystem-editor/template-specificator/template-specificator.component.ts @@ -1,4 +1,7 @@ -import { Component } from '@angular/core'; +import {Component, Inject} from '@angular/core'; +import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog"; +import {Gamesystem} from "../../../project/game-model/gamesystems/Gamesystem"; +import {FormControl, Validators} from "@angular/forms"; @Component({ selector: 'app-template-specificator', @@ -7,4 +10,17 @@ import { Component } from '@angular/core'; }) export class TemplateSpecificatorComponent { + templateCtrl: FormControl = new FormControl('', [Validators.required]) + + constructor(private dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public templateSystems: Gamesystem[] = []) { + } + + cancelSpecification() { + this.dialogRef.close() + } + + confirmSpecification() { + this.dialogRef.close(this.templateCtrl.value) + } } From 21bc3297788fee64d5f9cc82354194755185351f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sun, 14 Apr 2024 08:02:59 +0200 Subject: [PATCH 08/28] Persist CharacterspecificTemplatesystems --- .../project/serializer/CharacterSerializer.ts | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/app/project/serializer/CharacterSerializer.ts b/src/app/project/serializer/CharacterSerializer.ts index 4923004..f21213c 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 {SimpleTemplateGamesystem} from "../game-model/templates/simpleGamesystem/SimpleTemplateGamesystem"; +import {Gamesystem} from "../game-model/gamesystems/Gamesystem"; export class CharacterSerializer { + private static ignoredKeys: string[] = ['unsaved', 'type', 'incomingTransitions', 'outgoingTransitions', 'initial', 'conditions', 'stateDescription', 'templateType', 'parentGamesystem'] + public static serializeCharacters(characters: Character[]): StoreComponent[] { const storedCharacters: StoreComponent[] = [] characters.forEach(character => storedCharacters.push(this.serializeSingleCharacter(character))) @@ -13,14 +17,41 @@ export class CharacterSerializer { private static serializeSingleCharacter(character: Character): StoreComponent{ const fileName = character.componentName + const templateGamesystemBackup = character.characterSpecificTemplateSystems.concat(); + character.characterSpecificTemplateSystems = character.characterSpecificTemplateSystems.filter(system => system instanceof SimpleTemplateGamesystem) + console.log("Templatesystem: ", character.characterSpecificTemplateSystems) const jsonString = JSON.stringify(character, (key, value) => { - if(key === 'unsaved' || key === 'type') { + if(value instanceof Gamesystem) { + return { + ...value, + componentDescription: undefined, + parentGamesystem: undefined + } + } + + if(key === 'scriptAccount') { + return value.componentName + } + + if(key === 'conditionMap' || key === 'actionMap') { + if(value.get(character) == undefined) { + return [] + } + return value.get(character) + } + + if(key === 'startingState' || key === 'endingState') { + return value.stateLabel + } + + if(this.ignoredKeys.includes(key)) { return undefined } else { return value; } }, SerializeConstants.JSON_INDENT) + return new StoreComponent(jsonString, fileName, ModelComponentType.CHARACTER); } } From fc77868d421fa13e8a331ad5cb7b3deb75648afe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sun, 14 Apr 2024 08:03:17 +0200 Subject: [PATCH 09/28] Store min and max value of conditions as numbers --- .../scriptaccount-condition-editor.component.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.html b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.html index 0cad14c..e9b79eb 100644 --- a/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.html +++ b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.html @@ -18,7 +18,7 @@ {{condition.minValue}} Minimal Value - + @@ -29,7 +29,7 @@ {{condition.maxValue}} Maximal Value - + From b178d8595a3e230435974972631b1f086976743f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sun, 14 Apr 2024 08:15:32 +0200 Subject: [PATCH 10/28] Display Characterspecific conditions in simple-state-editor --- .../gamesystem-editor.component.html | 2 +- .../gamesystem-editor.component.ts | 2 + .../simple-gamesystem-editor.component.html | 2 +- .../simple-gamesystem-editor.component.ts | 2 + .../simple-state-editor.component.html | 2 +- .../simple-state-editor.component.ts | 25 +++++++++- testModel/gamesystems/TemplateGamesystem.json | 47 ++++++++++++++++++- 7 files changed, 75 insertions(+), 7 deletions(-) diff --git a/src/app/editor/gamesystem-editor/gamesystem-editor.component.html b/src/app/editor/gamesystem-editor/gamesystem-editor.component.html index 2eb564e..0537cf2 100644 --- a/src/app/editor/gamesystem-editor/gamesystem-editor.component.html +++ b/src/app/editor/gamesystem-editor/gamesystem-editor.component.html @@ -1,3 +1,3 @@ - + diff --git a/src/app/editor/gamesystem-editor/gamesystem-editor.component.ts b/src/app/editor/gamesystem-editor/gamesystem-editor.component.ts index f14dda3..2174be0 100644 --- a/src/app/editor/gamesystem-editor/gamesystem-editor.component.ts +++ b/src/app/editor/gamesystem-editor/gamesystem-editor.component.ts @@ -5,6 +5,7 @@ import { Transition } from '../../project/game-model/gamesystems/transitions/Tra import {ScriptAccount} from "../../project/game-model/scriptAccounts/ScriptAccount"; import {SimpleGamesystem} from "../../project/game-model/gamesystems/SimpleGamesystem"; import {ProductGamesystem} from "../../project/game-model/gamesystems/ProductGamesystem"; +import {TemplateElement} from "../../project/game-model/templates/TemplateElement"; @Component({ selector: 'app-gamesystem-editor', @@ -15,6 +16,7 @@ export class GamesystemEditorComponent implements OnInit{ @Input() gamesystem: Gamesystem, Transition> | undefined @Input() scriptAccounts: ScriptAccount[] = []; + @Input() templateElement: TemplateElement | undefined @Output('onOpenGamesystemEditor') openGamesystemEmitter = new EventEmitter(); ngOnInit() { diff --git a/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.html b/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.html index 7d7dc52..2dd2e3b 100644 --- a/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.html +++ b/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.html @@ -1,4 +1,4 @@ - +
diff --git a/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.ts b/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.ts index 36af424..af11955 100644 --- a/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.ts +++ b/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.ts @@ -2,6 +2,7 @@ import {Component, Input} from '@angular/core'; import {MatTableDataSource} from "@angular/material/table"; import {SimpleGamesystem} from "../../../project/game-model/gamesystems/SimpleGamesystem"; import {ScriptAccount} from "../../../project/game-model/scriptAccounts/ScriptAccount"; +import {TemplateElement} from "../../../project/game-model/templates/TemplateElement"; @Component({ selector: 'app-simple-gamesystem-editor', @@ -12,6 +13,7 @@ export class SimpleGamesystemEditorComponent { @Input() simpleGamesystem: SimpleGamesystem | undefined @Input() scriptAccunts: ScriptAccount[] = [] + @Input() templateElement: TemplateElement | undefined } diff --git a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.html b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.html index 4e74bda..c8f2e06 100644 --- a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.html +++ b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.html @@ -27,7 +27,7 @@
-
diff --git a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts index 049814c..6d00617 100644 --- a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts +++ b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts @@ -6,6 +6,8 @@ import {SimpleState} from "../../../../project/game-model/gamesystems/states/Sim import {SimpleGamesystem} from "../../../../project/game-model/gamesystems/SimpleGamesystem"; import {ScriptAccount} from "../../../../project/game-model/scriptAccounts/ScriptAccount"; import {ScriptAccountCondition} from "../../../../project/game-model/gamesystems/conditions/ScriptAccountCondition"; +import {TemplateElement} from "../../../../project/game-model/templates/TemplateElement"; +import {SimpleTemplateState} from "../../../../project/game-model/templates/simpleGamesystem/SimpleTemplateState"; @Component({ selector: 'app-simple-state-editor', @@ -24,6 +26,7 @@ export class SimpleStateEditorComponent implements OnInit{ @Input() states: SimpleState[] = []; @Input() gamesystem: SimpleGamesystem | undefined @Input() scriptAccounts: ScriptAccount[] = [] + @Input() templateElement: TemplateElement | undefined dataSource = new MatTableDataSource(); displayedColumns = ["name", "initial", "edit", "delete"]; columnsToDisplayWithExpand = [...this.displayedColumns, 'expand']; @@ -96,11 +99,29 @@ export class SimpleStateEditorComponent implements OnInit{ } onCreateCondition(state: SimpleState, condition: ScriptAccountCondition) { - state.addScriptAccountCondition(condition); + if(this.templateElement != undefined && state instanceof SimpleTemplateState) { + state.conditionMap.get(this.templateElement)!.push(condition) + } else { + state.addScriptAccountCondition(condition); + } } deleteCondition(state: SimpleState, condition: ScriptAccountCondition) { - state.removeScriptAccountCondition(condition.scriptAccount); + if(this.templateElement != undefined && state instanceof SimpleTemplateState) { + let conditions = state.conditionMap.get(this.templateElement)! + conditions = conditions.filter(currentCondition => condition.scriptAccount !== currentCondition.scriptAccount)!; + state.conditionMap.set(this.templateElement, conditions); + } else { + state.removeScriptAccountCondition(condition.scriptAccount); + } + } + + getDisplayedConditions(state: SimpleState) { + if(this.templateElement == undefined) { + return state.conditions + } else if(state instanceof SimpleTemplateState){ + return (state as SimpleTemplateState).conditionMap.get(this.templateElement)! + } } } diff --git a/testModel/gamesystems/TemplateGamesystem.json b/testModel/gamesystems/TemplateGamesystem.json index dd2b785..0a1da3d 100644 --- a/testModel/gamesystems/TemplateGamesystem.json +++ b/testModel/gamesystems/TemplateGamesystem.json @@ -1,7 +1,50 @@ { "componentName": "TemplateGamesystem", "componentDescription": "", - "states": [], - "transitions": [], + "states": [ + { + "initial": false, + "conditions": [ + { + "scriptAccount": "Luftfeuchtigkeit", + "minValue": 0, + "maxValue": "10" + } + ], + "stateLabel": "A", + "stateDescription": "" + }, + { + "initial": false, + "conditions": [ + { + "scriptAccount": "New ScriptAccount", + "minValue": 0, + "maxValue": 100 + } + ], + "stateLabel": "B", + "stateDescription": "" + } + ], + "transitions": [ + { + "scriptAccountActions": [ + { + "changingValue": 10, + "scriptAccount": "Luftfeuchtigkeit" + } + ], + "scriptAccountConditions": [ + { + "scriptAccount": "Temperature", + "minValue": 0, + "maxValue": 10 + } + ], + "startingState": "A", + "endingState": "B" + } + ], "templateType": 0 } \ No newline at end of file From 877d90171f248d0c0bf5d84c4753b248cf6f2b38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sun, 14 Apr 2024 08:18:25 +0200 Subject: [PATCH 11/28] Add Default DisplayCondition Case --- .../simple-state-editor/simple-state-editor.component.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts index 6d00617..386684e 100644 --- a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts +++ b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts @@ -122,6 +122,8 @@ export class SimpleStateEditorComponent implements OnInit{ return state.conditions } else if(state instanceof SimpleTemplateState){ return (state as SimpleTemplateState).conditionMap.get(this.templateElement)! + } else { + return []; } } } From 26ea30da13cfc02bb136a3c7bf7446ab6871717d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sun, 14 Apr 2024 08:44:26 +0200 Subject: [PATCH 12/28] Load States and Transition as Templates in Templatesystems --- .../ProductSystemGenerator.ts | 4 ---- .../parser/gamesystemParser/GamesystemParser.ts | 4 ++-- .../parser/gamesystemParser/StateParser.ts | 15 +++++++++++---- .../parser/gamesystemParser/TransitionParser.ts | 17 +++++++++++++---- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/app/project/game-model/gamesystems/productSystemGenerator/ProductSystemGenerator.ts b/src/app/project/game-model/gamesystems/productSystemGenerator/ProductSystemGenerator.ts index d84bbb0..a9b3eab 100644 --- a/src/app/project/game-model/gamesystems/productSystemGenerator/ProductSystemGenerator.ts +++ b/src/app/project/game-model/gamesystems/productSystemGenerator/ProductSystemGenerator.ts @@ -114,8 +114,6 @@ export class ProductSystemGenerator { if(generatedTransitions.find(generatedTransition => generatedTransition.startingState.equals(startingState) && generatedTransition.endingState.equals(endingState)) == undefined) { generatedTransitions.push(transition) - } else { - console.log(transition) } } @@ -130,8 +128,6 @@ export class ProductSystemGenerator { if(generatedTransitions.find(generatedTransition => generatedTransition.startingState.equals(startingState) && generatedTransition.endingState.equals(endingState)) == undefined) { generatedTransitions.push(transition) - } else { - console.log(transition) } } } diff --git a/src/app/project/parser/gamesystemParser/GamesystemParser.ts b/src/app/project/parser/gamesystemParser/GamesystemParser.ts index eafbfa8..564d4ce 100644 --- a/src/app/project/parser/gamesystemParser/GamesystemParser.ts +++ b/src/app/project/parser/gamesystemParser/GamesystemParser.ts @@ -50,10 +50,10 @@ export class GamesystemParser { const stateParser = new StateParser(this.scriptAccounts); - simpleGamesystem.states = stateParser.parseStates(gamesystemData.states) + simpleGamesystem.states = stateParser.parseStates(gamesystemData.states, gamesystemData.templateType) const transitionParser = new TransitionParser(simpleGamesystem.states, this.scriptAccounts) - simpleGamesystem.transitions = transitionParser.parseTransitions(gamesystemData.transitions) + simpleGamesystem.transitions = transitionParser.parseTransitions(gamesystemData.transitions, gamesystemData.templateType) return simpleGamesystem diff --git a/src/app/project/parser/gamesystemParser/StateParser.ts b/src/app/project/parser/gamesystemParser/StateParser.ts index 8da602a..1c9cf1f 100644 --- a/src/app/project/parser/gamesystemParser/StateParser.ts +++ b/src/app/project/parser/gamesystemParser/StateParser.ts @@ -2,6 +2,8 @@ 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/templates/TemplateType"; +import {SimpleTemplateState} from "../../game-model/templates/simpleGamesystem/SimpleTemplateState"; export class StateParser { @@ -12,23 +14,28 @@ export class StateParser { this.conditionParser = new ScriptAccountConditionParser(scriptAccounts) } - public parseStates(stateData: any): SimpleState[] { + public parseStates(stateData: any, templateType: TemplateType | undefined): SimpleState[] { const parsedStates: SimpleState[] = [] for(let i=0; i Date: Sun, 14 Apr 2024 08:46:17 +0200 Subject: [PATCH 13/28] Ignore conditionMaps and actionMaps when persisting templatesystems --- src/app/project/serializer/GamesystemSerializer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/project/serializer/GamesystemSerializer.ts b/src/app/project/serializer/GamesystemSerializer.ts index 8ffcafc..311ce30 100644 --- a/src/app/project/serializer/GamesystemSerializer.ts +++ b/src/app/project/serializer/GamesystemSerializer.ts @@ -7,7 +7,7 @@ import {ModelComponentType} from "../game-model/ModelComponentType"; export class GamesystemSerializer { - private static IGNORED_SIMPLE_ATTRIBUTES = ["parentGamesystem", 'incomingTransitions', "outgoingTransitions", "unsaved", "type"] + private static IGNORED_SIMPLE_ATTRIBUTES = ["parentGamesystem", 'incomingTransitions', "outgoingTransitions", "unsaved", "type", "conditionMap", "actionMap"] public static serializeGamesystems(gamesystems: Gamesystem[]): StoreComponent[] { let storedGamesystems: StoreComponent[] = [] From 1f5ed46fed412d1072af280007bd72d239d987a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sun, 14 Apr 2024 09:09:38 +0200 Subject: [PATCH 14/28] Use conditionMaps and actionMaps when TemplateEditing --- .../character-editor.component.html | 2 +- .../simple-gamesystem-editor.component.html | 2 +- .../simple-state-editor.component.ts | 1 + .../scriptaccount-action-editor.component.ts | 46 ++++++++++++++++--- .../simple-transition-editor.component.html | 4 +- .../simple-transition-editor.component.ts | 33 ++++++++++++- testModel/characters/Astrid Hofferson.json | 3 +- testModel/characters/Hicks Haddock.json | 38 ++++++++++++++- 8 files changed, 114 insertions(+), 15 deletions(-) diff --git a/src/app/editor/character-editor/character-editor.component.html b/src/app/editor/character-editor/character-editor.component.html index 9fc0955..b13fddf 100644 --- a/src/app/editor/character-editor/character-editor.component.html +++ b/src/app/editor/character-editor/character-editor.component.html @@ -8,7 +8,7 @@ {{templateSystem.componentName}} - + diff --git a/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.html b/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.html index 2dd2e3b..a7ac8c2 100644 --- a/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.html +++ b/src/app/editor/gamesystem-editor/simple-gamesystem-editor/simple-gamesystem-editor.component.html @@ -1,4 +1,4 @@
- +
diff --git a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts index 386684e..f09ff92 100644 --- a/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts +++ b/src/app/editor/gamesystem-editor/state-editor/simple-state-editor/simple-state-editor.component.ts @@ -43,6 +43,7 @@ export class SimpleStateEditorComponent implements OnInit{ this.dataSource.filterPredicate = (data: SimpleState, filter: string) => { return data.stateLabel.toLowerCase().includes(filter); } + console.log(this.templateElement) } editState(state: SimpleState) { diff --git a/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.ts b/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.ts index e8392ee..67ae272 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.ts +++ b/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.ts @@ -3,6 +3,10 @@ import {MatTableDataSource} from "@angular/material/table"; import {ScriptAccount} from "../../../../project/game-model/scriptAccounts/ScriptAccount"; import {Transition} from "../../../../project/game-model/gamesystems/transitions/Transition"; import {ScriptAccountAction} from "../../../../project/game-model/gamesystems/actions/ScriptAccountAction"; +import {TemplateElement} from "../../../../project/game-model/templates/TemplateElement"; +import { + SimpleTemplateTransition +} from "../../../../project/game-model/templates/simpleGamesystem/SimpleTemplateTransition"; @Component({ selector: 'app-scriptaccount-action-editor', @@ -13,6 +17,7 @@ export class ScriptaccountActionEditorComponent implements OnInit{ @Input() transition: Transition | undefined @Input() scriptAccounts: ScriptAccount[] = [] @Input() enableEditing: boolean = false; + @Input() templateElement: TemplateElement | undefined dataSource: MatTableDataSource = new MatTableDataSource(); displayedColumns: string[] = ['scriptAccount', "valueChange", 'edit', 'delete']; @@ -21,7 +26,9 @@ export class ScriptaccountActionEditorComponent implements OnInit{ addedAction: ScriptAccountAction | undefined ngOnInit() { - this.dataSource.data = this.transition!.scriptAccountActions.map(action => action); + this.dataSource.data = this.getDisplayedActions() + + if(!this.enableEditing) { this.displayedColumns = this.displayedColumns.slice(0, -2); @@ -41,17 +48,42 @@ export class ScriptaccountActionEditorComponent implements OnInit{ finishEditing() { if(this.addedAction != undefined && this.addedAction.scriptAccount.componentName !== '') { - this.transition?.addScriptAccountAction(this.addedAction) - console.log(this.addedAction.scriptAccount) - this.dataSource.data = this.transition!.scriptAccountActions; - console.log(this.dataSource.data.length, this.transition!.scriptAccountActions.length) + if(this.templateElement != undefined && this.transition instanceof SimpleTemplateTransition) { + if(this.transition.actionMap.has(this.templateElement!)) { + this.transition.actionMap.get(this.templateElement!)!.push(this.addedAction) + } else { + this.transition.actionMap.set(this.templateElement!, [this.addedAction]) + } + } else { + this.transition?.addScriptAccountAction(this.addedAction) + } + + + this.dataSource.data = this.getDisplayedActions(); this.addedAction = undefined; } this.editedAction = undefined; } + getDisplayedActions(): ScriptAccountAction[] { + if(this.templateElement == undefined) { + return this.transition!.scriptAccountActions.map(action => action); + } else if(this.transition instanceof SimpleTemplateTransition) { + return this.transition!.actionMap.get(this.templateElement)! + } else { + return [] + } + } + deleteAction(action: ScriptAccountAction) { - this.transition!.removeScriptAccountAction(action.scriptAccount) - this.dataSource.data = this.transition!.scriptAccountActions + if(this.templateElement != undefined && this.transition instanceof SimpleTemplateTransition && this.transition.actionMap.has(this.templateElement!)) { + const updatedAction = this.transition.actionMap.get(this.templateElement)!.filter(currentAction => + currentAction.scriptAccount !== action.scriptAccount) + this.transition.actionMap.set(this.templateElement!, updatedAction) + } else { + this.transition!.removeScriptAccountAction(action.scriptAccount) + } + + this.dataSource.data = this.getDisplayedActions() } } diff --git a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html index 91f3790..7a57e18 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html +++ b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html @@ -42,10 +42,10 @@ [@detailExpand]="element == expandedElement ? 'expanded' : 'collapsed'">
- +
-
diff --git a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts index d26acd6..ceaf686 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts +++ b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts @@ -8,6 +8,10 @@ import {ScriptAccount} from "../../../../project/game-model/scriptAccounts/Scrip import {SimpleTransition} from "../../../../project/game-model/gamesystems/transitions/SimpleTransition"; import {SimpleState} from "../../../../project/game-model/gamesystems/states/SimpleState"; import {ScriptAccountCondition} from "../../../../project/game-model/gamesystems/conditions/ScriptAccountCondition"; +import {TemplateElement} from "../../../../project/game-model/templates/TemplateElement"; +import { + SimpleTemplateTransition +} from "../../../../project/game-model/templates/simpleGamesystem/SimpleTemplateTransition"; @Component({ selector: 'app-simple-transition-editor', templateUrl: './simple-transition-editor.component.html', @@ -24,6 +28,8 @@ export class SimpleTransitionEditorComponent implements OnInit { @Input() gamesystem: SimpleGamesystem | undefined @Input() scriptAccounts: ScriptAccount[] = [] + @Input() templateElement: TemplateElement | undefined + displayedColumns: string[] = ["starting-state", "ending-state", "edit", "delete"]; dataSource = new MatTableDataSource(); columnsToDisplayWithExpand = [...this.displayedColumns, 'expand']; @@ -91,10 +97,33 @@ export class SimpleTransitionEditorComponent implements OnInit { protected readonly transition = transition; onCreateCondition(transition: SimpleTransition, condition: ScriptAccountCondition) { - transition.addScriptAccountCondition(condition); + if(this.templateElement != undefined && transition instanceof SimpleTemplateTransition) { + transition.conditionMap.get(this.templateElement)!.push(condition) + } else { + transition.addScriptAccountCondition(condition); + } + } deleteCondition(trasition: SimpleTransition, condition: ScriptAccountCondition) { - trasition.removeScriptAccountCondition(condition.scriptAccount); + if(this.templateElement != undefined && trasition instanceof SimpleTemplateTransition) { + let updatedConditions = trasition.conditionMap.get(this.templateElement)! + updatedConditions = updatedConditions.filter(currentCondition => condition.scriptAccount !== currentCondition.scriptAccount); + trasition.conditionMap.set(this.templateElement, updatedConditions); + } else { + console.log(this.templateElement) + trasition.removeScriptAccountCondition(condition.scriptAccount); + } + + } + + getDisplayedConditions(transition: SimpleTransition) { + if(this.templateElement == undefined) { + return transition.scriptAccountConditions + } else if(transition instanceof SimpleTemplateTransition) { + return transition.conditionMap.get(this.templateElement)! + } else { + return []; + } } } diff --git a/testModel/characters/Astrid Hofferson.json b/testModel/characters/Astrid Hofferson.json index 0678c2b..9437d7c 100644 --- a/testModel/characters/Astrid Hofferson.json +++ b/testModel/characters/Astrid Hofferson.json @@ -1,4 +1,5 @@ { "componentName": "Astrid Hofferson", - "componentDescription": "" + "componentDescription": "", + "characterSpecificTemplateSystems": [] } \ No newline at end of file diff --git a/testModel/characters/Hicks Haddock.json b/testModel/characters/Hicks Haddock.json index 1e611d7..d929721 100644 --- a/testModel/characters/Hicks Haddock.json +++ b/testModel/characters/Hicks Haddock.json @@ -1,4 +1,40 @@ { "componentName": "Hicks Haddock", - "componentDescription": "" + "componentDescription": "", + "characterSpecificTemplateSystems": [ + { + "componentName": "TemplateGamesystem", + "states": [ + { + "stateLabel": "A", + "conditionMap": [] + }, + { + "stateLabel": "B", + "conditionMap": [] + } + ], + "transitions": [ + { + "scriptAccountActions": [ + { + "changingValue": 10, + "scriptAccount": "Luftfeuchtigkeit" + } + ], + "scriptAccountConditions": [ + { + "scriptAccount": "Temperature", + "minValue": 0, + "maxValue": 10 + } + ], + "startingState": "A", + "endingState": "B", + "conditionMap": [], + "actionMap": [] + } + ] + } + ] } \ No newline at end of file From 70880b28ef88a62babb86a62daf8cc3f35bec8fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sun, 14 Apr 2024 09:11:19 +0200 Subject: [PATCH 15/28] Ignore normal conditions and actions of template-transition when persisting character-specific gamesystems --- src/app/project/serializer/CharacterSerializer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/project/serializer/CharacterSerializer.ts b/src/app/project/serializer/CharacterSerializer.ts index f21213c..210052e 100644 --- a/src/app/project/serializer/CharacterSerializer.ts +++ b/src/app/project/serializer/CharacterSerializer.ts @@ -7,7 +7,7 @@ import {Gamesystem} from "../game-model/gamesystems/Gamesystem"; export class CharacterSerializer { - private static ignoredKeys: string[] = ['unsaved', 'type', 'incomingTransitions', 'outgoingTransitions', 'initial', 'conditions', 'stateDescription', 'templateType', 'parentGamesystem'] + private static ignoredKeys: string[] = ['unsaved', 'type', 'incomingTransitions', 'outgoingTransitions', 'initial', 'conditions', 'stateDescription', 'templateType', 'parentGamesystem', 'scriptAccountActions', 'scriptAccountConditions'] public static serializeCharacters(characters: Character[]): StoreComponent[] { const storedCharacters: StoreComponent[] = [] From df3933d147ba7f282b204ef15623e0976c7813cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sun, 14 Apr 2024 09:28:50 +0200 Subject: [PATCH 16/28] Parse CharacterSpecificTemplatesystems and reassign them to character --- src/app/app.component.ts | 8 +- .../parser/characterParser/CharacterParser.ts | 74 ++++++++++++++++++- 2 files changed, 77 insertions(+), 5 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 010b208..1927ff2 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -26,6 +26,7 @@ import {CharacterSerializer} from "./project/serializer/CharacterSerializer"; import {CharacterParser} from "./project/parser/characterParser/CharacterParser"; import {TemplateType} from "./project/game-model/templates/TemplateType"; import {TemplateTypeUtilities} from "./project/game-model/templates/TemplateTypeUtilities"; +import {SimpleTemplateGamesystem} from "./project/game-model/templates/simpleGamesystem/SimpleTemplateGamesystem"; @Component({ selector: 'app-root', @@ -208,14 +209,13 @@ export class AppComponent implements OnInit{ const gamesystemParser = new GamesystemParser(scriptAccounts); const gamesystems = gamesystemParser.parseStoredGamesystems(storedGameModel.storedGamesystems); - const characterParser = new CharacterParser(); - const characters = characterParser.parseCharacters(storedGameModel.storedCharacters); - gameModel.scriptAccounts = scriptAccounts gameModel.gamesystems = gamesystems gameModel.generateProductSystemContents() - gameModel.characters = characters + const characterTemplateSystems = gameModel.getTemplateSystems(TemplateType.CHARACTER).map(templateSystem => templateSystem as SimpleTemplateGamesystem) + const characterParser = new CharacterParser(characterTemplateSystems, gameModel.scriptAccounts); + gameModel.characters = characterParser.parseCharacters(storedGameModel.storedCharacters) this.gameModel = gameModel; } diff --git a/src/app/project/parser/characterParser/CharacterParser.ts b/src/app/project/parser/characterParser/CharacterParser.ts index 07d7378..0570861 100644 --- a/src/app/project/parser/characterParser/CharacterParser.ts +++ b/src/app/project/parser/characterParser/CharacterParser.ts @@ -1,9 +1,26 @@ import {StoreComponent} from "../../../../../app/storage/StoreComponent"; import {Character} from "../../game-model/characters/Character"; +import {SimpleTemplateGamesystem} from "../../game-model/templates/simpleGamesystem/SimpleTemplateGamesystem"; +import {ScriptAccountActionParser} from "../gamesystemParser/ScriptAccountActionParser"; +import {ScriptAccountConditionParser} from "../gamesystemParser/ScriptAccountConditionParser"; +import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount"; +import {SimpleTemplateState} from "../../game-model/templates/simpleGamesystem/SimpleTemplateState"; +import {SimpleTemplateTransition} from "../../game-model/templates/simpleGamesystem/SimpleTemplateTransition"; export class CharacterParser { + characterSpecificGamesystems: SimpleTemplateGamesystem[] + scriptAccountConditionParser: ScriptAccountConditionParser + scriptAccountActionParser: ScriptAccountActionParser + + constructor(characterSpecificGamesystems: SimpleTemplateGamesystem[], scriptAccounts: ScriptAccount[]) { + this.characterSpecificGamesystems = characterSpecificGamesystems; + this.scriptAccountActionParser = new ScriptAccountActionParser(scriptAccounts); + 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 +28,61 @@ export class CharacterParser { } private parseSingleCharacter(characterData: any): Character { - return new Character(characterData.componentName, characterData.componentDescription); + const character = new Character(characterData.componentName, characterData.componentDescription); + const templateSpecificGamesystems = this.parseCharacterSpecificGamesystems(character, characterData.characterSpecificTemplateSystems); + templateSpecificGamesystems.forEach(system => character.addCharacterSpecificSimpleTemplatesystem(system)) + return character; + } + + private parseCharacterSpecificGamesystems(character: Character, characterSpecificGamesystems: any): SimpleTemplateGamesystem[] { + const result: SimpleTemplateGamesystem[] = [] + for(let i=0; i gamesystem.componentName === componentName) + } + + private findReferencedState(gamesystem: SimpleTemplateGamesystem, stateLabel: string) { + return gamesystem.states.find(state => state.stateLabel === stateLabel); + } + + private findReferencedTransition(gamesystem: SimpleTemplateGamesystem, startingLabel: string, endingLabel: string) { + return gamesystem.transitions.find(transition => transition.startingState.stateLabel === startingLabel && transition.endingState.stateLabel === endingLabel); + } + } From c1070ed1ff2c5e17b334cab2fb65d5c34dcfda14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sun, 14 Apr 2024 09:32:19 +0200 Subject: [PATCH 17/28] Don't override default conditions/actions when loading character specific gamesystem --- .../simpleGamesystem/SimpleTemplateState.ts | 4 ++- .../SimpleTemplateTransition.ts | 10 +++++-- testModel/characters/Hicks Haddock.json | 29 +++++++++---------- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateState.ts b/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateState.ts index e603b6d..50bb918 100644 --- a/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateState.ts +++ b/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateState.ts @@ -7,7 +7,9 @@ export class SimpleTemplateState extends SimpleState { conditionMap: Map = new Map(); addTemplateElement(templateElement: TemplateElement) { - this.conditionMap.set(templateElement, this.conditions) + if(!this.conditionMap.has(templateElement)) { + this.conditionMap.set(templateElement, this.conditions) + } } removeTemplateElement(templateElement: TemplateElement) { diff --git a/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateTransition.ts b/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateTransition.ts index a9612d5..90529ba 100644 --- a/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateTransition.ts +++ b/src/app/project/game-model/templates/simpleGamesystem/SimpleTemplateTransition.ts @@ -8,8 +8,14 @@ export class SimpleTemplateTransition extends SimpleTransition{ actionMap: Map = new Map(); addTemplateElement(templateElement: TemplateElement) { - this.conditionMap.set(templateElement, this.scriptAccountConditions.concat()) - this.actionMap.set(templateElement, this.scriptAccountActions.concat()) + if(!this.conditionMap.has(templateElement)) { + this.conditionMap.set(templateElement, this.scriptAccountConditions.concat()) + } + + if(!this.actionMap.has(templateElement)) { + this.actionMap.set(templateElement, this.scriptAccountActions.concat()) + } + } removeTemplateElement(templateElement: TemplateElement) { diff --git a/testModel/characters/Hicks Haddock.json b/testModel/characters/Hicks Haddock.json index d929721..0ff4204 100644 --- a/testModel/characters/Hicks Haddock.json +++ b/testModel/characters/Hicks Haddock.json @@ -7,28 +7,27 @@ "states": [ { "stateLabel": "A", - "conditionMap": [] + "conditionMap": [ + { + "scriptAccount": "Luftfeuchtigkeit", + "minValue": 0, + "maxValue": "10" + } + ] }, { "stateLabel": "B", - "conditionMap": [] + "conditionMap": [ + { + "scriptAccount": "New ScriptAccount", + "minValue": 0, + "maxValue": 100 + } + ] } ], "transitions": [ { - "scriptAccountActions": [ - { - "changingValue": 10, - "scriptAccount": "Luftfeuchtigkeit" - } - ], - "scriptAccountConditions": [ - { - "scriptAccount": "Temperature", - "minValue": 0, - "maxValue": 10 - } - ], "startingState": "A", "endingState": "B", "conditionMap": [], From eaaac9ec7a2028024ca58470774aac6d754f2961 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sun, 14 Apr 2024 10:09:30 +0200 Subject: [PATCH 18/28] Implement basic ProductTemplateSystem --- .../productGamesystem/ProductTemplateSystem.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts diff --git a/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts b/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts new file mode 100644 index 0000000..f4a2b4b --- /dev/null +++ b/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts @@ -0,0 +1,17 @@ +import {ProductGamesystem} from "../../gamesystems/ProductGamesystem"; +import {TemplateGamesystem} from "../TemplateGamesystem"; +import {TemplateElement} from "../TemplateElement"; +import {ProductState} from "../../gamesystems/states/ProductState"; +import {ProductTransition} from "../../gamesystems/transitions/ProductTransition"; + +export class ProductTemplateSystem extends ProductGamesystem implements TemplateGamesystem{ + + stateMap: Map = new Map(); + transitionMap: Map = new Map() + + addTemplateElement(templateElement: TemplateElement): void { + } + + + +} From 151531f970b5ca3b02a33c76bec4b0e97ca7b7a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sun, 14 Apr 2024 11:14:04 +0200 Subject: [PATCH 19/28] Create ProductTemplatesystems --- src/app/app.component.ts | 9 +++- src/app/project/game-model/GameModel.ts | 46 +++++++++++++++++-- .../gamesystems/ProductGamesystem.ts | 19 +++++--- .../ProductTemplateCreator.ts | 30 ++++++++++++ .../ProductTemplateSystem.ts | 11 ++++- 5 files changed, 102 insertions(+), 13 deletions(-) create mode 100644 src/app/project/game-model/templates/productGamesystem/ProductTemplateCreator.ts diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 1927ff2..6b962e0 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -157,8 +157,13 @@ export class AppComponent implements OnInit{ } - //const createdGamesystem = this.gameModel!.createGamesystem("New Gamesystem", parentGamesystemName, templateType); - const createdGamesystem = this.gameModel!.createSimpleGamesystem("New Gamesystem", templateType) + let createdGamesystem; + if(parentGamesystemName == undefined) { + createdGamesystem = this.gameModel?.createSimpleGamesystem("New Gamesystem", templateType); + } else { + createdGamesystem = this.gameModel!.createSimpleGamesystemWithParent("New Gamesystem", parentGamesystemName, templateType) + } + if(createdGamesystem != undefined) { this.gamesystemOverview!.refresh(); this.editor?.openGameModelComponent(createdGamesystem); diff --git a/src/app/project/game-model/GameModel.ts b/src/app/project/game-model/GameModel.ts index a50286f..b59445a 100644 --- a/src/app/project/game-model/GameModel.ts +++ b/src/app/project/game-model/GameModel.ts @@ -8,6 +8,8 @@ import {Character} from "./characters/Character"; import {ModelComponentType} from "./ModelComponentType"; import {TemplateType} from "./templates/TemplateType"; import {SimpleTemplateGamesystem} from "./templates/simpleGamesystem/SimpleTemplateGamesystem"; +import {ProductTemplateSystem} from "./templates/productGamesystem/ProductTemplateSystem"; +import {ProductTemplateCreator} from "./templates/productGamesystem/ProductTemplateCreator"; export class GameModel { gameModelName: string @@ -47,7 +49,7 @@ export class GameModel { return undefined; } - createSimpleGamesystem(gamesystemName: string, templateType: TemplateType | undefined) { + createSimpleGamesystem(gamesystemName: string, templateType: TemplateType | undefined, pushToTop: boolean = true) { if(gamesystemName != undefined && this.findGamesystem(gamesystemName) == undefined) { let simpleGamesystem: SimpleGamesystem @@ -57,12 +59,48 @@ export class GameModel { simpleGamesystem = new SimpleTemplateGamesystem(gamesystemName, "", templateType) } - this.gamesystems.push(simpleGamesystem) + if(pushToTop) { + this.gamesystems.push(simpleGamesystem) + } return simpleGamesystem; } return undefined; } + createSimpleGamesystemWithParent(gamesystemName: string, parentGamesystemName: string, templateType: TemplateType | undefined) { + const simpleGamesystem = this.createSimpleGamesystem(gamesystemName, templateType, false)!; + + const parentGamesystem = this.findGamesystem(parentGamesystemName) + if(parentGamesystem == undefined) {return undefined} + + let parentProductGamesystem: ProductGamesystem; + if(parentGamesystem instanceof SimpleTemplateGamesystem) { + parentProductGamesystem = ProductTemplateCreator.constructTemplateFromSimpleGamesystem(parentGamesystem, this, templateType!) + } else if(parentGamesystem instanceof SimpleGamesystem) { + if(simpleGamesystem instanceof SimpleTemplateGamesystem) { + parentProductGamesystem = ProductTemplateCreator.constructTemplateFromSimpleGamesystem(parentGamesystem, this, templateType!) + } else { + console.log("Test") + parentProductGamesystem = ProductGamesystem.constructFromSimpleGamesystem(parentGamesystem, this); + console.log(this.gamesystems) + } + } else { + if(simpleGamesystem instanceof SimpleTemplateGamesystem) { + parentProductGamesystem = ProductTemplateCreator.convertProductToTemplate(parentGamesystem as ProductGamesystem, this, templateType!) + } else { + parentProductGamesystem = parentGamesystem as ProductGamesystem + } + + } + + parentProductGamesystem.addChildGamesystem(simpleGamesystem); + simpleGamesystem.parentGamesystem = parentProductGamesystem; + + return simpleGamesystem; + } + + + createGamesystem(gamesystemName: string, parentGamesystemName: string | undefined, templateType: TemplateType | undefined) { if(gamesystemName != undefined && this.findGamesystem(gamesystemName) == undefined) { const simpleGamesystem = new SimpleGamesystem(gamesystemName, ""); @@ -140,7 +178,9 @@ export class GameModel { while(gamesystemQueue.length > 0) { const currentGamesystem = gamesystemQueue.shift()!; - if(currentGamesystem instanceof SimpleTemplateGamesystem && currentGamesystem.templateType === templateType) { + if(currentGamesystem instanceof SimpleTemplateGamesystem && currentGamesystem.templateType === templateType) { + requestedTemplates.push(currentGamesystem) + } else if(currentGamesystem instanceof ProductTemplateSystem && currentGamesystem.templateType === templateType) { requestedTemplates.push(currentGamesystem) } diff --git a/src/app/project/game-model/gamesystems/ProductGamesystem.ts b/src/app/project/game-model/gamesystems/ProductGamesystem.ts index e3e2daf..a7d380f 100644 --- a/src/app/project/game-model/gamesystems/ProductGamesystem.ts +++ b/src/app/project/game-model/gamesystems/ProductGamesystem.ts @@ -9,6 +9,8 @@ import {GameModel} from "../GameModel"; import {ScriptAccountCondition} from "./conditions/ScriptAccountCondition"; import {ScriptAccountAction} from "./actions/ScriptAccountAction"; import {ProductSystemGenerator} from "./productSystemGenerator/ProductSystemGenerator"; +import {TemplateType} from "../templates/TemplateType"; +import {ProductTemplateSystem} from "../templates/productGamesystem/ProductTemplateSystem"; export class ProductGamesystem extends Gamesystem { @@ -16,25 +18,28 @@ export class ProductGamesystem extends Gamesystem 0) { simpleGamesystem.componentName += "(Child)"; - productGamesystem.addChildGamesystem(simpleGamesystem); - simpleGamesystem.parentGamesystem = productGamesystem + this.addChildGamesystem(simpleGamesystem); + simpleGamesystem.parentGamesystem = this } if(parentGamesystem != undefined) { parentGamesystem.removeChildGamesystem(simpleGamesystem); - parentGamesystem.addChildGamesystem(productGamesystem); - productGamesystem.parentGamesystem = parentGamesystem + parentGamesystem.addChildGamesystem(this); + this.parentGamesystem = parentGamesystem } else { gameModel.removeGamesystem(simpleGamesystem); - gameModel.addGamesystem(productGamesystem); + gameModel.addGamesystem(this); } - - return productGamesystem; } createState(innerStates: State[]): ProductState | undefined { diff --git a/src/app/project/game-model/templates/productGamesystem/ProductTemplateCreator.ts b/src/app/project/game-model/templates/productGamesystem/ProductTemplateCreator.ts new file mode 100644 index 0000000..1befc41 --- /dev/null +++ b/src/app/project/game-model/templates/productGamesystem/ProductTemplateCreator.ts @@ -0,0 +1,30 @@ +import {SimpleGamesystem} from "../../gamesystems/SimpleGamesystem"; +import {GameModel} from "../../GameModel"; +import {TemplateType} from "../TemplateType"; +import {ProductTemplateSystem} from "./ProductTemplateSystem"; +import {ProductGamesystem} from "../../gamesystems/ProductGamesystem"; + +export class ProductTemplateCreator { + static constructTemplateFromSimpleGamesystem(simpleGamesystem: SimpleGamesystem, gameModel: GameModel, templateType: TemplateType) { + const productGamesystem = new ProductTemplateSystem(simpleGamesystem.componentName, simpleGamesystem.componentDescription, templateType); + productGamesystem.constructHierarchyFromSimpleGamesystem(simpleGamesystem, gameModel); + return productGamesystem; + } + + static convertProductToTemplate(productGamesystem: ProductGamesystem, gameModel: GameModel, templateType: TemplateType) { + const productTemplate = new ProductTemplateSystem(productGamesystem.componentName, productGamesystem.componentDescription, templateType); + productTemplate.states = productGamesystem.states + productTemplate.transitions = productGamesystem.transitions + productTemplate.innerGamesystems = productGamesystem.innerGamesystems; + productGamesystem.innerGamesystems.forEach(innerGamesystem => innerGamesystem.parentGamesystem = productTemplate); + + if(productGamesystem.parentGamesystem == undefined) { + gameModel.removeGamesystem(productGamesystem) + gameModel.gamesystems.push(productTemplate) + } else { + productTemplate.parentGamesystem = productGamesystem.parentGamesystem; + productGamesystem.parentGamesystem.addChildGamesystem(productTemplate); + } + return productTemplate; + } +} diff --git a/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts b/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts index f4a2b4b..6db77cc 100644 --- a/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts +++ b/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts @@ -3,15 +3,24 @@ import {TemplateGamesystem} from "../TemplateGamesystem"; import {TemplateElement} from "../TemplateElement"; import {ProductState} from "../../gamesystems/states/ProductState"; import {ProductTransition} from "../../gamesystems/transitions/ProductTransition"; +import {SimpleGamesystem} from "../../gamesystems/SimpleGamesystem"; +import {GameModel} from "../../GameModel"; +import {TemplateType} from "../TemplateType"; export class ProductTemplateSystem extends ProductGamesystem implements TemplateGamesystem{ stateMap: Map = new Map(); transitionMap: Map = new Map() + templateType: TemplateType - addTemplateElement(templateElement: TemplateElement): void { + + constructor(gamesystemName: string, gamesystemDescription: string, templateType: TemplateType) { + super(gamesystemName, gamesystemDescription); + this.templateType = templateType; } + addTemplateElement(templateElement: TemplateElement): void { + } } From 21d324d3b241c6f11653f3413231050e12e9ddfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sun, 14 Apr 2024 11:18:23 +0200 Subject: [PATCH 20/28] Persist TemplateType of ProductTemplateSystems --- .../serializer/GamesystemSerializer.ts | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/app/project/serializer/GamesystemSerializer.ts b/src/app/project/serializer/GamesystemSerializer.ts index 311ce30..41ebcf3 100644 --- a/src/app/project/serializer/GamesystemSerializer.ts +++ b/src/app/project/serializer/GamesystemSerializer.ts @@ -4,6 +4,7 @@ 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 {ProductTemplateSystem} from "../game-model/templates/productGamesystem/ProductTemplateSystem"; export class GamesystemSerializer { @@ -59,12 +60,24 @@ export class GamesystemSerializer { storedChildsystems.forEach(storedChildsystem => storedGamesystems.push(storedChildsystem)) }) - const jsonString = { - 'componentName': productGamesystem.componentName, - 'componentDescription': productGamesystem.componentDescription, - 'childsystems': innerGamesystemJsonArray + let jsonString; + if(productGamesystem instanceof ProductTemplateSystem) { + jsonString = { + 'componentName': productGamesystem.componentName, + 'componentDescription': productGamesystem.componentDescription, + 'childsystems': innerGamesystemJsonArray, + 'templateType': productGamesystem.templateType + } + } else { + jsonString = { + 'componentName': productGamesystem.componentName, + 'componentDescription': productGamesystem.componentDescription, + 'childsystems': innerGamesystemJsonArray, + } } + + const storedProductsystem = new StoreComponent(JSON.stringify(jsonString, null, SerializeConstants.JSON_INDENT), fileName, ModelComponentType.GAMESYTEM) storedGamesystems.push(storedProductsystem) From 10a32df8591d7291347b43fc6edf92864d42a77d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sun, 14 Apr 2024 11:20:36 +0200 Subject: [PATCH 21/28] Load Templatetype of ProductTemplateGamesystems --- .../parser/gamesystemParser/GamesystemParser.ts | 9 ++++++++- testModel/gamesystems/Producttest/Letters.json | 7 +++++++ testModel/gamesystems/Producttest/Numbers.json | 6 ++++++ testModel/gamesystems/Producttest/Producttest.json | 13 +++++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 testModel/gamesystems/Producttest/Letters.json create mode 100644 testModel/gamesystems/Producttest/Numbers.json create mode 100644 testModel/gamesystems/Producttest/Producttest.json diff --git a/src/app/project/parser/gamesystemParser/GamesystemParser.ts b/src/app/project/parser/gamesystemParser/GamesystemParser.ts index 564d4ce..0e4ce93 100644 --- a/src/app/project/parser/gamesystemParser/GamesystemParser.ts +++ b/src/app/project/parser/gamesystemParser/GamesystemParser.ts @@ -7,6 +7,7 @@ import {StateParser} from "./StateParser"; import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount"; import {TransitionParser} from "./TransitionParser"; import {SimpleTemplateGamesystem} from "../../game-model/templates/simpleGamesystem/SimpleTemplateGamesystem"; +import {ProductTemplateSystem} from "../../game-model/templates/productGamesystem/ProductTemplateSystem"; export class GamesystemParser { @@ -60,7 +61,13 @@ export class GamesystemParser { } parseProductGamesystem(gamesystemData: any) { - const productGamesystem = new ProductGamesystem(gamesystemData.componentName, gamesystemData.componentDescription); + let productGamesystem; + if(gamesystemData.templateType == undefined) { + productGamesystem = new ProductGamesystem(gamesystemData.componentName, gamesystemData.componentDescription); + } else { + productGamesystem = new ProductTemplateSystem(gamesystemData.componentName, gamesystemData.componentDescription, gamesystemData.templateType) + } + const childsystemNames: string[] = [] for(let i=0; i Date: Sun, 14 Apr 2024 11:35:24 +0200 Subject: [PATCH 22/28] Add related Templatesystem as specified Gamesystems --- .../project/game-model/characters/Character.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/app/project/game-model/characters/Character.ts b/src/app/project/game-model/characters/Character.ts index 8f2fe49..a35e773 100644 --- a/src/app/project/game-model/characters/Character.ts +++ b/src/app/project/game-model/characters/Character.ts @@ -4,6 +4,8 @@ import {TemplateElement} from "../templates/TemplateElement"; import {TemplateGamesystem} from "../templates/TemplateGamesystem"; import {Gamesystem} from "../gamesystems/Gamesystem"; import {SimpleTemplateGamesystem} from "../templates/simpleGamesystem/SimpleTemplateGamesystem"; +import {ProductTemplateSystem} from "../templates/productGamesystem/ProductTemplateSystem"; +import {ProductGamesystem} from "../gamesystems/ProductGamesystem"; export class Character extends ModelComponent implements TemplateElement { @@ -13,10 +15,20 @@ export class Character extends ModelComponent implements TemplateElement { super(componentName, componentDescription, ModelComponentType.CHARACTER); } - addCharacterSpecificSimpleTemplatesystem(gamesystem: SimpleTemplateGamesystem) { + addCharacterSpecificSimpleTemplatesystem(gamesystem: Gamesystem) { if(!this.isTemplateSystemCharacterSpecific(gamesystem.componentName)) { - this.characterSpecificTemplateSystems.push(gamesystem) - gamesystem.addTemplateElement(this) + if(gamesystem instanceof SimpleTemplateGamesystem) { + this.characterSpecificTemplateSystems.push(gamesystem) + gamesystem.addTemplateElement(this) + } else if(gamesystem instanceof ProductTemplateSystem) { + this.characterSpecificTemplateSystems.push(gamesystem) + gamesystem.addTemplateElement(this) + gamesystem.innerGamesystems.forEach(innerGamesystem => this.addCharacterSpecificSimpleTemplatesystem(innerGamesystem)) + } + + if(gamesystem.parentGamesystem != undefined) { + this.addCharacterSpecificSimpleTemplatesystem(gamesystem.parentGamesystem) + } } } From bf5403814ad17e1b9e7a947cada63fdc9377ed56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sun, 14 Apr 2024 11:36:30 +0200 Subject: [PATCH 23/28] Exclude SiblingTemplates to be automatically specified --- src/app/project/game-model/characters/Character.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/project/game-model/characters/Character.ts b/src/app/project/game-model/characters/Character.ts index a35e773..e4161ab 100644 --- a/src/app/project/game-model/characters/Character.ts +++ b/src/app/project/game-model/characters/Character.ts @@ -23,7 +23,6 @@ export class Character extends ModelComponent implements TemplateElement { } else if(gamesystem instanceof ProductTemplateSystem) { this.characterSpecificTemplateSystems.push(gamesystem) gamesystem.addTemplateElement(this) - gamesystem.innerGamesystems.forEach(innerGamesystem => this.addCharacterSpecificSimpleTemplatesystem(innerGamesystem)) } if(gamesystem.parentGamesystem != undefined) { From 4d4efa49c9d4268b172bfc2dd833d92303fa14dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sun, 14 Apr 2024 11:39:39 +0200 Subject: [PATCH 24/28] Exclude SiblingTemplates to be automatically specified only by recursive call --- src/app/project/game-model/characters/Character.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/app/project/game-model/characters/Character.ts b/src/app/project/game-model/characters/Character.ts index e4161ab..4d9bf6c 100644 --- a/src/app/project/game-model/characters/Character.ts +++ b/src/app/project/game-model/characters/Character.ts @@ -15,7 +15,7 @@ export class Character extends ModelComponent implements TemplateElement { super(componentName, componentDescription, ModelComponentType.CHARACTER); } - addCharacterSpecificSimpleTemplatesystem(gamesystem: Gamesystem) { + addCharacterSpecificSimpleTemplatesystem(gamesystem: Gamesystem, recursiveCall: boolean = false) { if(!this.isTemplateSystemCharacterSpecific(gamesystem.componentName)) { if(gamesystem instanceof SimpleTemplateGamesystem) { this.characterSpecificTemplateSystems.push(gamesystem) @@ -23,10 +23,15 @@ export class Character extends ModelComponent implements TemplateElement { } else if(gamesystem instanceof ProductTemplateSystem) { this.characterSpecificTemplateSystems.push(gamesystem) gamesystem.addTemplateElement(this) + + if(!recursiveCall) { + gamesystem.innerGamesystems.forEach(innerGamesystem => this.addCharacterSpecificSimpleTemplatesystem(innerGamesystem, true)) + } + } if(gamesystem.parentGamesystem != undefined) { - this.addCharacterSpecificSimpleTemplatesystem(gamesystem.parentGamesystem) + this.addCharacterSpecificSimpleTemplatesystem(gamesystem.parentGamesystem, true) } } } From 6496bd52c5222fad3676c8a05c87e9c61a15458d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sun, 14 Apr 2024 11:42:45 +0200 Subject: [PATCH 25/28] Persist and Load Characterspecified ProductTemplateSystems --- src/app/project/serializer/CharacterSerializer.ts | 2 +- testModel/characters/Astrid Hofferson.json | 8 +++++++- testModel/characters/Hicks Haddock.json | 5 +++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/app/project/serializer/CharacterSerializer.ts b/src/app/project/serializer/CharacterSerializer.ts index 210052e..bc0d21e 100644 --- a/src/app/project/serializer/CharacterSerializer.ts +++ b/src/app/project/serializer/CharacterSerializer.ts @@ -51,7 +51,7 @@ export class CharacterSerializer { } }, SerializeConstants.JSON_INDENT) - + character.characterSpecificTemplateSystems = templateGamesystemBackup return new StoreComponent(jsonString, fileName, ModelComponentType.CHARACTER); } } diff --git a/testModel/characters/Astrid Hofferson.json b/testModel/characters/Astrid Hofferson.json index 9437d7c..468452a 100644 --- a/testModel/characters/Astrid Hofferson.json +++ b/testModel/characters/Astrid Hofferson.json @@ -1,5 +1,11 @@ { "componentName": "Astrid Hofferson", "componentDescription": "", - "characterSpecificTemplateSystems": [] + "characterSpecificTemplateSystems": [ + { + "componentName": "Letters", + "states": [], + "transitions": [] + } + ] } \ No newline at end of file diff --git a/testModel/characters/Hicks Haddock.json b/testModel/characters/Hicks Haddock.json index 0ff4204..571f2e5 100644 --- a/testModel/characters/Hicks Haddock.json +++ b/testModel/characters/Hicks Haddock.json @@ -34,6 +34,11 @@ "actionMap": [] } ] + }, + { + "componentName": "Letters", + "states": [], + "transitions": [] } ] } \ No newline at end of file From ebd3a541207247d4c79253a6c49d5623507119be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sun, 14 Apr 2024 11:55:06 +0200 Subject: [PATCH 26/28] Display Characterspecific ProductStates --- .../gamesystem-editor.component.html | 2 +- .../product-gamesystem-editor.component.html | 2 +- .../product-gamesystem-editor.component.ts | 2 ++ .../product-state-editor.component.ts | 11 ++++++++++- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/app/editor/gamesystem-editor/gamesystem-editor.component.html b/src/app/editor/gamesystem-editor/gamesystem-editor.component.html index 0537cf2..f4ef23b 100644 --- a/src/app/editor/gamesystem-editor/gamesystem-editor.component.html +++ b/src/app/editor/gamesystem-editor/gamesystem-editor.component.html @@ -1,3 +1,3 @@ - diff --git a/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.html b/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.html index b2d1a1f..7cbbe0c 100644 --- a/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.html +++ b/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.html @@ -1,4 +1,4 @@ - +
diff --git a/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.ts b/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.ts index d1f7f23..29319ca 100644 --- a/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.ts +++ b/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.ts @@ -4,6 +4,7 @@ import { } from "../transition-editor/product-transition-editor/product-transition-editor.component"; import {ProductGamesystem} from "../../../project/game-model/gamesystems/ProductGamesystem"; import {SimpleGamesystem} from "../../../project/game-model/gamesystems/SimpleGamesystem"; +import {TemplateElement} from "../../../project/game-model/templates/TemplateElement"; @@ -15,6 +16,7 @@ import {SimpleGamesystem} from "../../../project/game-model/gamesystems/SimpleGa export class ProductGamesystemEditorComponent { @Input() gamesystem: ProductGamesystem | undefined + @Input() templateElement: TemplateElement | undefined @Output("onOpenGamesystemEditor") openGamesystemEditorEmitter = new EventEmitter(); onOpenGamesystemEditor(gamesystem: SimpleGamesystem) { diff --git a/src/app/editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component.ts b/src/app/editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component.ts index 328928e..066e478 100644 --- a/src/app/editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component.ts +++ b/src/app/editor/gamesystem-editor/state-editor/product-state-editor/product-state-editor.component.ts @@ -8,6 +8,8 @@ import {ProductGamesystem} from "../../../../project/game-model/gamesystems/Prod import {SimpleGamesystem} from "../../../../project/game-model/gamesystems/SimpleGamesystem"; import {ProductState} from "../../../../project/game-model/gamesystems/states/ProductState"; import {State} from "../../../../project/game-model/gamesystems/states/State"; +import {TemplateElement} from "../../../../project/game-model/templates/TemplateElement"; +import {ProductTemplateSystem} from "../../../../project/game-model/templates/productGamesystem/ProductTemplateSystem"; @Component({ selector: 'app-product-state-editor', @@ -24,6 +26,7 @@ import {State} from "../../../../project/game-model/gamesystems/states/State"; export class ProductStateEditorComponent implements OnInit{ @Input() gamesystem: ProductGamesystem | undefined + @Input() templateElement: TemplateElement | undefined @Output('onOpenGamesystemEditor') openGamesystemEditorEmitter = new EventEmitter(); displayedColumns: string[] = []; expandedColumns: string[] = [] @@ -36,7 +39,13 @@ export class ProductStateEditorComponent implements OnInit{ this.generateColumnNamesRecursively(this.gamesystem!, ""); this.displayedColumns.push('Initial'); this.expandedColumns = [...this.displayedColumns, 'expand']; - this.datasource.data = this.gamesystem!.states; + + if(this.templateElement == undefined) { + this.datasource.data = this.gamesystem!.states; + } else if(this.gamesystem instanceof ProductTemplateSystem) { + this.datasource.data = this.gamesystem!.stateMap.get(this.templateElement)! + } + this.datasource.filterPredicate = (data: ProductState, filter: string) => { const leaf_states = LeafGamesystemCalculator.calcLeafStates(data); return leaf_states.some((state) => state.stateLabel.toLowerCase().includes(filter)) From c127a0122f9b33e6a7b067223ec7b82859fa7e46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sun, 14 Apr 2024 11:59:30 +0200 Subject: [PATCH 27/28] Display Characterspecific ProductTransitions --- .../product-gamesystem-editor.component.html | 2 +- .../product-transition-editor.component.ts | 10 ++++- testModel/characters/Astrid Hofferson.json | 45 +++++++++++++++++-- testModel/characters/Hicks Haddock.json | 20 ++++++++- .../gamesystems/Producttest/Letters.json | 24 +++++++++- .../gamesystems/Producttest/Numbers.json | 24 +++++++++- 6 files changed, 114 insertions(+), 11 deletions(-) diff --git a/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.html b/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.html index 7cbbe0c..0eee76f 100644 --- a/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.html +++ b/src/app/editor/gamesystem-editor/product-gamesystem-editor/product-gamesystem-editor.component.html @@ -1,4 +1,4 @@
- +
diff --git a/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.ts b/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.ts index 2f164d6..6c12eec 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.ts +++ b/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.ts @@ -8,6 +8,8 @@ import {ProductGamesystem} from "../../../../project/game-model/gamesystems/Prod import {SimpleGamesystem} from "../../../../project/game-model/gamesystems/SimpleGamesystem"; import {ProductTransition} from "../../../../project/game-model/gamesystems/transitions/ProductTransition"; import {ProductState} from "../../../../project/game-model/gamesystems/states/ProductState"; +import {TemplateElement} from "../../../../project/game-model/templates/TemplateElement"; +import {ProductTemplateSystem} from "../../../../project/game-model/templates/productGamesystem/ProductTemplateSystem"; class DisplayedColumnName { displayedName: string internalName: string @@ -34,6 +36,7 @@ export class ProductTransitionEditorComponent implements OnInit{ @Input() gamesystem: ProductGamesystem | undefined @Output() onOpenGamesystem = new EventEmitter(); + @Input() templateElement: TemplateElement | undefined dataSource = new MatTableDataSource(); displayedColumns: DisplayedColumnName[] = []; @@ -52,7 +55,12 @@ export class ProductTransitionEditorComponent implements OnInit{ this.columns = this.displayedColumns.map(column => column.internalName) this.columnsToDisplayWithExpand = [...this.columns, 'expand'] - this.dataSource.data = this.gamesystem.transitions; + if(this.templateElement == undefined) { + this.dataSource.data = this.gamesystem.transitions; + } else if(this.gamesystem instanceof ProductTemplateSystem){ + this.dataSource.data = this.gamesystem!.transitionMap.get(this.templateElement)! + } + this.dataSource.filterPredicate = (data: ProductTransition, filter: string) => { const leaf_starting_states = LeafGamesystemCalculator.calcLeafStates(data.startingState); const leaf_ending_states = LeafGamesystemCalculator.calcLeafStates(data.endingState); diff --git a/testModel/characters/Astrid Hofferson.json b/testModel/characters/Astrid Hofferson.json index 468452a..014ec69 100644 --- a/testModel/characters/Astrid Hofferson.json +++ b/testModel/characters/Astrid Hofferson.json @@ -3,9 +3,48 @@ "componentDescription": "", "characterSpecificTemplateSystems": [ { - "componentName": "Letters", - "states": [], - "transitions": [] + "componentName": "TemplateGamesystem", + "states": [ + { + "stateLabel": "A", + "conditionMap": [ + { + "scriptAccount": "Luftfeuchtigkeit", + "minValue": 0, + "maxValue": "10" + } + ] + }, + { + "stateLabel": "B", + "conditionMap": [ + { + "scriptAccount": "New ScriptAccount", + "minValue": 0, + "maxValue": 100 + } + ] + } + ], + "transitions": [ + { + "startingState": "A", + "endingState": "B", + "conditionMap": [ + { + "scriptAccount": "Temperature", + "minValue": 0, + "maxValue": 10 + } + ], + "actionMap": [ + { + "changingValue": 10, + "scriptAccount": "Luftfeuchtigkeit" + } + ] + } + ] } ] } \ No newline at end of file diff --git a/testModel/characters/Hicks Haddock.json b/testModel/characters/Hicks Haddock.json index 571f2e5..158b912 100644 --- a/testModel/characters/Hicks Haddock.json +++ b/testModel/characters/Hicks Haddock.json @@ -37,8 +37,24 @@ }, { "componentName": "Letters", - "states": [], - "transitions": [] + "states": [ + { + "stateLabel": "A", + "conditionMap": [] + }, + { + "stateLabel": "B", + "conditionMap": [] + } + ], + "transitions": [ + { + "startingState": "A", + "endingState": "B", + "conditionMap": [], + "actionMap": [] + } + ] } ] } \ No newline at end of file diff --git a/testModel/gamesystems/Producttest/Letters.json b/testModel/gamesystems/Producttest/Letters.json index 4be751b..9bab958 100644 --- a/testModel/gamesystems/Producttest/Letters.json +++ b/testModel/gamesystems/Producttest/Letters.json @@ -1,7 +1,27 @@ { "componentName": "Letters", "componentDescription": "", - "states": [], - "transitions": [], + "states": [ + { + "initial": false, + "conditions": [], + "stateLabel": "A", + "stateDescription": "" + }, + { + "initial": false, + "conditions": [], + "stateLabel": "B", + "stateDescription": "" + } + ], + "transitions": [ + { + "scriptAccountActions": [], + "scriptAccountConditions": [], + "startingState": "A", + "endingState": "B" + } + ], "templateType": 0 } \ No newline at end of file diff --git a/testModel/gamesystems/Producttest/Numbers.json b/testModel/gamesystems/Producttest/Numbers.json index 5c9bd28..89f1e28 100644 --- a/testModel/gamesystems/Producttest/Numbers.json +++ b/testModel/gamesystems/Producttest/Numbers.json @@ -1,6 +1,26 @@ { "componentName": "Numbers", "componentDescription": "", - "states": [], - "transitions": [] + "states": [ + { + "initial": false, + "conditions": [], + "stateLabel": "1", + "stateDescription": "" + }, + { + "initial": false, + "conditions": [], + "stateLabel": "2", + "stateDescription": "" + } + ], + "transitions": [ + { + "scriptAccountActions": [], + "scriptAccountConditions": [], + "startingState": "1", + "endingState": "2" + } + ] } \ No newline at end of file From 42388de905498340bdb3940cb763df58830c0534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ckelmann?= Date: Sun, 14 Apr 2024 12:25:23 +0200 Subject: [PATCH 28/28] Generate States and Transition Template Specific --- .../ProductSystemGenerator.ts | 30 ++++++++--- .../TemplateProductSystemGenerator.ts | 54 +++++++++++++++++++ .../ProductTemplateSystem.ts | 4 +- 3 files changed, 80 insertions(+), 8 deletions(-) create mode 100644 src/app/project/game-model/gamesystems/productSystemGenerator/TemplateProductSystemGenerator.ts diff --git a/src/app/project/game-model/gamesystems/productSystemGenerator/ProductSystemGenerator.ts b/src/app/project/game-model/gamesystems/productSystemGenerator/ProductSystemGenerator.ts index a9b3eab..816533b 100644 --- a/src/app/project/game-model/gamesystems/productSystemGenerator/ProductSystemGenerator.ts +++ b/src/app/project/game-model/gamesystems/productSystemGenerator/ProductSystemGenerator.ts @@ -8,6 +8,7 @@ import {ProductGeneratorResult} from "./ProductGeneratorResult"; import {Gamesystem} from "../Gamesystem"; import {ProductGenerationData} from "./ProductGenerationData"; import {ProductTransition} from "../transitions/ProductTransition"; +import {SimpleTemplateTransition} from "../../templates/simpleGamesystem/SimpleTemplateTransition"; export class ProductSystemGenerator { productGamesystem: ProductGamesystem @@ -109,8 +110,8 @@ export class ProductSystemGenerator { protected generateBinaryProductTransition(startingState: ProductState, endingState: ProductState, usedTransition: Transition, generatedTransitions: ProductTransition[]) { const transition = new ProductTransition(startingState, endingState); - transition.scriptAccountActions = [... usedTransition.scriptAccountActions]; - transition.scriptAccountConditions = [... usedTransition.scriptAccountConditions]; + transition.scriptAccountActions = [... this.getTransitionActions(usedTransition)]; + transition.scriptAccountConditions = [... this.getTransitionConditions(usedTransition)]; if(generatedTransitions.find(generatedTransition => generatedTransition.startingState.equals(startingState) && generatedTransition.endingState.equals(endingState)) == undefined) { generatedTransitions.push(transition) @@ -118,13 +119,13 @@ export class ProductSystemGenerator { } protected generateBinaryProductTransitionMulti(startingState: ProductState, endingState: ProductState, leftTransition: Transition, rightTransition: Transition, generatedTransitions: ProductTransition[]) { - const leftConditions = leftTransition.scriptAccountConditions; - const rightConditions = rightTransition.scriptAccountConditions; + const leftConditions = this.getTransitionConditions(leftTransition) + const rightConditions = this.getTransitionConditions(rightTransition) if(!this.contradictCombinedConditions(leftConditions, rightConditions)) { const transition = new ProductTransition(startingState, endingState) - transition.scriptAccountActions = this.generateCombinedActions(leftTransition.scriptAccountActions, rightTransition.scriptAccountActions); - transition.scriptAccountConditions = this.generateCombinedConditions(leftTransition.scriptAccountConditions, rightTransition.scriptAccountConditions); + transition.scriptAccountActions = this.generateCombinedActions(this.getTransitionActions(leftTransition), this.getTransitionActions(rightTransition)); + transition.scriptAccountConditions = this.generateCombinedConditions(this.getTransitionConditions(leftTransition), this.getTransitionConditions(rightTransition)); if(generatedTransitions.find(generatedTransition => generatedTransition.startingState.equals(startingState) && generatedTransition.endingState.equals(endingState)) == undefined) { generatedTransitions.push(transition) @@ -133,7 +134,10 @@ export class ProductSystemGenerator { } protected generateBinaryProductState(leftState: State, rightState: State, generatedStates: ProductState[]): ProductState | undefined { - const combinedStateConditions: ScriptAccountCondition[] = leftState.conditions.concat(rightState.conditions); + const leftConditions = this.getStateConditions(leftState) + const rightConditions = this.getStateConditions(rightState) + + const combinedStateConditions: ScriptAccountCondition[] = leftConditions.concat(rightConditions) for(let i=0; i) { + return transition.scriptAccountConditions; + } + + protected getTransitionActions(transition: Transition) { + return transition.scriptAccountActions; + } + + protected getStateConditions(state: State) { + return state.conditions; + } + } diff --git a/src/app/project/game-model/gamesystems/productSystemGenerator/TemplateProductSystemGenerator.ts b/src/app/project/game-model/gamesystems/productSystemGenerator/TemplateProductSystemGenerator.ts new file mode 100644 index 0000000..9a7915d --- /dev/null +++ b/src/app/project/game-model/gamesystems/productSystemGenerator/TemplateProductSystemGenerator.ts @@ -0,0 +1,54 @@ +import {ProductSystemGenerator} from "./ProductSystemGenerator"; +import {ProductGeneratorResult} from "./ProductGeneratorResult"; +import {TemplateElement} from "../../templates/TemplateElement"; +import {ProductTemplateSystem} from "../../templates/productGamesystem/ProductTemplateSystem"; +import {ProductState} from "../states/ProductState"; +import {Transition} from "../transitions/Transition"; +import {ProductTransition} from "../transitions/ProductTransition"; +import {State} from "../states/State"; +import {SimpleTemplateTransition} from "../../templates/simpleGamesystem/SimpleTemplateTransition"; +import {state, transition} from "@angular/animations"; +import {ScriptAccountCondition} from "../conditions/ScriptAccountCondition"; +import {SimpleTemplateState} from "../../templates/simpleGamesystem/SimpleTemplateState"; + +export class TemplateProductSystemGenerator extends ProductSystemGenerator { + + templateElement: TemplateElement + + + constructor(productGamesystem: ProductTemplateSystem, templateElement: TemplateElement) { + super(productGamesystem); + this.templateElement = templateElement; + } + + protected assignGeneratedStatesAndTransitions(generationResult: ProductGeneratorResult) { + const productTemplateSystem = this.productGamesystem as ProductTemplateSystem + productTemplateSystem.transitionMap.set(this.templateElement, generationResult.transitions) + productTemplateSystem.stateMap.set(this.templateElement, generationResult.states) + } + + protected getTransitionConditions(transition: Transition) { + if(transition instanceof SimpleTemplateTransition) { + return transition.conditionMap.get(this.templateElement)! + } else { + return transition.scriptAccountConditions; + } + } + + protected getTransitionActions(transition: Transition) { + if(transition instanceof SimpleTemplateTransition) { + return transition.actionMap.get(this.templateElement)! + } else { + return transition.scriptAccountActions; + } + } + + + protected getStateConditions(state: State): ScriptAccountCondition[] { + if(state instanceof SimpleTemplateState) { + return state.conditionMap.get(this.templateElement)! + } else { + return state.conditions + } + } +} diff --git a/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts b/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts index 6db77cc..e6957fd 100644 --- a/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts +++ b/src/app/project/game-model/templates/productGamesystem/ProductTemplateSystem.ts @@ -6,6 +6,7 @@ import {ProductTransition} from "../../gamesystems/transitions/ProductTransition import {SimpleGamesystem} from "../../gamesystems/SimpleGamesystem"; import {GameModel} from "../../GameModel"; import {TemplateType} from "../TemplateType"; +import {TemplateProductSystemGenerator} from "../../gamesystems/productSystemGenerator/TemplateProductSystemGenerator"; export class ProductTemplateSystem extends ProductGamesystem implements TemplateGamesystem{ @@ -20,7 +21,8 @@ export class ProductTemplateSystem extends ProductGamesystem implements Template } addTemplateElement(templateElement: TemplateElement): void { - + const productTemplateGenerator = new TemplateProductSystemGenerator(this, templateElement); + productTemplateGenerator.generateFromChildsystems() } }