diff --git a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html index 75a20e3..cc9cb09 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html +++ b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.html @@ -45,7 +45,7 @@
-
diff --git a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts index 5a54129..2a71b80 100644 --- a/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts +++ b/src/app/editor/gamesystem-editor/transition-editor/simple-transition-editor/simple-transition-editor.component.ts @@ -13,6 +13,7 @@ import { SimpleTemplateTransition } from "../../../../project/game-model/gamesystems/transitions/SimpleTemplateTransition"; import {Character} from "../../../../project/game-model/characters/Character"; +import {SimpleTemplateState} from "../../../../project/game-model/gamesystems/states/SimpleTemplateState"; @Component({ selector: 'app-simple-transition-editor', templateUrl: './simple-transition-editor.component.html', @@ -109,7 +110,16 @@ export class SimpleTransitionEditorComponent implements OnInit { protected readonly transition = transition; onCreateCondition(transition: SimpleTransition, condition: ScriptAccountCondition) { - transition.addScriptAccountCondition(condition); + if(transition instanceof SimpleTemplateTransition && this.templateReference instanceof Character) { + const templateTransition = transition as SimpleTemplateTransition + if(templateTransition.conditionMap.has(this.templateReference)) { + templateTransition.conditionMap.get(this.templateReference)!.push(condition) + } else { + templateTransition.conditionMap.set(this.templateReference, [condition]) + } + } else { + transition.addScriptAccountCondition(condition); + } } deleteCondition(trasition: SimpleTransition, condition: ScriptAccountCondition) { @@ -119,4 +129,16 @@ export class SimpleTransitionEditorComponent implements OnInit { editTransition(transition: SimpleTransition) { 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; + } + } } diff --git a/src/app/project/parser/characterParser/CharacterParser.ts b/src/app/project/parser/characterParser/CharacterParser.ts index d1323f9..1bd6fdb 100644 --- a/src/app/project/parser/characterParser/CharacterParser.ts +++ b/src/app/project/parser/characterParser/CharacterParser.ts @@ -4,15 +4,19 @@ import {SimpleTemplateGamesystem} from "../../game-model/gamesystems/SimpleTempl import {ScriptAccount} from "../../game-model/scriptAccounts/ScriptAccount"; import {ScriptAccountParser} from "../ScriptAccountParser"; import {ScriptAccountConditionParser} from "../gamesystemParser/ScriptAccountConditionParser"; +import {transition} from "@angular/animations"; +import {ScriptAccountActionParser} from "../gamesystemParser/ScriptAccountActionParser"; export class CharacterParser { characterSpecificGamesystems: SimpleTemplateGamesystem[] scriptAccountConditionParser: ScriptAccountConditionParser + scriptAccountActionParser: ScriptAccountActionParser constructor(characterSpecificGamesystems: SimpleTemplateGamesystem[], scriptAccounts: ScriptAccount[]) { this.characterSpecificGamesystems = characterSpecificGamesystems; + this.scriptAccountActionParser = new ScriptAccountActionParser(scriptAccounts); this.scriptAccountConditionParser = new ScriptAccountConditionParser(scriptAccounts) } @@ -44,11 +48,21 @@ export class CharacterParser { for(let i=0; i, stateLabel: string) { return gamesystem.states.find(state => state.stateLabel === stateLabel); } + + private findReferencedTransition(gamesystem: SimpleTemplateGamesystem, startingLabel: string, endingLabel: string) { + return gamesystem.transitions.find(transition => transition.startingState.stateLabel === startingLabel && transition.endingState.stateLabel === endingLabel); + } } diff --git a/testModel/characters/Hicks Haddock.json b/testModel/characters/Hicks Haddock.json index 54fd6be..b3934ab 100644 --- a/testModel/characters/Hicks Haddock.json +++ b/testModel/characters/Hicks Haddock.json @@ -26,8 +26,19 @@ "scriptAccountConditions": [], "startingState": "Fröhlich", "endingState": "Wütend", - "conditionMap": [], - "actionMap": [] + "conditionMap": [ + { + "scriptAccount": "Luftfeuchtigkeit", + "minValue": 0, + "maxValue": "10" + } + ], + "actionMap": [ + { + "changingValue": 0, + "scriptAccount": "New ScriptAccount" + } + ] } ] }