alt-templatesystem-impl #29
@ -6,7 +6,9 @@
|
||||
<mat-accordion>
|
||||
<mat-expansion-panel *ngFor="let gamesystem of character!.characterSpecificGamesystems">
|
||||
<mat-expansion-panel-header>{{gamesystem.componentName}}</mat-expansion-panel-header>
|
||||
<app-gamesystem-editor [scriptAccounts]="gameModel!.scriptAccounts" [gamesystem]="gamesystem" [templateReference]="character!"></app-gamesystem-editor>
|
||||
</mat-expansion-panel>
|
||||
|
||||
</mat-accordion>
|
||||
<button mat-stroked-button style="width: 100%; margin-top: 10px" (click)="onOpenTemplateCreator()">Add Gamesystem</button>
|
||||
</mat-card-content>
|
||||
|
@ -1,10 +1,4 @@
|
||||
<mat-form-field appearance="fill">
|
||||
<mat-label>Templatetype</mat-label>
|
||||
<mat-select [(ngModel)]="gamesystem!.template">
|
||||
<mat-option [value]="TemplateType.NONE">None</mat-option>
|
||||
<mat-option [value]="TemplateType.CHARACTER">Character</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<app-simple-gamesystem-editor *ngIf="isSimpleGamesystem()" [simpleGamesystem]="convertGamesystemToSimpleGamesystem()" [scriptAccunts]="scriptAccounts"></app-simple-gamesystem-editor>
|
||||
<app-simple-gamesystem-editor *ngIf="isSimpleGamesystem()" [simpleGamesystem]="convertGamesystemToSimpleGamesystem()" [scriptAccunts]="scriptAccounts"
|
||||
[templateReference]="templateReference"></app-simple-gamesystem-editor>
|
||||
<app-product-gamesystem-editor *ngIf="!isSimpleGamesystem()" [gamesystem]="convertGamesystemToProductGamesystem()"
|
||||
(onOpenGamesystemEditor)="onOpenGamesystemEditor($event)"></app-product-gamesystem-editor>
|
||||
|
@ -6,6 +6,7 @@ import {ScriptAccount} from "../../project/game-model/scriptAccounts/ScriptAccou
|
||||
import {SimpleGamesystem} from "../../project/game-model/gamesystems/SimpleGamesystem";
|
||||
import {ProductGamesystem} from "../../project/game-model/gamesystems/ProductGamesystem";
|
||||
import {SimpleTemplateGamesystem} from "../../project/game-model/gamesystems/SimpleTemplateGamesystem";
|
||||
import {Character} from "../../project/game-model/characters/Character";
|
||||
|
||||
@Component({
|
||||
selector: 'app-gamesystem-editor',
|
||||
@ -16,6 +17,7 @@ export class GamesystemEditorComponent implements OnInit{
|
||||
|
||||
@Input() gamesystem: Gamesystem<State<any>, Transition<any>> | undefined
|
||||
@Input() scriptAccounts: ScriptAccount[] = [];
|
||||
@Input() templateReference: Character | undefined
|
||||
@Output('onOpenGamesystemEditor') openGamesystemEmitter = new EventEmitter<SimpleGamesystem>();
|
||||
|
||||
ngOnInit() {
|
||||
|
@ -1,4 +1,4 @@
|
||||
<app-simple-state-editor [states]="simpleGamesystem!.states" [gamesystem]="simpleGamesystem" [scriptAccounts]="scriptAccunts"></app-simple-state-editor>
|
||||
<app-simple-state-editor [states]="simpleGamesystem!.states" [gamesystem]="simpleGamesystem" [scriptAccounts]="scriptAccunts" [templateReference]="templateReference"></app-simple-state-editor>
|
||||
<div id="transition-editor">
|
||||
<app-simple-transition-editor [gamesystem]="simpleGamesystem" [scriptAccounts]="scriptAccunts"></app-simple-transition-editor>
|
||||
</div>
|
||||
|
@ -3,6 +3,7 @@ import {MatTableDataSource} from "@angular/material/table";
|
||||
import {SimpleGamesystem} from "../../../project/game-model/gamesystems/SimpleGamesystem";
|
||||
import {ScriptAccount} from "../../../project/game-model/scriptAccounts/ScriptAccount";
|
||||
import {SimpleTemplateGamesystem} from "../../../project/game-model/gamesystems/SimpleTemplateGamesystem";
|
||||
import {Character} from "../../../project/game-model/characters/Character";
|
||||
|
||||
@Component({
|
||||
selector: 'app-simple-gamesystem-editor',
|
||||
@ -13,6 +14,7 @@ export class SimpleGamesystemEditorComponent implements OnInit{
|
||||
|
||||
@Input() simpleGamesystem: SimpleGamesystem | SimpleTemplateGamesystem<any> | undefined
|
||||
@Input() scriptAccunts: ScriptAccount[] = []
|
||||
@Input() templateReference: Character | undefined
|
||||
|
||||
ngOnInit(): void {
|
||||
console.log("SimpleGamesystem: ", this.simpleGamesystem)
|
||||
|
@ -27,7 +27,7 @@
|
||||
</mat-form-field>
|
||||
|
||||
<div class="long-form">
|
||||
<app-scriptaccount-condition-editor [conditions]="element.conditions" [scriptAccounts]="scriptAccounts" [enableEditiong]="true"
|
||||
<app-scriptaccount-condition-editor [conditions]="getStateConditions(element)" [scriptAccounts]="scriptAccounts" [enableEditiong]="true"
|
||||
(onCreateCondition)="onCreateCondition(element, $event)" (onDeleteCondition)="deleteCondition(element, $event)"></app-scriptaccount-condition-editor>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -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 {Character} from "../../../../project/game-model/characters/Character";
|
||||
import {SimpleTemplateState} from "../../../../project/game-model/gamesystems/states/SimpleTemplateState";
|
||||
|
||||
@Component({
|
||||
selector: 'app-simple-state-editor',
|
||||
@ -24,6 +26,8 @@ export class SimpleStateEditorComponent implements OnInit{
|
||||
@Input() states: SimpleState[] = [];
|
||||
@Input() gamesystem: SimpleGamesystem | undefined
|
||||
@Input() scriptAccounts: ScriptAccount[] = []
|
||||
@Input() templateReference: Character | undefined
|
||||
|
||||
dataSource = new MatTableDataSource<SimpleState>();
|
||||
displayedColumns = ["name", "initial", "edit", "delete"];
|
||||
columnsToDisplayWithExpand = [...this.displayedColumns, 'expand'];
|
||||
@ -96,11 +100,33 @@ export class SimpleStateEditorComponent implements OnInit{
|
||||
}
|
||||
|
||||
onCreateCondition(state: SimpleState, condition: ScriptAccountCondition) {
|
||||
if(this.templateReference instanceof Character) {
|
||||
const templateState = state as SimpleTemplateState<Character>
|
||||
console.log("CharacterRef: ", this.templateReference);
|
||||
templateState.conditionMap.get(this.templateReference as Character)!.push(condition)
|
||||
console.log(templateState)
|
||||
} else {
|
||||
state.addScriptAccountCondition(condition);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
deleteCondition(state: SimpleState, condition: ScriptAccountCondition) {
|
||||
state.removeScriptAccountCondition(condition.scriptAccount);
|
||||
}
|
||||
|
||||
getStateConditions(state: SimpleState) {
|
||||
if(state instanceof SimpleTemplateState) {
|
||||
if(this.templateReference instanceof Character) {
|
||||
const referenceSpecificConditions = state.conditionMap.get(this.templateReference as Character)
|
||||
if(referenceSpecificConditions == undefined) {
|
||||
return []
|
||||
} else {
|
||||
return referenceSpecificConditions;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return state.conditions;
|
||||
}
|
||||
}
|
||||
|
@ -19,21 +19,21 @@ export class CharacterParser {
|
||||
|
||||
private parseSingleCharacter(characterData: any): Character {
|
||||
const character = new Character(characterData.componentName, characterData.componentDescription);
|
||||
character.characterSpecificGamesystems = this.parseCharacterSpecificGamesystems(characterData.characterSpecificGamesystems);
|
||||
character.characterSpecificGamesystems = this.parseCharacterSpecificGamesystems(character, characterData.characterSpecificGamesystems);
|
||||
console.log("Parsed Character", character)
|
||||
return character;
|
||||
}
|
||||
|
||||
private parseCharacterSpecificGamesystems(characterSpecificGamesystems: any): SimpleTemplateGamesystem<Character>[] {
|
||||
private parseCharacterSpecificGamesystems(character: Character, characterSpecificGamesystems: any): SimpleTemplateGamesystem<Character>[] {
|
||||
const result: SimpleTemplateGamesystem<Character>[] = []
|
||||
for(let i=0; i<characterSpecificGamesystems.length; i++) {
|
||||
const characterSpecificGamesystem = characterSpecificGamesystems[i];
|
||||
result.push(this.parseSingleCharacterSpecificGamesystem(characterSpecificGamesystem)!)
|
||||
result.push(this.parseSingleCharacterSpecificGamesystem(character, characterSpecificGamesystem)!)
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private parseSingleCharacterSpecificGamesystem(characterSpecificGamesystem: any): SimpleTemplateGamesystem<Character> | undefined{
|
||||
private parseSingleCharacterSpecificGamesystem(character: Character, characterSpecificGamesystem: any): SimpleTemplateGamesystem<Character> | undefined{
|
||||
const referencedGamesystem = this.findCharacterSpecificGamesystem(characterSpecificGamesystem.componentName)
|
||||
|
||||
if(referencedGamesystem != undefined) {
|
||||
@ -41,7 +41,7 @@ export class CharacterParser {
|
||||
const stateReference = characterSpecificGamesystem.states[i];
|
||||
const state = this.findReferencedState(referencedGamesystem, stateReference.stateLabel)!
|
||||
|
||||
|
||||
state.conditionMap.set(character, [])
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ import {StoreComponent} from "../../../../app/storage/StoreComponent";
|
||||
import {SerializeConstants} from "./SerializeConstants";
|
||||
import {ModelComponentType} from "../game-model/ModelComponentType";
|
||||
import {Gamesystem} from "../game-model/gamesystems/Gamesystem";
|
||||
import {ScriptAccount} from "../game-model/scriptAccounts/ScriptAccount";
|
||||
|
||||
export class CharacterSerializer {
|
||||
|
||||
@ -24,6 +25,14 @@ export class CharacterSerializer {
|
||||
}
|
||||
}
|
||||
|
||||
if(key === 'scriptAccount') {
|
||||
return value.componentName
|
||||
}
|
||||
|
||||
if(key === 'conditionMap') {
|
||||
return value.get(character)
|
||||
}
|
||||
|
||||
if(this.ignoredKeys.includes(key)) {
|
||||
return undefined
|
||||
} else {
|
||||
|
@ -7,11 +7,17 @@
|
||||
"states": [
|
||||
{
|
||||
"stateLabel": "Fröhlich",
|
||||
"conditionMap": {}
|
||||
"conditionMap": [
|
||||
{
|
||||
"scriptAccount": "Luftfeuchtigkeit",
|
||||
"minValue": 0,
|
||||
"maxValue": "10"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"stateLabel": "Wütend",
|
||||
"conditionMap": {}
|
||||
"conditionMap": []
|
||||
}
|
||||
],
|
||||
"transitions": []
|
||||
|
Loading…
Reference in New Issue
Block a user