Introduce Basic concept of Templates for SimpleGamesystems and Characters
All checks were successful
E2E Testing / test (push) Successful in 1m32s

This commit is contained in:
Sebastian Böckelmann 2024-04-13 12:30:42 +02:00
parent 4bd85945b5
commit cd48a10084
13 changed files with 157 additions and 11 deletions

View File

@ -64,10 +64,21 @@ function createWindow(): BrowserWindow {
submenu: [
{
label: "Gamesystem",
submenu: [
{
label: "Normal",
click: () => {
win!.webContents.send('context-menu', "new-gamesystem");
win!.webContents.send('context-menu', "new-gamesystem-normal");
}
},
{
label: "Character",
click: () => {
win!.webContents.send('context-menu', "new-gamesystem-character");
}
}
]
},
{
label: "ScriptAccount",
click: () => {

View File

@ -24,6 +24,8 @@ import {Character} from "./project/game-model/characters/Character";
import {CharacterOverviewComponent} from "./side-overviews/character-overview/character-overview.component";
import {CharacterSerializer} from "./project/serializer/CharacterSerializer";
import {CharacterParser} from "./project/parser/characterParser/CharacterParser";
import {TemplateType} from "./project/game-model/templates/TemplateType";
import {TemplateTypeUtilities} from "./project/game-model/templates/TemplateTypeUtilities";
@Component({
selector: 'app-root',
@ -76,8 +78,9 @@ export class AppComponent implements OnInit{
} else if(message.startsWith("new")) {
const splittedMessage = message.split("-");
const modelComponentType = ModelComponentTypeUtillities.fromString(splittedMessage[1]);
const templateType = TemplateTypeUtilities.fromString(splittedMessage[2]);
if(modelComponentType != undefined) {
this.onCreateModelComponent(modelComponentType);
this.onCreateModelComponent(modelComponentType, templateType);
} else {
console.log("[ERROR] [App-Component] Unknown Context-Menu Command!")
}
@ -127,10 +130,10 @@ export class AppComponent implements OnInit{
})
}
private onCreateModelComponent(modelComponentType: ModelComponentType) {
private onCreateModelComponent(modelComponentType: ModelComponentType, templateType: TemplateType | undefined) {
switch (modelComponentType) {
case ModelComponentType.SCRIPTACCOUNT: this.onCreateNewScriptAccount(); break
case ModelComponentType.GAMESYTEM: this.onCreateNewGamesystem(); break
case ModelComponentType.GAMESYTEM: this.onCreateNewGamesystem(templateType); break
case ModelComponentType.CHARACTER: this.onCreateNewCharacter(); break
}
}
@ -144,7 +147,7 @@ export class AppComponent implements OnInit{
}
}
private onCreateNewGamesystem() {
private onCreateNewGamesystem(templateType: TemplateType | undefined) {
let parentGamesystemName = undefined
if(this.openContent != ModelComponentType.GAMESYTEM) {
this.openGamesystemsOverview();
@ -153,7 +156,8 @@ export class AppComponent implements OnInit{
}
const createdGamesystem = this.gameModel!.createGamesystem("New Gamesystem", parentGamesystemName);
//const createdGamesystem = this.gameModel!.createGamesystem("New Gamesystem", parentGamesystemName, templateType);
const createdGamesystem = this.gameModel!.createSimpleGamesystem("New Gamesystem", templateType)
if(createdGamesystem != undefined) {
this.gamesystemOverview!.refresh();
this.editor?.openGameModelComponent(createdGamesystem);

View File

@ -6,6 +6,8 @@ import {ProductGamesystem} from "./gamesystems/ProductGamesystem";
import {SimpleGamesystem} from "./gamesystems/SimpleGamesystem";
import {Character} from "./characters/Character";
import {ModelComponentType} from "./ModelComponentType";
import {TemplateType} from "./templates/TemplateType";
import {SimpleTemplateGamesystem} from "./templates/simpleGamesystem/SimpleTemplateGamesystem";
export class GameModel {
gameModelName: string
@ -45,9 +47,26 @@ export class GameModel {
return undefined;
}
createGamesystem(gamesystemName: string, parentGamesystemName: string | undefined) {
createSimpleGamesystem(gamesystemName: string, templateType: TemplateType | undefined) {
if(gamesystemName != undefined && this.findGamesystem(gamesystemName) == undefined) {
let simpleGamesystem: SimpleGamesystem
if(templateType == undefined) {
simpleGamesystem = new SimpleGamesystem(gamesystemName, "")
} else {
simpleGamesystem = new SimpleTemplateGamesystem(gamesystemName, "", templateType)
}
this.gamesystems.push(simpleGamesystem)
return simpleGamesystem;
}
return undefined;
}
createGamesystem(gamesystemName: string, parentGamesystemName: string | undefined, templateType: TemplateType | undefined) {
if(gamesystemName != undefined && this.findGamesystem(gamesystemName) == undefined) {
const simpleGamesystem = new SimpleGamesystem(gamesystemName, "");
if(parentGamesystemName != undefined) {
const parentGamesystem = this.findGamesystem(parentGamesystemName);
if(parentGamesystem instanceof SimpleGamesystem) {
@ -61,7 +80,6 @@ export class GameModel {
}
} else {
this.gamesystems.push(simpleGamesystem);
}
return simpleGamesystem;
}

View File

@ -1,7 +1,8 @@
import {ModelComponent} from "../ModelComponent";
import {ModelComponentType} from "../ModelComponentType";
import {TemplateElement} from "../templates/TemplateElement";
export class Character extends ModelComponent{
export class Character extends ModelComponent implements TemplateElement {
constructor(componentName: string, componentDescription: string) {
super(componentName, componentDescription, ModelComponentType.CHARACTER);

View File

@ -0,0 +1,2 @@
export interface TemplateElement {
}

View File

@ -0,0 +1,9 @@
import {Gamesystem} from "../gamesystems/Gamesystem";
import {TemplateElement} from "./TemplateElement";
export interface TemplateGamesystem {
addTemplateElement(templateElement: TemplateElement): void;
}

View File

@ -0,0 +1,3 @@
export enum TemplateType {
CHARACTER
}

View File

@ -0,0 +1,9 @@
import {TemplateType} from "./TemplateType";
export class TemplateTypeUtilities {
static fromString(string: string) {
if(string === 'character') {
return TemplateType.CHARACTER
}
}
}

View File

@ -0,0 +1,41 @@
import {SimpleGamesystem} from "../../gamesystems/SimpleGamesystem";
import {TemplateGamesystem} from "../TemplateGamesystem";
import {TemplateElement} from "../TemplateElement";
import {SimpleState} from "../../gamesystems/states/SimpleState";
import {SimpleTransition} from "../../gamesystems/transitions/SimpleTransition";
import {state, transition} from "@angular/animations";
import {SimpleTemplateState} from "./SimpleTemplateState";
import {SimpleTemplateTransition} from "./SimpleTemplateTransition";
import {TemplateType} from "../TemplateType";
export class SimpleTemplateGamesystem extends SimpleGamesystem implements TemplateGamesystem {
templateType: TemplateType
constructor(gamesystemName: string, gamesystemDescription: string, templateType: TemplateType) {
super(gamesystemName, gamesystemDescription);
this.templateType = templateType;
}
addTemplateElement(templateElement: TemplateElement): void {
this.states.forEach(state => {
(state as SimpleTemplateState).addTemplateElement(templateElement);
})
this.transitions.forEach(transition => {
(transition as SimpleTemplateTransition).addTemplateElement(templateElement);
})
}
createState(label: string, description: string): SimpleState | undefined {
return new SimpleTemplateState(label, description);
}
createTransition(startingState: SimpleState, endingState: SimpleState): SimpleTransition | undefined {
return new SimpleTemplateTransition(startingState, endingState)
}
removeState(state: SimpleState): boolean {
return super.removeState(state);
}
}

View File

@ -0,0 +1,16 @@
import {SimpleState} from "../../gamesystems/states/SimpleState";
import {TemplateElement} from "../TemplateElement";
import {ScriptAccountCondition} from "../../gamesystems/conditions/ScriptAccountCondition";
export class SimpleTemplateState extends SimpleState {
conditionMap: Map<TemplateElement, ScriptAccountCondition[]> = new Map();
addTemplateElement(templateElement: TemplateElement) {
this.conditionMap.set(templateElement, [])
}
removeTemplateElement(templateElement: TemplateElement) {
this.conditionMap.delete(templateElement)
}
}

View File

@ -0,0 +1,19 @@
import {SimpleTransition} from "../../gamesystems/transitions/SimpleTransition";
import {TemplateElement} from "../TemplateElement";
import {ScriptAccountCondition} from "../../gamesystems/conditions/ScriptAccountCondition";
import {ScriptAccountAction} from "../../gamesystems/actions/ScriptAccountAction";
export class SimpleTemplateTransition extends SimpleTransition{
conditionMap: Map<TemplateElement, ScriptAccountCondition[]> = new Map();
actionMap: Map<TemplateElement, ScriptAccountAction[]> = new Map();
addTemplateElement(templateElement: TemplateElement) {
this.conditionMap.set(templateElement, [])
this.actionMap.set(templateElement, [])
}
removeTemplateElement(templateElement: TemplateElement) {
this.conditionMap.delete(templateElement)
this.actionMap.delete(templateElement)
}
}

View File

@ -0,0 +1,6 @@
{
"componentName": "NormalGamesystem",
"componentDescription": "",
"states": [],
"transitions": []
}

View File

@ -0,0 +1,7 @@
{
"componentName": "TemplateGamesystem",
"componentDescription": "",
"states": [],
"transitions": [],
"templateType": 0
}