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-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>

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()"
(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 {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() {

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">
<app-simple-transition-editor [gamesystem]="simpleGamesystem" [scriptAccounts]="scriptAccunts"></app-simple-transition-editor>
</div>

View File

@ -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)

View File

@ -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>

View File

@ -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;
}
}

View File

@ -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, [])
}
}

View File

@ -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 {

View File

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