alt-templatesystem-impl #29

Closed
sebastian wants to merge 23 commits from alt-templatesystem-impl into character-specific-gamesystems
10 changed files with 59 additions and 11 deletions
Showing only changes of commit e962cc9594 - Show all commits

View File

@ -6,7 +6,9 @@
<mat-accordion> <mat-accordion>
<mat-expansion-panel *ngFor="let gamesystem of character!.characterSpecificGamesystems"> <mat-expansion-panel *ngFor="let gamesystem of character!.characterSpecificGamesystems">
<mat-expansion-panel-header>{{gamesystem.componentName}}</mat-expansion-panel-header> <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-expansion-panel>
</mat-accordion> </mat-accordion>
<button mat-stroked-button style="width: 100%; margin-top: 10px" (click)="onOpenTemplateCreator()">Add Gamesystem</button> <button mat-stroked-button style="width: 100%; margin-top: 10px" (click)="onOpenTemplateCreator()">Add Gamesystem</button>
</mat-card-content> </mat-card-content>

View File

@ -1,3 +1,4 @@
<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()" <app-product-gamesystem-editor *ngIf="!isSimpleGamesystem()" [gamesystem]="convertGamesystemToProductGamesystem()"
(onOpenGamesystemEditor)="onOpenGamesystemEditor($event)"></app-product-gamesystem-editor> (onOpenGamesystemEditor)="onOpenGamesystemEditor($event)"></app-product-gamesystem-editor>

View File

@ -6,6 +6,7 @@ import {ScriptAccount} from "../../project/game-model/scriptAccounts/ScriptAccou
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 {SimpleTemplateGamesystem} from "../../project/game-model/gamesystems/SimpleTemplateGamesystem"; import {SimpleTemplateGamesystem} from "../../project/game-model/gamesystems/SimpleTemplateGamesystem";
import {Character} from "../../project/game-model/characters/Character";
@Component({ @Component({
selector: 'app-gamesystem-editor', selector: 'app-gamesystem-editor',
@ -16,6 +17,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() templateReference: Character | 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 [states]="simpleGamesystem!.states" [gamesystem]="simpleGamesystem" [scriptAccounts]="scriptAccunts" [templateReference]="templateReference"></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

@ -3,6 +3,7 @@ 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 {SimpleTemplateGamesystem} from "../../../project/game-model/gamesystems/SimpleTemplateGamesystem"; import {SimpleTemplateGamesystem} from "../../../project/game-model/gamesystems/SimpleTemplateGamesystem";
import {Character} from "../../../project/game-model/characters/Character";
@Component({ @Component({
selector: 'app-simple-gamesystem-editor', selector: 'app-simple-gamesystem-editor',
@ -13,6 +14,7 @@ export class SimpleGamesystemEditorComponent implements OnInit{
@Input() simpleGamesystem: SimpleGamesystem | SimpleTemplateGamesystem<any> | undefined @Input() simpleGamesystem: SimpleGamesystem | SimpleTemplateGamesystem<any> | undefined
@Input() scriptAccunts: ScriptAccount[] = [] @Input() scriptAccunts: ScriptAccount[] = []
@Input() templateReference: Character | undefined
ngOnInit(): void { ngOnInit(): void {
console.log("SimpleGamesystem: ", this.simpleGamesystem) console.log("SimpleGamesystem: ", this.simpleGamesystem)

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]="getStateConditions(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 {Character} from "../../../../project/game-model/characters/Character";
import {SimpleTemplateState} from "../../../../project/game-model/gamesystems/states/SimpleTemplateState";
@Component({ @Component({
selector: 'app-simple-state-editor', selector: 'app-simple-state-editor',
@ -24,6 +26,8 @@ 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() templateReference: Character | 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 +100,33 @@ export class SimpleStateEditorComponent implements OnInit{
} }
onCreateCondition(state: SimpleState, condition: ScriptAccountCondition) { onCreateCondition(state: SimpleState, condition: ScriptAccountCondition) {
state.addScriptAccountCondition(condition); 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) { deleteCondition(state: SimpleState, condition: ScriptAccountCondition) {
state.removeScriptAccountCondition(condition.scriptAccount); 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;
}
} }

View File

@ -19,21 +19,21 @@ export class CharacterParser {
private parseSingleCharacter(characterData: any): Character { private parseSingleCharacter(characterData: any): Character {
const character = new Character(characterData.componentName, characterData.componentDescription); 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) console.log("Parsed Character", character)
return character; return character;
} }
private parseCharacterSpecificGamesystems(characterSpecificGamesystems: any): SimpleTemplateGamesystem<Character>[] { private parseCharacterSpecificGamesystems(character: Character, characterSpecificGamesystems: any): SimpleTemplateGamesystem<Character>[] {
const result: SimpleTemplateGamesystem<Character>[] = [] const result: SimpleTemplateGamesystem<Character>[] = []
for(let i=0; i<characterSpecificGamesystems.length; i++) { for(let i=0; i<characterSpecificGamesystems.length; i++) {
const characterSpecificGamesystem = characterSpecificGamesystems[i]; const characterSpecificGamesystem = characterSpecificGamesystems[i];
result.push(this.parseSingleCharacterSpecificGamesystem(characterSpecificGamesystem)!) result.push(this.parseSingleCharacterSpecificGamesystem(character, characterSpecificGamesystem)!)
} }
return result; return result;
} }
private parseSingleCharacterSpecificGamesystem(characterSpecificGamesystem: any): SimpleTemplateGamesystem<Character> | undefined{ private parseSingleCharacterSpecificGamesystem(character: Character, characterSpecificGamesystem: any): SimpleTemplateGamesystem<Character> | undefined{
const referencedGamesystem = this.findCharacterSpecificGamesystem(characterSpecificGamesystem.componentName) const referencedGamesystem = this.findCharacterSpecificGamesystem(characterSpecificGamesystem.componentName)
if(referencedGamesystem != undefined) { if(referencedGamesystem != undefined) {
@ -41,7 +41,7 @@ export class CharacterParser {
const stateReference = characterSpecificGamesystem.states[i]; const stateReference = characterSpecificGamesystem.states[i];
const state = this.findReferencedState(referencedGamesystem, stateReference.stateLabel)! const state = this.findReferencedState(referencedGamesystem, stateReference.stateLabel)!
state.conditionMap.set(character, [])
} }
} }

View File

@ -3,6 +3,7 @@ import {StoreComponent} from "../../../../app/storage/StoreComponent";
import {SerializeConstants} from "./SerializeConstants"; import {SerializeConstants} from "./SerializeConstants";
import {ModelComponentType} from "../game-model/ModelComponentType"; import {ModelComponentType} from "../game-model/ModelComponentType";
import {Gamesystem} from "../game-model/gamesystems/Gamesystem"; import {Gamesystem} from "../game-model/gamesystems/Gamesystem";
import {ScriptAccount} from "../game-model/scriptAccounts/ScriptAccount";
export class CharacterSerializer { 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)) { if(this.ignoredKeys.includes(key)) {
return undefined return undefined
} else { } else {

View File

@ -7,11 +7,17 @@
"states": [ "states": [
{ {
"stateLabel": "Fröhlich", "stateLabel": "Fröhlich",
"conditionMap": {} "conditionMap": [
{
"scriptAccount": "Luftfeuchtigkeit",
"minValue": 0,
"maxValue": "10"
}
]
}, },
{ {
"stateLabel": "Wütend", "stateLabel": "Wütend",
"conditionMap": {} "conditionMap": []
} }
], ],
"transitions": [] "transitions": []