CharacterSpecific Templatesystems #36

Merged
sebastian merged 31 commits from template-systems into main 2024-04-14 13:45:04 +02:00
7 changed files with 75 additions and 7 deletions
Showing only changes of commit b178d8595a - Show all commits

View File

@ -1,3 +1,3 @@
<app-simple-gamesystem-editor *ngIf="isSimpleGamesystem()" [simpleGamesystem]="convertGamesystemToSimpleGamesystem()" [scriptAccunts]="scriptAccounts"></app-simple-gamesystem-editor> <app-simple-gamesystem-editor *ngIf="isSimpleGamesystem()" [templateElement]="templateElement" [simpleGamesystem]="convertGamesystemToSimpleGamesystem()" [scriptAccunts]="scriptAccounts"></app-simple-gamesystem-editor>
<app-product-gamesystem-editor *ngIf="!isSimpleGamesystem()" [gamesystem]="convertGamesystemToProductGamesystem()" <app-product-gamesystem-editor *ngIf="!isSimpleGamesystem()" [gamesystem]="convertGamesystemToProductGamesystem()"
(onOpenGamesystemEditor)="onOpenGamesystemEditor($event)"></app-product-gamesystem-editor> (onOpenGamesystemEditor)="onOpenGamesystemEditor($event)"></app-product-gamesystem-editor>

View File

