Assign template Transition to template gamesystem
All checks were successful
E2E Testing / test (push) Successful in 1m50s

This commit is contained in:
Sebastian Böckelmann 2024-04-11 17:15:17 +02:00
parent f7eadfa04d
commit a3639969e3
5 changed files with 42 additions and 4 deletions

View File

@ -8,6 +8,10 @@ import {ScriptAccount} from "../../../../project/game-model/scriptAccounts/Scrip
import {SimpleTransition} from "../../../../project/game-model/gamesystems/transitions/SimpleTransition";
import {SimpleState} from "../../../../project/game-model/gamesystems/states/SimpleState";
import {ScriptAccountCondition} from "../../../../project/game-model/gamesystems/conditions/ScriptAccountCondition";
import {SimpleTemplateGamesystem} from "../../../../project/game-model/gamesystems/SimpleTemplateGamesystem";
import {
SimpleTemplateTransition
} from "../../../../project/game-model/gamesystems/transitions/SimpleTemplateTransition";
@Component({
selector: 'app-simple-transition-editor',
templateUrl: './simple-transition-editor.component.html',
@ -53,7 +57,11 @@ export class SimpleTransitionEditorComponent implements OnInit {
}
addTransition() {
if(this.gamesystem instanceof SimpleTemplateGamesystem) {
this.editedTransition = new SimpleTemplateTransition(this.defaultStartingState, this.defaultEndingState);
} else {
this.editedTransition = new SimpleTransition(this.defaultStartingState, this.defaultEndingState);
}
const updatedData = this.dataSource.data;
updatedData.push(this.editedTransition);
this.dataSource.data = updatedData;
@ -79,6 +87,7 @@ export class SimpleTransitionEditorComponent implements OnInit {
return;
}
this.gamesystem?.createTransition(this.editedTransition!.startingState, this.editedTransition!.endingState);
console.log("Edited Gamesystem: ", this.gamesystem!)
this.dataSource.data = this.gamesystem!.transitions;
this.editedTransition = undefined;
}

View File

@ -27,7 +27,6 @@ export class SimpleTemplateGamesystem<ReferenceType> extends Gamesystem<SimpleTe
if((startingState == null || endingState == null) || startingState === endingState) {
return undefined;
}
const transition = new SimpleTemplateTransition<ReferenceType>(startingState, endingState);
if(this.transitions.find(t => t.startingState === startingState && t.endingState === endingState) == undefined) {
this.transitions.push(transition)

View File

@ -17,6 +17,7 @@ export class CharacterSerializer {
private static serializeSingleCharacter(character: Character): StoreComponent{
const fileName = character.componentName
console.log("Templatesystem: ", character.characterSpecificGamesystems)
const jsonString = JSON.stringify(character, (key, value) => {
if(value instanceof Gamesystem) {
return {

View File

@ -20,7 +20,27 @@
"conditionMap": []
}
],
"transitions": []
"transitions": [
{
"scriptAccountActions": [],
"scriptAccountConditions": [],
"startingState": {
"stateLabel": "Fröhlich",
"conditionMap": [
{
"scriptAccount": "Luftfeuchtigkeit",
"minValue": 0,
"maxValue": "10"
}
]
},
"endingState": {
"stateLabel": "Wütend",
"conditionMap": []
},
"actions": {}
}
]
}
]
}

View File

@ -15,6 +15,15 @@
"stateDescription": ""
}
],
"transitions": [],
"transitions": [
{
"scriptAccountActions": [],
"scriptAccountConditions": [],
"startingState": "Fröhlich",
"endingState": "Wütend",
"conditions": {},
"actions": {}
}
],
"templateType": 1
}