Persist ScriptAccountConditions to TemplateTransition
All checks were successful
E2E Testing / test (push) Successful in 1m55s
All checks were successful
E2E Testing / test (push) Successful in 1m55s
This commit is contained in:
parent
f11e290a6b
commit
803d0d4443
@ -45,7 +45,7 @@
|
|||||||
<app-scriptaccount-action-editor [transition]="element" [scriptAccounts]="scriptAccounts" [enableEditing]="true" [templateReference]="templateReference"></app-scriptaccount-action-editor>
|
<app-scriptaccount-action-editor [transition]="element" [scriptAccounts]="scriptAccounts" [enableEditing]="true" [templateReference]="templateReference"></app-scriptaccount-action-editor>
|
||||||
</div>
|
</div>
|
||||||
<div class="condition-container">
|
<div class="condition-container">
|
||||||
<app-scriptaccount-condition-editor [conditions]="element.scriptAccountConditions" [scriptAccounts]="scriptAccounts" [enableEditiong]="true"
|
<app-scriptaccount-condition-editor [conditions]="fetchConditions(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>
|
||||||
|
@ -13,6 +13,7 @@ import {
|
|||||||
SimpleTemplateTransition
|
SimpleTemplateTransition
|
||||||
} from "../../../../project/game-model/gamesystems/transitions/SimpleTemplateTransition";
|
} from "../../../../project/game-model/gamesystems/transitions/SimpleTemplateTransition";
|
||||||
import {Character} from "../../../../project/game-model/characters/Character";
|
import {Character} from "../../../../project/game-model/characters/Character";
|
||||||
|
import {SimpleTemplateState} from "../../../../project/game-model/gamesystems/states/SimpleTemplateState";
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-simple-transition-editor',
|
selector: 'app-simple-transition-editor',
|
||||||
templateUrl: './simple-transition-editor.component.html',
|
templateUrl: './simple-transition-editor.component.html',
|
||||||
@ -109,8 +110,17 @@ export class SimpleTransitionEditorComponent implements OnInit {
|
|||||||
protected readonly transition = transition;
|
protected readonly transition = transition;
|
||||||
|
|
||||||
onCreateCondition(transition: SimpleTransition, condition: ScriptAccountCondition) {
|
onCreateCondition(transition: SimpleTransition, condition: ScriptAccountCondition) {
|
||||||
|
if(transition instanceof SimpleTemplateTransition && this.templateReference instanceof Character) {
|
||||||
|
const templateTransition = transition as SimpleTemplateTransition<Character>
|
||||||
|
if(templateTransition.conditionMap.has(this.templateReference)) {
|
||||||
|
templateTransition.conditionMap.get(this.templateReference)!.push(condition)
|
||||||
|
} else {
|
||||||
|
templateTransition.conditionMap.set(this.templateReference, [condition])
|
||||||
|
}
|
||||||
|
} else {
|
||||||
transition.addScriptAccountCondition(condition);
|
transition.addScriptAccountCondition(condition);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
deleteCondition(trasition: SimpleTransition, condition: ScriptAccountCondition) {
|
deleteCondition(trasition: SimpleTransition, condition: ScriptAccountCondition) {
|
||||||
trasition.removeScriptAccountCondition(condition.scriptAccount);
|
trasition.removeScriptAccountCondition(condition.scriptAccount);
|
||||||
@ -119,4 +129,16 @@ export class SimpleTransitionEditorComponent implements OnInit {
|
|||||||
editTransition(transition: SimpleTransition) {
|
editTransition(transition: SimpleTransition) {
|
||||||
this.referenceTransitionEmitter.emit(transition)
|
this.referenceTransitionEmitter.emit(transition)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fetchConditions(transition: SimpleTransition): ScriptAccountCondition[] {
|
||||||
|
if(transition instanceof SimpleTemplateTransition && this.templateReference instanceof Character) {
|
||||||
|
if(transition.conditionMap.get(this.templateReference) == undefined) {
|
||||||
|
return transition.scriptAccountConditions
|
||||||
|
} else {
|
||||||
|
return transition.conditionMap.get(this.templateReference!)!
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return transition.scriptAccountConditions;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,15 +4,19 @@ import {SimpleTemplateGamesystem} from "../../game-model/gamesystems/SimpleTempl
|
|||||||
import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount";
|
import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount";
|
||||||
import {ScriptAccountParser} from "../ScriptAccountParser";
|
import {ScriptAccountParser} from "../ScriptAccountParser";
|
||||||
import {ScriptAccountConditionParser} from "../gamesystemParser/ScriptAccountConditionParser";
|
import {ScriptAccountConditionParser} from "../gamesystemParser/ScriptAccountConditionParser";
|
||||||
|
import {transition} from "@angular/animations";
|
||||||
|
import {ScriptAccountActionParser} from "../gamesystemParser/ScriptAccountActionParser";
|
||||||
|
|
||||||
|
|
||||||
export class CharacterParser {
|
export class CharacterParser {
|
||||||
|
|
||||||
characterSpecificGamesystems: SimpleTemplateGamesystem<Character>[]
|
characterSpecificGamesystems: SimpleTemplateGamesystem<Character>[]
|
||||||
scriptAccountConditionParser: ScriptAccountConditionParser
|
scriptAccountConditionParser: ScriptAccountConditionParser
|
||||||
|
scriptAccountActionParser: ScriptAccountActionParser
|
||||||
|
|
||||||
constructor(characterSpecificGamesystems: SimpleTemplateGamesystem<Character>[], scriptAccounts: ScriptAccount[]) {
|
constructor(characterSpecificGamesystems: SimpleTemplateGamesystem<Character>[], scriptAccounts: ScriptAccount[]) {
|
||||||
this.characterSpecificGamesystems = characterSpecificGamesystems;
|
this.characterSpecificGamesystems = characterSpecificGamesystems;
|
||||||
|
this.scriptAccountActionParser = new ScriptAccountActionParser(scriptAccounts);
|
||||||
this.scriptAccountConditionParser = new ScriptAccountConditionParser(scriptAccounts)
|
this.scriptAccountConditionParser = new ScriptAccountConditionParser(scriptAccounts)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,11 +48,21 @@ export class CharacterParser {
|
|||||||
for(let i=0; i<characterSpecificGamesystem.states.length; i++) {
|
for(let i=0; i<characterSpecificGamesystem.states.length; i++) {
|
||||||
const stateReference = characterSpecificGamesystem.states[i];
|
const stateReference = characterSpecificGamesystem.states[i];
|
||||||
const state = this.findReferencedState(referencedGamesystem, stateReference.stateLabel)!
|
const state = this.findReferencedState(referencedGamesystem, stateReference.stateLabel)!
|
||||||
|
|
||||||
const conditions = this.scriptAccountConditionParser.parseStoredConditions(stateReference.conditionMap);
|
const conditions = this.scriptAccountConditionParser.parseStoredConditions(stateReference.conditionMap);
|
||||||
|
|
||||||
state.conditionMap.set(character, conditions)
|
state.conditionMap.set(character, conditions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(let i=0; i<characterSpecificGamesystem.transitions.length; i++) {
|
||||||
|
const transitionReference = characterSpecificGamesystem.transitions[i];
|
||||||
|
|
||||||
|
const transition = this.findReferencedTransition(referencedGamesystem, transitionReference.startingState, transitionReference.endingState);
|
||||||
|
const condititions = this.scriptAccountConditionParser.parseStoredConditions(transitionReference.conditionMap);
|
||||||
|
const actions = this.scriptAccountActionParser.parseActions(transitionReference.actionMap);
|
||||||
|
|
||||||
|
transition!.actionMap.set(character, actions);
|
||||||
|
transition!.conditionMap.set(character, condititions);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return referencedGamesystem;
|
return referencedGamesystem;
|
||||||
@ -60,4 +74,8 @@ export class CharacterParser {
|
|||||||
private findReferencedState(gamesystem: SimpleTemplateGamesystem<Character>, stateLabel: string) {
|
private findReferencedState(gamesystem: SimpleTemplateGamesystem<Character>, stateLabel: string) {
|
||||||
return gamesystem.states.find(state => state.stateLabel === stateLabel);
|
return gamesystem.states.find(state => state.stateLabel === stateLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private findReferencedTransition(gamesystem: SimpleTemplateGamesystem<Character>, startingLabel: string, endingLabel: string) {
|
||||||
|
return gamesystem.transitions.find(transition => transition.startingState.stateLabel === startingLabel && transition.endingState.stateLabel === endingLabel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,19 @@
|
|||||||
"scriptAccountConditions": [],
|
"scriptAccountConditions": [],
|
||||||
"startingState": "Fröhlich",
|
"startingState": "Fröhlich",
|
||||||
"endingState": "Wütend",
|
"endingState": "Wütend",
|
||||||
"conditionMap": [],
|
"conditionMap": [
|
||||||
"actionMap": []
|
{
|
||||||
|
"scriptAccount": "Luftfeuchtigkeit",
|
||||||
|
"minValue": 0,
|
||||||
|
"maxValue": "10"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"actionMap": [
|
||||||
|
{
|
||||||
|
"changingValue": 0,
|
||||||
|
"scriptAccount": "New ScriptAccount"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user