@ -5,6 +5,7 @@ import { Transition } from '../../project/game-model/gamesystems/transitions/Tra
import {ScriptAccount} from "../../project/game-model/scriptAccounts/ScriptAccount"; import {ScriptAccount} from "../../project/game-model/scriptAccounts/ScriptAccount";
import {SimpleGamesystem} from "../../project/game-model/gamesystems/SimpleGamesystem"; import {SimpleGamesystem} from "../../project/game-model/gamesystems/SimpleGamesystem";
import {ProductGamesystem} from "../../project/game-model/gamesystems/ProductGamesystem"; import {ProductGamesystem} from "../../project/game-model/gamesystems/ProductGamesystem";
import {TemplateElement} from "../../project/game-model/templates/TemplateElement";
@Component({ @Component({
selector: 'app-gamesystem-editor', selector: 'app-gamesystem-editor',
@ -15,6 +16,7 @@ export class GamesystemEditorComponent implements OnInit{
@Input() gamesystem: Gamesystem<State<any>, Transition<any>> | undefined @Input() gamesystem: Gamesystem<State<any>, Transition<any>> | undefined
@Input() scriptAccounts: ScriptAccount[] = []; @Input() scriptAccounts: ScriptAccount[] = [];
@Input() templateElement: TemplateElement | undefined
@Output('onOpenGamesystemEditor') openGamesystemEmitter = new EventEmitter<SimpleGamesystem>(); @Output('onOpenGamesystemEditor') openGamesystemEmitter = new EventEmitter<SimpleGamesystem>();
ngOnInit() { ngOnInit() {

View File

@ -1,4 +1,4 @@
<app-simple-state-editor [states]="simpleGamesystem!.states" [gamesystem]="simpleGamesystem" [scriptAccounts]="scriptAccunts"></app-simple-state-editor> <app-simple-state-editor [templateElement]="templateElement" [states]="simpleGamesystem!.states" [gamesystem]="simpleGamesystem" [scriptAccounts]="scriptAccunts"></app-simple-state-editor>
<div id="transition-editor"> <div id="transition-editor">
<app-simple-transition-editor [gamesystem]="simpleGamesystem" [scriptAccounts]="scriptAccunts"></app-simple-transition-editor> <app-simple-transition-editor [gamesystem]="simpleGamesystem" [scriptAccounts]="scriptAccunts"></app-simple-transition-editor>
</div> </div>

View File

@ -2,6 +2,7 @@ import {Component, Input} from '@angular/core';
import {MatTableDataSource} from "@angular/material/table"; import {MatTableDataSource} from "@angular/material/table";
import {SimpleGamesystem} from "../../../project/game-model/gamesystems/SimpleGamesystem"; import {SimpleGamesystem} from "../../../project/game-model/gamesystems/SimpleGamesystem";
import {ScriptAccount} from "../../../project/game-model/scriptAccounts/ScriptAccount"; import {ScriptAccount} from "../../../project/game-model/scriptAccounts/ScriptAccount";
import {TemplateElement} from "../../../project/game-model/templates/TemplateElement";
@Component({ @Component({
selector: 'app-simple-gamesystem-editor', selector: 'app-simple-gamesystem-editor',
@ -12,6 +13,7 @@ export class SimpleGamesystemEditorComponent {
@Input() simpleGamesystem: SimpleGamesystem | undefined @Input() simpleGamesystem: SimpleGamesystem | undefined
@Input() scriptAccunts: ScriptAccount[] = [] @Input() scriptAccunts: ScriptAccount[] = []
@Input() templateElement: TemplateElement | undefined
} }

View File

@ -27,7 +27,7 @@
</mat-form-field> </mat-form-field>
<div class="long-form"> <div class="long-form">
<app-scriptaccount-condition-editor [conditions]="element.conditions" [scriptAccounts]="scriptAccounts" [enableEditiong]="true" <app-scriptaccount-condition-editor [conditions]="getDisplayedConditions(element)" [scriptAccounts]="scriptAccounts" [enableEditiong]="true"
(onCreateCondition)="onCreateCondition(element, $event)" (onDeleteCondition)="deleteCondition(element, $event)"></app-scriptaccount-condition-editor> (onCreateCondition)="onCreateCondition(element, $event)" (onDeleteCondition)="deleteCondition(element, $event)"></app-scriptaccount-condition-editor>
</div> </div>
</div> </div>

View File

@ -6,6 +6,8 @@ import {SimpleState} from "../../../../project/game-model/gamesystems/states/Sim
import {SimpleGamesystem} from "../../../../project/game-model/gamesystems/SimpleGamesystem"; import {SimpleGamesystem} from "../../../../project/game-model/gamesystems/SimpleGamesystem";
import {ScriptAccount} from "../../../../project/game-model/scriptAccounts/ScriptAccount"; import {ScriptAccount} from "../../../../project/game-model/scriptAccounts/ScriptAccount";
import {ScriptAccountCondition} from "../../../../project/game-model/gamesystems/conditions/ScriptAccountCondition"; 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({ @Component({
selector: 'app-simple-state-editor', selector: 'app-simple-state-editor',
@ -24,6 +26,7 @@ export class SimpleStateEditorComponent implements OnInit{
@Input() states: SimpleState[] = []; @Input() states: SimpleState[] = [];
@Input() gamesystem: SimpleGamesystem | undefined @Input() gamesystem: SimpleGamesystem | undefined
@Input() scriptAccounts: ScriptAccount[] = [] @Input() scriptAccounts: ScriptAccount[] = []
@Input() templateElement: TemplateElement | undefined
dataSource = new MatTableDataSource<SimpleState>(); dataSource = new MatTableDataSource<SimpleState>();
displayedColumns = ["name", "initial", "edit", "delete"]; displayedColumns = ["name", "initial", "edit", "delete"];
columnsToDisplayWithExpand = [...this.displayedColumns, 'expand']; columnsToDisplayWithExpand = [...this.displayedColumns, 'expand'];
@ -96,11 +99,29 @@ export class SimpleStateEditorComponent implements OnInit{
} }
onCreateCondition(state: SimpleState, condition: ScriptAccountCondition) { 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) { 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)!
}
} }
} }

View File

@ -1,7 +1,50 @@
{ {
"componentName": "TemplateGamesystem", "componentName": "TemplateGamesystem",
"componentDescription": "", "componentDescription": "",
"states": [], "states": [
"transitions": [], {
"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 "templateType": 0
} }