CharacterSpecific Templatesystems #36
@ -8,7 +8,7 @@
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>{{templateSystem.componentName}}</mat-panel-title>
|
||||
</mat-expansion-panel-header>
|
||||
<app-gamesystem-editor [gamesystem]="templateSystem" [scriptAccounts]="gameModel!.scriptAccounts"></app-gamesystem-editor>
|
||||
<app-gamesystem-editor [templateElement]="character" [gamesystem]="templateSystem" [scriptAccounts]="gameModel!.scriptAccounts"></app-gamesystem-editor>
|
||||
</mat-expansion-panel>
|
||||
</mat-accordion>
|
||||
<button mat-stroked-button class="specify-btn" (click)="openTemplateSpecificator()">Specify Templatesystem</button>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<app-simple-state-editor [templateElement]="templateElement" [states]="simpleGamesystem!.states" [gamesystem]="simpleGamesystem" [scriptAccounts]="scriptAccunts"></app-simple-state-editor>
|
||||
<div id="transition-editor">
|
||||
<app-simple-transition-editor [gamesystem]="simpleGamesystem" [scriptAccounts]="scriptAccunts"></app-simple-transition-editor>
|
||||
<app-simple-transition-editor [templateElement]="templateElement" [gamesystem]="simpleGamesystem" [scriptAccounts]="scriptAccunts"></app-simple-transition-editor>
|
||||
</div>
|
||||
|
@ -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) {
|
||||
|
@ -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<any> | undefined
|
||||
@Input() scriptAccounts: ScriptAccount[] = []
|
||||
@Input() enableEditing: boolean = false;
|
||||
@Input() templateElement: TemplateElement | undefined
|
||||
|
||||
dataSource: MatTableDataSource<ScriptAccountAction> = 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 !== '') {
|
||||
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)
|
||||
console.log(this.addedAction.scriptAccount)
|
||||
this.dataSource.data = this.transition!.scriptAccountActions;
|
||||
console.log(this.dataSource.data.length, this.transition!.scriptAccountActions.length)
|
||||
}
|
||||
|
||||
|
||||
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) {
|
||||
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.transition!.scriptAccountActions
|
||||
}
|
||||
|
||||
this.dataSource.data = this.getDisplayedActions()
|
||||
}
|
||||
}
|
||||
|
@ -42,10 +42,10 @@
|
||||
[@detailExpand]="element == expandedElement ? 'expanded' : 'collapsed'">
|
||||
<div class="condition-action-container">
|
||||
<div class="action-container">
|
||||
<app-scriptaccount-action-editor [transition]="element" [scriptAccounts]="scriptAccounts" [enableEditing]="true"></app-scriptaccount-action-editor>
|
||||
<app-scriptaccount-action-editor [templateElement]="templateElement" [transition]="element" [scriptAccounts]="scriptAccounts" [enableEditing]="true"></app-scriptaccount-action-editor>
|
||||
</div>
|
||||
<div class="condition-container">
|
||||
<app-scriptaccount-condition-editor [conditions]="element.scriptAccountConditions" [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>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -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<SimpleTransition>();
|
||||
columnsToDisplayWithExpand = [...this.displayedColumns, 'expand'];
|
||||
@ -91,10 +97,33 @@ export class SimpleTransitionEditorComponent implements OnInit {
|
||||
protected readonly transition = transition;
|
||||
|
||||
onCreateCondition(transition: SimpleTransition, condition: ScriptAccountCondition) {
|
||||
if(this.templateElement != undefined && transition instanceof SimpleTemplateTransition) {
|
||||
transition.conditionMap.get(this.templateElement)!.push(condition)
|
||||
} else {
|
||||
transition.addScriptAccountCondition(condition);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
deleteCondition(trasition: SimpleTransition, condition: ScriptAccountCondition) {
|
||||
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 [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
{
|
||||
"componentName": "Astrid Hofferson",
|
||||
"componentDescription": ""
|
||||
"componentDescription": "",
|
||||
"characterSpecificTemplateSystems": []
|
||||
}
|
@ -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": []
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user