diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 87fe6af..69fde6f 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -65,6 +65,9 @@ import {MatCard, MatCardContent} from "@angular/material/card";
import {
ScriptaccountActionEditorComponent
} from "./editor/gamesystem-editor/transition-editor/scriptaccount-action-editor/scriptaccount-action-editor.component";
+import {
+ ScriptaccountConditionEditorComponent
+} from "./editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component";
// AoT requires an exported function for factories
const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new TranslateHttpLoader(http, './assets/i18n/', '.json');
@@ -85,7 +88,8 @@ const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new Transl
ProductTransitionEditorComponent,
ProductStateEditorComponent,
ProductGamesystemEditorComponent,
- ScriptaccountActionEditorComponent
+ ScriptaccountActionEditorComponent,
+ ScriptaccountConditionEditorComponent
],
imports: [
BrowserModule,
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
new file mode 100644
index 0000000..654d45f
--- /dev/null
+++ b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.html
@@ -0,0 +1,56 @@
+
diff --git a/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.scss b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.scss
new file mode 100644
index 0000000..e69de29
diff --git a/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.spec.ts b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.spec.ts
new file mode 100644
index 0000000..d833447
--- /dev/null
+++ b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.spec.ts
@@ -0,0 +1,23 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { ScriptaccountConditionEditorComponent } from './scriptaccount-condition-editor.component';
+
+describe('ScriptaccountConditionEditorComponent', () => {
+ let component: ScriptaccountConditionEditorComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ imports: [ScriptaccountConditionEditorComponent]
+ })
+ .compileComponents();
+
+ fixture = TestBed.createComponent(ScriptaccountConditionEditorComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.ts b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.ts
new file mode 100644
index 0000000..2277704
--- /dev/null
+++ b/src/app/editor/gamesystem-editor/scriptaccount-condition-editor/scriptaccount-condition-editor.component.ts
@@ -0,0 +1,49 @@
+import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
+import {ScriptAccountCondition} from "../../../game-model/gamesystems/conditions/ScriptAccountCondition";
+import {MatTableDataSource} from "@angular/material/table";
+import {ScriptAccount} from "../../../game-model/scriptAccounts/ScriptAccount";
+
+@Component({
+ selector: 'app-scriptaccount-condition-editor',
+ templateUrl: './scriptaccount-condition-editor.component.html',
+ styleUrl: './scriptaccount-condition-editor.component.scss'
+})
+export class ScriptaccountConditionEditorComponent implements OnInit{
+
+ @Input() conditions: ScriptAccountCondition[] = []
+ @Input() scriptAccounts: ScriptAccount[] = []
+ @Output() onCreateCondition: EventEmitter = new EventEmitter();
+ @Output() onDeleteCondition: EventEmitter = new EventEmitter();
+
+ dataSource: MatTableDataSource = new MatTableDataSource();
+ displayedColumns = ['scriptAccount', 'minValue', 'maxValue', 'edit', 'delete']
+
+ editedCondition: ScriptAccountCondition | undefined
+ addedCondition: ScriptAccountCondition | undefined
+
+ ngOnInit() {
+ this.dataSource.data = this.conditions.concat();
+ }
+
+ createCondition() {
+ this.addedCondition = ScriptAccountCondition.constructScriptAccountCondition(new ScriptAccount("", ""), 0,0);
+ this.editedCondition = this.addedCondition;
+ this.dataSource.data = this.dataSource.data.concat(this.addedCondition!);
+ console.log(this.dataSource.data.length)
+ console.log(this.conditions.length)
+ }
+
+ finishEditing() {
+ if(this.addedCondition != undefined) {
+ const createdCondition = ScriptAccountCondition.constructScriptAccountCondition(this.addedCondition.scriptAccount, this.addedCondition.minValue, this.addedCondition.maxValue);
+ if(createdCondition != undefined) {
+ this.onCreateCondition.emit(createdCondition);
+ this.conditions.push(createdCondition);
+ this.dataSource.data = this.conditions;
+ }
+ this.addedCondition = undefined;
+ } else {
+ this.editedCondition = undefined;
+ }
+ }
+}
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 837048b..6a08285 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
@@ -41,6 +41,8 @@
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 efa965a..4c0030e 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
@@ -7,6 +7,7 @@ import {SimpleTransition} from "../../../../game-model/gamesystems/transitions/S
import {animate, state, style, transition, trigger} from "@angular/animations";
import {SimpleState} from "../../../../game-model/gamesystems/states/SimpleState";
import {ScriptAccount} from "../../../../game-model/scriptAccounts/ScriptAccount";
+import {ScriptAccountCondition} from "../../../../game-model/gamesystems/conditions/ScriptAccountCondition";
@Component({
selector: 'app-simple-transition-editor',
templateUrl: './simple-transition-editor.component.html',
@@ -86,4 +87,14 @@ export class SimpleTransitionEditorComponent implements OnInit {
const filterValue = (event.target as HTMLInputElement).value;
this.dataSource.filter = filterValue.trim().toLowerCase();
}
+
+ protected readonly transition = transition;
+
+ onCreateCondition(transition: SimpleTransition, condition: ScriptAccountCondition) {
+ transition.addScriptAccountCondition(condition);
+ }
+
+ deleteCondition(trasition: SimpleTransition, condition: ScriptAccountCondition) {
+ trasition.removeScriptAccountCondition(condition.scriptAccount);
+ }
}
diff --git a/src/app/game-model/gamesystems/states/State.ts b/src/app/game-model/gamesystems/states/State.ts
index 234c4ce..d1848f5 100644
--- a/src/app/game-model/gamesystems/states/State.ts
+++ b/src/app/game-model/gamesystems/states/State.ts
@@ -1,4 +1,6 @@
import {Transition} from "../transitions/Transition";
+import {ScriptAccountCondition} from "../conditions/ScriptAccountCondition";
+import {ScriptAccount} from "../../scriptAccounts/ScriptAccount";
export abstract class State> {
@@ -7,6 +9,8 @@ export abstract class State> {
initial: boolean = false;
+ conditions: ScriptAccountCondition[] = [];
+
addIncomingTransition(transition: T) {
this.incomingTransitions.push(transition);
}
@@ -23,5 +27,24 @@ export abstract class State> {
}
+ addScriptAccountCondition(scriptAccountCondition: ScriptAccountCondition) {
+ const existingScriptAccountCondition = this.findScriptAccountConditionByScriptAccount(scriptAccountCondition.scriptAccount);
+ if(existingScriptAccountCondition != undefined) {
+ if(!existingScriptAccountCondition.isContradicting(scriptAccountCondition)) {
+ existingScriptAccountCondition.extendCondition(scriptAccountCondition)
+ }
+ } else {
+ this.conditions.push(scriptAccountCondition);
+ }
+ }
+
+ removeScriptAccountCondition(scriptAccount: ScriptAccount) {
+ this.conditions = this.conditions.filter(condition => condition.scriptAccount !== scriptAccount);
+ }
+
+ findScriptAccountConditionByScriptAccount(scriptAccount: ScriptAccount): ScriptAccountCondition | undefined {
+ return this.conditions.find(condition => condition.scriptAccount === scriptAccount);
+ }
+
abstract equals(state: State>): boolean;
}