From 2a01f45bf62c3a2f0de2688a5cce4297bd78df3b Mon Sep 17 00:00:00 2001 From: sebastian Date: Sun, 2 Jun 2024 19:43:10 +0200 Subject: [PATCH 1/4] Move scriptaccount-action-editor.component to different directory --- src/app/app.module.ts | 2 +- .../scriptaccount-action-editor.component.html | 0 .../scriptaccount-action-editor.component.scss | 0 .../scriptaccount-action-editor.component.spec.ts | 0 .../scriptaccount-action-editor.component.ts | 10 +++++----- 5 files changed, 6 insertions(+), 6 deletions(-) rename src/app/editor/gamesystem-editor/{transition-editor => }/scriptaccount-action-editor/scriptaccount-action-editor.component.html (100%) rename src/app/editor/gamesystem-editor/{transition-editor => }/scriptaccount-action-editor/scriptaccount-action-editor.component.scss (100%) rename src/app/editor/gamesystem-editor/{transition-editor => }/scriptaccount-action-editor/scriptaccount-action-editor.component.spec.ts (100%) rename src/app/editor/gamesystem-editor/{transition-editor => }/scriptaccount-action-editor/scriptaccount-action-editor.component.ts (86%) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 388d61f..219130c 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -64,7 +64,7 @@ import {MatTooltip} from "@angular/material/tooltip"; import {MatCard, MatCardContent, MatCardHeader, MatCardTitle} from "@angular/material/card"; import { ScriptaccountActionEditorComponent -} from "./editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component"; +} from "./editor/gamesystem-editor/scriptaccount-action-editor/scriptaccount-action-editor.component"; import { ScriptaccountConditionEditorComponent } from "./editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component"; diff --git a/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.html b/src/app/editor/gamesystem-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.html similarity index 100% rename from src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.html rename to src/app/editor/gamesystem-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.html diff --git a/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.scss b/src/app/editor/gamesystem-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.scss similarity index 100% rename from src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.scss rename to src/app/editor/gamesystem-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.scss diff --git a/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.spec.ts b/src/app/editor/gamesystem-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.spec.ts similarity index 100% rename from src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.spec.ts rename to src/app/editor/gamesystem-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.spec.ts diff --git a/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.ts b/src/app/editor/gamesystem-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.ts similarity index 86% rename from src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.ts rename to src/app/editor/gamesystem-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.ts index 67ae272..2801dc2 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.ts +++ b/src/app/editor/gamesystem-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.ts @@ -1,12 +1,12 @@ import {Component, Input, OnInit} from '@angular/core'; 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 {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"; +} from "../../../project/game-model/templates/simpleGamesystem/SimpleTemplateTransition"; @Component({ selector: 'app-scriptaccount-action-editor', From e8e3c83b458b8aa11be188a7f46ee8649a0a112a Mon Sep 17 00:00:00 2001 From: sebastian Date: Sun, 2 Jun 2024 19:56:21 +0200 Subject: [PATCH 2/4] Move logic for deleting and adding actions into simple-transition-editor --- .../scriptaccount-action-editor.component.ts | 45 +++++-------------- .../simple-transition-editor.component.html | 3 +- .../simple-transition-editor.component.ts | 30 ++++++++++++- 3 files changed, 41 insertions(+), 37 deletions(-) diff --git a/src/app/editor/gamesystem-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.ts b/src/app/editor/gamesystem-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.ts index 2801dc2..e8ddc69 100644 --- a/src/app/editor/gamesystem-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.ts +++ b/src/app/editor/gamesystem-editor/scriptaccount-action-editor/scriptaccount-action-editor.component.ts @@ -1,4 +1,4 @@ -import {Component, Input, OnInit} from '@angular/core'; +import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; import {MatTableDataSource} from "@angular/material/table"; import {ScriptAccount} from "../../../project/game-model/scriptAccounts/ScriptAccount"; import {Transition} from "../../../project/game-model/gamesystems/transitions/Transition"; @@ -7,6 +7,7 @@ import {TemplateElement} from "../../../project/game-model/templates/TemplateEle import { SimpleTemplateTransition } from "../../../project/game-model/templates/simpleGamesystem/SimpleTemplateTransition"; +import {ScriptAccountCondition} from "../../../project/game-model/gamesystems/conditions/ScriptAccountCondition"; @Component({ selector: 'app-scriptaccount-action-editor', @@ -14,10 +15,11 @@ import { styleUrl: './scriptaccount-action-editor.component.scss' }) export class ScriptaccountActionEditorComponent implements OnInit{ - @Input() transition: Transition | undefined @Input() scriptAccounts: ScriptAccount[] = [] @Input() enableEditing: boolean = false; - @Input() templateElement: TemplateElement | undefined + @Input() actions: ScriptAccountAction[] = [] + @Output() onAddAction: EventEmitter = new EventEmitter(); + @Output() onRemoveAction: EventEmitter = new EventEmitter(); dataSource: MatTableDataSource = new MatTableDataSource(); displayedColumns: string[] = ['scriptAccount', "valueChange", 'edit', 'delete']; @@ -26,7 +28,7 @@ export class ScriptaccountActionEditorComponent implements OnInit{ addedAction: ScriptAccountAction | undefined ngOnInit() { - this.dataSource.data = this.getDisplayedActions() + this.dataSource.data = this.actions @@ -48,42 +50,15 @@ export class ScriptaccountActionEditorComponent implements OnInit{ finishEditing() { if(this.addedAction != undefined && this.addedAction.scriptAccount.componentName !== '') { - 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.onAddAction.emit(this.addedAction); 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) { - 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() + deleteAction(deletedAction: ScriptAccountAction) { + this.dataSource.data = this.dataSource.data.filter(action => action !== deletedAction); + this.onRemoveAction.emit(deletedAction); } } 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 7a57e18..ca299fe 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,7 +42,8 @@ [@detailExpand]="element == expandedElement ? 'expanded' : 'collapsed'">
- +
action.scriptAccount !== currentAction.scriptAccount); + transition.actionMap.set(this.templateElement, updatedActions); + } else { + transition.removeScriptAccountAction(action.scriptAccount); + } + } + + getDisplayedActions(transition: SimpleTransition) { + if(this.templateElement == undefined) { + return transition.scriptAccountActions + } else if(transition instanceof SimpleTemplateTransition) { + return transition.actionMap.get(this.templateElement)! + } else { + return []; + } + } } From 5d4c9a6e58cdbd6b7ca2c26dc903605c02749116 Mon Sep 17 00:00:00 2001 From: Sebastian Boeckelmann Date: Sat, 15 Jun 2024 13:54:13 +0200 Subject: [PATCH 3/4] Include ScriptAccountActions in character-interaction-editor --- .../character-interaction-editor.component.html | 7 +++++-- .../character-interaction-editor.component.ts | 12 ++++++++++++ .../game-model/interactions/AbstractInteraction.ts | 1 + .../project/game-model/interactions/Interaction.ts | 7 +++++++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/app/editor/character-editor/character-interaction-editor/character-interaction-editor.component.html b/src/app/editor/character-editor/character-interaction-editor/character-interaction-editor.component.html index 30c8f4d..cdb366e 100644 --- a/src/app/editor/character-editor/character-interaction-editor/character-interaction-editor.component.html +++ b/src/app/editor/character-editor/character-interaction-editor/character-interaction-editor.component.html @@ -117,13 +117,16 @@ - + Actions - +

Inventory Actions

diff --git a/src/app/editor/character-editor/character-interaction-editor/character-interaction-editor.component.ts b/src/app/editor/character-editor/character-interaction-editor/character-interaction-editor.component.ts index 4385a80..da52e9c 100644 --- a/src/app/editor/character-editor/character-interaction-editor/character-interaction-editor.component.ts +++ b/src/app/editor/character-editor/character-interaction-editor/character-interaction-editor.component.ts @@ -9,6 +9,7 @@ import {Interaction} from "../../../project/game-model/interactions/Interaction" import {Condition} from "../../../project/game-model/interactions/condition/Condition"; import {MatSnackBar} from "@angular/material/snack-bar"; import {ScriptAccountCondition} from "../../../project/game-model/gamesystems/conditions/ScriptAccountCondition"; +import {ScriptAccountAction} from "../../../project/game-model/gamesystems/actions/ScriptAccountAction"; @Component({ selector: 'app-character-interaction-editor', @@ -85,4 +86,15 @@ export class CharacterInteractionEditorComponent implements OnInit{ onDeleteCondition(interaction: AbstractInteraction, condition: ScriptAccountCondition) { interaction!.removeCondition(condition); } + + onAddAction(interaction: AbstractInteraction, action: ScriptAccountAction) { + if(interaction instanceof Interaction) { + interaction.addAction(action); + } + } + onRemoveAction(interaction: AbstractInteraction, action: ScriptAccountAction) { + if(interaction instanceof Interaction) { + interaction.removeAction(action); + } + } } diff --git a/src/app/project/game-model/interactions/AbstractInteraction.ts b/src/app/project/game-model/interactions/AbstractInteraction.ts index e8e8f22..b03d943 100644 --- a/src/app/project/game-model/interactions/AbstractInteraction.ts +++ b/src/app/project/game-model/interactions/AbstractInteraction.ts @@ -3,6 +3,7 @@ import {Condition} from "./condition/Condition"; import {ScriptAccountCondition} from "../gamesystems/conditions/ScriptAccountCondition"; import {InventoryCondition} from "./condition/InventoryCondition"; import {GamesystemCondition} from "./condition/GamesystemCondition"; +import {Action} from "./actions/Action"; export abstract class AbstractInteraction { diff --git a/src/app/project/game-model/interactions/Interaction.ts b/src/app/project/game-model/interactions/Interaction.ts index d83cbd2..0c639e4 100644 --- a/src/app/project/game-model/interactions/Interaction.ts +++ b/src/app/project/game-model/interactions/Interaction.ts @@ -35,4 +35,11 @@ export class Interaction extends AbstractInteraction{ } + addAction(action: Action) { + this.actions.push(action); + } + + removeAction(deletedAction: Action) { + this.actions = this.actions.filter(action => action !== deletedAction); + } } From 224468f08853c5d841e99ce5b5adb7cfc9e1be8a Mon Sep 17 00:00:00 2001 From: Sebastian Boeckelmann Date: Sat, 15 Jun 2024 14:03:18 +0200 Subject: [PATCH 4/4] Include ScriptAccountEditor in ProductTransitionEditor --- .../product-transition-editor.component.html | 3 ++- .../gamesystems/ProductGamesystem/Letter.json | 21 ++++++++++++++++++- .../gamesystems/ProductGamesystem/Number.json | 21 ++++++++++++++++++- 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.html b/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.html index 8861ae6..53e49ca 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.html +++ b/src/app/editor/gamesystem-editor/transition-editor/product-transition-editor/product-transition-editor.component.html @@ -62,7 +62,8 @@
- + +
diff --git a/testModel/gamesystems/ProductGamesystem/Letter.json b/testModel/gamesystems/ProductGamesystem/Letter.json index 024eea1..5f64714 100644 --- a/testModel/gamesystems/ProductGamesystem/Letter.json +++ b/testModel/gamesystems/ProductGamesystem/Letter.json @@ -7,8 +7,27 @@ "conditions": [], "stateLabel": "A", "stateDescription": "" + }, + { + "initial": false, + "conditions": [], + "stateLabel": "B", + "stateDescription": "" + } + ], + "transitions": [ + { + "scriptAccountActions": [ + { + "characterDependency": 2, + "changingValue": 6, + "scriptAccount": "Test" + } + ], + "scriptAccountConditions": [], + "startingState": "A", + "endingState": "B" } ], - "transitions": [], "generateIsolatedStates": false } \ No newline at end of file diff --git a/testModel/gamesystems/ProductGamesystem/Number.json b/testModel/gamesystems/ProductGamesystem/Number.json index a774068..59ae3ac 100644 --- a/testModel/gamesystems/ProductGamesystem/Number.json +++ b/testModel/gamesystems/ProductGamesystem/Number.json @@ -7,8 +7,27 @@ "conditions": [], "stateLabel": "1", "stateDescription": "" + }, + { + "initial": false, + "conditions": [], + "stateLabel": "2", + "stateDescription": "" + } + ], + "transitions": [ + { + "scriptAccountActions": [ + { + "characterDependency": 2, + "changingValue": 5, + "scriptAccount": "Test" + } + ], + "scriptAccountConditions": [], + "startingState": "1", + "endingState": "2" } ], - "transitions": [], "generateIsolatedStates": false } \ No newline at end of file