Compare commits
No commits in common. "6912b4cc288c3658dcaf39e10217b17f47c60d7d" and "1f1cf3f9767bf7ec4577f727b8419812b3978c5a" have entirely different histories.
6912b4cc28
...
1f1cf3f976
@ -104,13 +104,13 @@ function createWindow(): BrowserWindow {
|
||||
{
|
||||
label: "Abstract Itemgroup",
|
||||
click: () => {
|
||||
win!.webContents.send('context-menu', "new-itemgroup-abstract")
|
||||
win!.webContents.send('context-menu', "new-itemgroup_abstract")
|
||||
}
|
||||
},
|
||||
{
|
||||
label: "Concrete Itemgroup",
|
||||
click: () => {
|
||||
win!.webContents.send('context-menu', "new-itemgroup-concrete")
|
||||
win!.webContents.send('context-menu', "new-itemgroup_concrete")
|
||||
}
|
||||
},
|
||||
{
|
||||
|
44
e2e/game-model/gamesystems/CreateGamesystem.spec.ts
Normal file
44
e2e/game-model/gamesystems/CreateGamesystem.spec.ts
Normal file
@ -0,0 +1,44 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
import {GamesystemTrainer} from "./GamesystemTrainer";
|
||||
import {ProductGamesystem} from "../../../src/app/project/game-model/gamesystems/ProductGamesystem";
|
||||
test.describe('Test Create Gamesystems', () => {
|
||||
|
||||
test('Test creating gamesystem with invalid name', async => {
|
||||
const gameModel = GamesystemTrainer.givenEmptyGameModel();
|
||||
let result = gameModel.createGamesystem(undefined, undefined);
|
||||
expect(result).toBeUndefined();
|
||||
|
||||
result = gameModel.createGamesystem(null, undefined);
|
||||
expect(result).toBeUndefined();
|
||||
})
|
||||
|
||||
test("Test creating gamesystem with valid name but without parent", async => {
|
||||
const gameModel = GamesystemTrainer.givenEmptyGameModel();
|
||||
let result = gameModel.createGamesystem(GamesystemTrainer.SIMPLEGAMESYSTEMNAME, undefined);
|
||||
expect(result).toBeDefined();
|
||||
expect(gameModel.gamesystems.length).toEqual(1);
|
||||
expect(gameModel.findGamesystem(GamesystemTrainer.SIMPLEGAMESYSTEMNAME)).toBeDefined();
|
||||
})
|
||||
|
||||
test("Test creating Gamesystem with valid name but with Product Parent", async => {
|
||||
const gameModel = GamesystemTrainer.givenGameModelWithProductGamesytemOnTopLayer();
|
||||
let result = gameModel.createGamesystem(GamesystemTrainer.SIMPLEGAMESYSTEM_LEAF_LEFT, GamesystemTrainer.TOP_PRODUCT_GAMESYSTEM_NAME);
|
||||
expect(result).toBeDefined();
|
||||
expect(result.parentGamesystem!.componentName).toEqual(GamesystemTrainer.TOP_PRODUCT_GAMESYSTEM_NAME);
|
||||
expect(result.parentGamesystem!.innerGamesystems.length).toEqual(3);
|
||||
expect(result.parentGamesystem!.innerGamesystems.includes(result)).toBeTruthy();
|
||||
})
|
||||
|
||||
test("Test creating Gamesystem with valid name but with Simple Parent", async() => {
|
||||
const gameModel = GamesystemTrainer.givenGameModelWithSimpleGamesystemOnTopLayer();
|
||||
let result = gameModel.createGamesystem(GamesystemTrainer.SIMPLEGAMESYSTEM_LEAF_LEFT, GamesystemTrainer.SIMPLEGAMESYSTEMNAME);
|
||||
expect(result).toBeDefined();
|
||||
expect(gameModel.gamesystems.length).toEqual(1);
|
||||
expect(gameModel.gamesystems[0]).toBeInstanceOf(ProductGamesystem);
|
||||
expect(gameModel.gamesystems[0]).toEqual(result.parentGamesystem);
|
||||
expect((gameModel.gamesystems[0] as ProductGamesystem).innerGamesystems.length).toEqual(1);
|
||||
expect((gameModel.gamesystems[0] as ProductGamesystem).innerGamesystems.includes(result)).toBeTruthy();
|
||||
})
|
||||
|
||||
|
||||
});
|
71
e2e/game-model/scriptAccounts/ScriptAccountTest.spec.ts
Normal file
71
e2e/game-model/scriptAccounts/ScriptAccountTest.spec.ts
Normal file
@ -0,0 +1,71 @@
|
||||
import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright';
|
||||
import { test, expect } from '@playwright/test';
|
||||
import * as PATH from 'path';
|
||||
import {GameModel} from "../../../src/app/project/game-model/GameModel";
|
||||
import {Gamesystem} from "../../src/app/project/game-model/gamesystems/Gamesystem";
|
||||
import {ScriptAccount} from "../../../src/app/project/game-model/scriptAccounts/ScriptAccount";
|
||||
import {ModelComponentType} from "../../../src/app/project/game-model/ModelComponentType";
|
||||
|
||||
test.describe('Test ScriptAccounts', () => {
|
||||
|
||||
test("Test ScriptAccount Creation", async () => {
|
||||
const scriptAccunt = new ScriptAccount("ScriptAccount", "Description");
|
||||
|
||||
expect(scriptAccunt.componentName).toEqual("ScriptAccount");
|
||||
expect(scriptAccunt.componentDescription).toEqual("Description");
|
||||
expect(scriptAccunt.type).toEqual(ModelComponentType.SCRIPTACCOUNT);
|
||||
expect(scriptAccunt.minValue).toEqual(0);
|
||||
expect(scriptAccunt.maxValue).toEqual(100);
|
||||
})
|
||||
|
||||
test("Test Adding ScriptAccounts", async () => {
|
||||
const gameModel: GameModel = new GameModel("GameModel");
|
||||
|
||||
let scriptAccount =gameModel.createScriptAccount("ScriptAccount");
|
||||
expect(scriptAccount).toBeDefined();
|
||||
expect(gameModel.scriptAccounts.length).toEqual(1);
|
||||
expect(gameModel.scriptAccounts.includes(scriptAccount)).toBeTruthy();
|
||||
|
||||
//Test adding scriptAccount with already existing name
|
||||
const scriptAccount2 = gameModel.createScriptAccount("ScriptAccount")
|
||||
expect(scriptAccount2).toBeUndefined();
|
||||
expect(gameModel.scriptAccounts.length).toEqual(1);
|
||||
|
||||
//Test for adding invalid names as scriptaccount names (null/undefined/empty)
|
||||
let result = gameModel.createScriptAccount(null);
|
||||
expect(result).toBeUndefined();
|
||||
expect(gameModel.scriptAccounts.length).toEqual(1);
|
||||
result = gameModel.createScriptAccount(undefined);
|
||||
expect(result).toBeUndefined();
|
||||
expect(gameModel.scriptAccounts.length).toEqual(1);
|
||||
result = gameModel.createScriptAccount("");
|
||||
expect(result).toBeUndefined();
|
||||
expect(gameModel.scriptAccounts.length).toEqual(1);
|
||||
})
|
||||
|
||||
test("test Removing ScriptAccounts", async () => {
|
||||
const gameModel: GameModel = new GameModel("GameModel");
|
||||
let scriptAccount = new ScriptAccount("test", "")
|
||||
|
||||
gameModel.removeScriptAccount(scriptAccount);
|
||||
expect(gameModel.scriptAccounts.length).toEqual(0);
|
||||
|
||||
scriptAccount = gameModel.createScriptAccount("ScriptAccount");
|
||||
gameModel.removeScriptAccount(scriptAccount);
|
||||
expect(gameModel.scriptAccounts.length).toEqual(0);
|
||||
|
||||
gameModel.removeScriptAccount(undefined);
|
||||
expect(gameModel.scriptAccounts.length).toEqual(0);
|
||||
|
||||
gameModel.removeScriptAccount(null);
|
||||
expect(gameModel.scriptAccounts.length).toEqual(0);
|
||||
|
||||
scriptAccount = gameModel.createScriptAccount(scriptAccount);
|
||||
let scriptAccount2 = gameModel.createScriptAccount("ScriptAccount 2");
|
||||
|
||||
gameModel.removeScriptAccount(scriptAccount);
|
||||
expect(gameModel.scriptAccounts.length).toEqual(1);
|
||||
expect(gameModel.scriptAccounts.includes(scriptAccount2)).toBeTruthy();
|
||||
})
|
||||
|
||||
});
|
@ -25,17 +25,11 @@ import {CharacterOverviewComponent} from "./side-overviews/character-overview/ch
|
||||
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";
|
||||
import {SimpleTemplateGamesystem} from "./project/game-model/templates/simpleGamesystem/SimpleTemplateGamesystem";
|
||||
import {ItemSerializer} from "./project/serializer/ItemSerializer";
|
||||
import {ItemgroupParser} from "./project/parser/itemParser/ItemgroupParser";
|
||||
import {ItemParser} from "./project/parser/itemParser/ItemParser";
|
||||
import {ItemgroupCreator} from "./project/game-model/utils/creator/ItemgroupCreator";
|
||||
import {ItemOverviewComponent} from "./side-overviews/item-overview/item-overview.component";
|
||||
import {Overview} from "./side-overviews/Overview";
|
||||
import {ItemCreator} from "./project/game-model/utils/creator/ItemCreator";
|
||||
import {ScriptAccountCreator} from "./project/game-model/utils/creator/ScriptAccountCreator";
|
||||
import {CharacterCreator} from "./project/game-model/utils/creator/CharacterCreator";
|
||||
import {GamesystemCreator} from "./project/game-model/utils/creator/GamesystemCreator";
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
@ -50,7 +44,6 @@ export class AppComponent implements OnInit{
|
||||
@ViewChild('scriptAccountOverview') scriptAccountOverview: ScriptAccountOverviewComponent | undefined
|
||||
@ViewChild('gamesystemOverview') gamesystemOverview: GamescriptOverviewComponent | undefined
|
||||
@ViewChild('characterOverview') characterOverview: CharacterOverviewComponent | undefined
|
||||
@ViewChild('itemOverview') itemOverview: ItemOverviewComponent | undefined
|
||||
|
||||
gameModel: GameModel | undefined
|
||||
|
||||
@ -89,46 +82,13 @@ export class AppComponent implements OnInit{
|
||||
} else if(message.startsWith("new")) {
|
||||
const splittedMessage = message.split("-");
|
||||
const modelComponentType = ModelComponentTypeUtillities.fromString(splittedMessage[1]);
|
||||
if(modelComponentType !== undefined) {
|
||||
let creationContext = "";
|
||||
if(splittedMessage.length > 2) {
|
||||
creationContext = splittedMessage[2];
|
||||
}
|
||||
|
||||
let componentCreator;
|
||||
switch (modelComponentType) {
|
||||
case ModelComponentType.ITEMGROUP: {
|
||||
componentCreator = new ItemgroupCreator(creationContext, this.gameModel!, this.selectedModelComponent);
|
||||
} break
|
||||
case ModelComponentType.ITEM: {
|
||||
componentCreator = new ItemCreator(creationContext, this.gameModel!, this.selectedModelComponent);
|
||||
} break
|
||||
case ModelComponentType.SCRIPTACCOUNT: {
|
||||
componentCreator = new ScriptAccountCreator(creationContext, this.gameModel!, this.selectedModelComponent);
|
||||
} break
|
||||
case ModelComponentType.CHARACTER: {
|
||||
componentCreator = new CharacterCreator(creationContext, this.gameModel!, this.selectedModelComponent);
|
||||
} break
|
||||
case ModelComponentType.GAMESYTEM: {
|
||||
componentCreator = new GamesystemCreator(creationContext, this.gameModel!, this.selectedModelComponent);
|
||||
} break
|
||||
}
|
||||
|
||||
if(componentCreator) {
|
||||
const createdModel = componentCreator.createModelComponent();
|
||||
this.openModelComponent(createdModel!)
|
||||
|
||||
const openedOverview = this.openedOverview;
|
||||
if(openedOverview) {
|
||||
openedOverview.refresh()
|
||||
}
|
||||
|
||||
const templateType = TemplateTypeUtilities.fromString(splittedMessage[2]);
|
||||
if(modelComponentType != undefined) {
|
||||
this.onCreateModelComponent(modelComponentType, templateType);
|
||||
} else {
|
||||
console.log("[ERROR] Unknown Creation Command: ", message)
|
||||
console.log("[ERROR] [App-Component] Unknown Context-Menu Command!")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private onEditModelComponent() {
|
||||
@ -150,7 +110,6 @@ export class AppComponent implements OnInit{
|
||||
}
|
||||
}break
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -175,6 +134,53 @@ export class AppComponent implements OnInit{
|
||||
})
|
||||
}
|
||||
|
||||
private onCreateModelComponent(modelComponentType: ModelComponentType, templateType: TemplateType | undefined) {
|
||||
switch (modelComponentType) {
|
||||
case ModelComponentType.SCRIPTACCOUNT: this.onCreateNewScriptAccount(); break
|
||||
case ModelComponentType.GAMESYTEM: this.onCreateNewGamesystem(templateType); break
|
||||
case ModelComponentType.CHARACTER: this.onCreateNewCharacter(); break
|
||||
}
|
||||
}
|
||||
|
||||
private onCreateNewScriptAccount() {
|
||||
const createdScriptAccount = this.gameModel!.createScriptAccount("New ScriptAccount");
|
||||
if(createdScriptAccount != undefined) {
|
||||
this.editor?.openGameModelComponent(createdScriptAccount);
|
||||
} else {
|
||||
console.log("[DEBUG] [App-Component] ScriptAccount could not be created (Name not unique)");
|
||||
}
|
||||
}
|
||||
|
||||
private onCreateNewGamesystem(templateType: TemplateType | undefined) {
|
||||
let parentGamesystemName = undefined
|
||||
if(this.openContent != ModelComponentType.GAMESYTEM) {
|
||||
this.openGamesystemsOverview();
|
||||
} else {
|
||||
parentGamesystemName = this.gamesystemOverview!.selectedGamesystemName;
|
||||
}
|
||||
|
||||
|
||||
let createdGamesystem;
|
||||
if(parentGamesystemName == undefined) {
|
||||
createdGamesystem = this.gameModel?.createSimpleGamesystem("New Gamesystem", templateType);
|
||||
} else {
|
||||
createdGamesystem = this.gameModel!.createSimpleGamesystemWithParent("New Gamesystem", parentGamesystemName, templateType)
|
||||
}
|
||||
|
||||
if(createdGamesystem != undefined) {
|
||||
this.gamesystemOverview!.refresh();
|
||||
this.editor?.openGameModelComponent(createdGamesystem);
|
||||
}
|
||||
}
|
||||
|
||||
private onCreateNewCharacter() {
|
||||
const createdCharacter = this.gameModel!.createCharacter("New Character")
|
||||
if(createdCharacter != undefined) {
|
||||
this.editor?.openGameModelComponent(createdCharacter);
|
||||
} else {
|
||||
console.log("[DEBUG] [App-Component] ScriptAccount could not be created (Name not unique)");
|
||||
}
|
||||
}
|
||||
|
||||
private getSelectedModelComponent(): ModelComponent | undefined {
|
||||
if(this.openContent == ModelComponentType.SCRIPTACCOUNT) {
|
||||
@ -297,26 +303,6 @@ export class AppComponent implements OnInit{
|
||||
}
|
||||
}
|
||||
|
||||
get selectedModelComponent(): ModelComponent | undefined {
|
||||
switch (this.openContent) {
|
||||
case ModelComponentType.GAMESYTEM: return this.gamesystemOverview!.getSelectedGamesystem();
|
||||
case ModelComponentType.CHARACTER: return this.characterOverview!.selectedCharacter;
|
||||
case ModelComponentType.SCRIPTACCOUNT: return this.scriptAccountOverview!.selectedScriptAccount;
|
||||
case ModelComponentType.ITEMGROUP: return this.itemOverview!.selectedModelComponent;
|
||||
case ModelComponentType.ITEM: return this.itemOverview!.selectedModelComponent;
|
||||
default: return undefined
|
||||
}
|
||||
}
|
||||
|
||||
get openedOverview(): Overview | undefined {
|
||||
if(this.openContent === ModelComponentType.ITEMGROUP || this.openContent === ModelComponentType.ITEM) {
|
||||
return this.itemOverview;
|
||||
} else if(this.openContent === ModelComponentType.SCRIPTACCOUNT) {
|
||||
return this.scriptAccountOverview;
|
||||
} else if(this.openContent === ModelComponentType.CHARACTER) {
|
||||
return this.characterOverview;
|
||||
} else if(this.openContent === ModelComponentType.GAMESYTEM) {
|
||||
return this.gamesystemOverview;
|
||||
}
|
||||
}
|
||||
protected readonly open = open;
|
||||
}
|
||||
|
@ -30,6 +30,47 @@ export class GameModel {
|
||||
this.gameModelName = gameModelName;
|
||||
}
|
||||
|
||||
addAbstractItemgroup(groupName: string, parentgroup: AbstractItemGroup | undefined) {
|
||||
//Ensure that Itemgroup does not exist
|
||||
if(parentgroup == undefined) {
|
||||
if(GameModel.findItemgroupByName(groupName, this.itemgroups) == undefined) {
|
||||
const itemgroup = new AbstractItemGroup(groupName, "", ModelComponentType.ITEMGROUP)
|
||||
this.itemgroups.push(itemgroup);
|
||||
itemgroup.addItemgroupCharacteristic(new ItemGroupCharacteristic("Test0", "", itemgroup));
|
||||
}
|
||||
} else {
|
||||
if(GameModel.findItemgroupByName(groupName, parentgroup.children) == undefined) {
|
||||
parentgroup.addChildItemgroup(new AbstractItemGroup(groupName, "", ModelComponentType.ITEMGROUP));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addConcreteItemgroup(groupName: string, parentgroup: AbstractItemGroup | undefined) {
|
||||
//Ensure that Itemgroup does not exist
|
||||
if(parentgroup == undefined) {
|
||||
if(GameModel.findItemgroupByName(groupName, this.itemgroups) == undefined) {
|
||||
this.itemgroups.push(new ConcreteItemGroup(groupName, "", ModelComponentType.ITEMGROUP));
|
||||
}
|
||||
} else {
|
||||
if(GameModel.findItemgroupByName(groupName, parentgroup.children) == undefined) {
|
||||
parentgroup.addChildItemgroup(new ConcreteItemGroup(groupName, "", ModelComponentType.ITEMGROUP));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addItem(itemName: string, conceteItemgroupName: string) {
|
||||
const itemgroup = GameModel.findItemgroupByName(conceteItemgroupName, this.itemgroups);
|
||||
if(itemgroup instanceof ConcreteItemGroup) {
|
||||
const itemgroups: ItemGroup[] = ItemgroupUtilities.findItemgroupPathToItemgroup(conceteItemgroupName, this.itemgroups);
|
||||
|
||||
if(itemgroups.length > 0) {
|
||||
const item = new Item(itemName, "", ModelComponentType.ITEM )
|
||||
itemgroup.addItem(item, itemgroups)
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static findItemgroupByName(name: string, itemgroups: ItemGroup[]) {
|
||||
const itemgroupQueue: ItemGroup[] = itemgroups.concat();
|
||||
@ -61,12 +102,16 @@ export class GameModel {
|
||||
}
|
||||
}
|
||||
|
||||
addScriptAccount(scriptAccount: ScriptAccount) {
|
||||
if(!this.scriptAccounts.find(sA => sA.componentName === scriptAccount.componentName)) {
|
||||
this.scriptAccounts.push(scriptAccount)
|
||||
return true;
|
||||
createScriptAccount(scriptAccountName: string) {
|
||||
if(scriptAccountName != undefined && scriptAccountName.length > 0) {
|
||||
const scriptAccount = new ScriptAccount(scriptAccountName, "");
|
||||
const searchedScriptAccount = this.scriptAccounts.find(s => s.componentName === scriptAccount.componentName);
|
||||
if(searchedScriptAccount == undefined) {
|
||||
this.scriptAccounts.push(scriptAccount);
|
||||
return scriptAccount;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
createSimpleGamesystem(gamesystemName: string, templateType: TemplateType | undefined, pushToTop: boolean = true) {
|
||||
@ -190,6 +235,10 @@ export class GameModel {
|
||||
}
|
||||
}
|
||||
|
||||
addScriptAccount(scriptAccount: ScriptAccount) {
|
||||
this.scriptAccounts.push(scriptAccount);
|
||||
}
|
||||
|
||||
generateProductSystemContents() {
|
||||
this.gamesystems.forEach(gamesystem => {
|
||||
if(gamesystem instanceof ProductGamesystem) {
|
||||
@ -232,12 +281,4 @@ export class GameModel {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
addCharacter(character: Character) {
|
||||
if(this.characters.find(c => c.componentName === character.componentName) === undefined) {
|
||||
this.characters.push(character)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -27,4 +27,5 @@ export abstract class Gamesystem<S, T> extends ModelComponent{
|
||||
this.transitions = updatedTransitions;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -32,12 +32,14 @@ export class ProductGamesystem extends Gamesystem<ProductState, ProductTransitio
|
||||
simpleGamesystem.parentGamesystem = this
|
||||
}
|
||||
|
||||
if(parentGamesystem == undefined || parentGamesystem.componentName === this.componentName) {
|
||||
gameModel.removeGamesystem(simpleGamesystem);
|
||||
this.addChildGamesystem(simpleGamesystem);
|
||||
} else {
|
||||
|
||||
if(parentGamesystem != undefined) {
|
||||
parentGamesystem.removeChildGamesystem(simpleGamesystem);
|
||||
parentGamesystem.addChildGamesystem(this);
|
||||
this.parentGamesystem = parentGamesystem
|
||||
} else {
|
||||
gameModel.removeGamesystem(simpleGamesystem);
|
||||
gameModel.addGamesystem(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,22 +0,0 @@
|
||||
import {ModelComponentCreator} from "./ModelComponentCreator";
|
||||
import {GameModel} from "../../GameModel";
|
||||
import {ModelComponent} from "../../ModelComponent";
|
||||
import {Character} from "../../characters/Character";
|
||||
|
||||
export class CharacterCreator extends ModelComponentCreator{
|
||||
|
||||
|
||||
constructor(context: string, gameModel: GameModel, selectedComponent: ModelComponent | undefined) {
|
||||
super(context, gameModel, selectedComponent);
|
||||
}
|
||||
|
||||
createModelComponent(): ModelComponent | undefined {
|
||||
const character = new Character("New Character", "");
|
||||
if(this.gameModel.addCharacter(character)) {
|
||||
return character;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
import {ModelComponentCreator} from "./ModelComponentCreator";
|
||||
import {GameModel} from "../../GameModel";
|
||||
import {ModelComponent} from "../../ModelComponent";
|
||||
import {TemplateTypeUtilities} from "../../templates/TemplateTypeUtilities";
|
||||
import {Gamesystem} from "../../gamesystems/Gamesystem";
|
||||
import {SimpleGamesystem} from "../../gamesystems/SimpleGamesystem";
|
||||
import {ProductGamesystem} from "../../gamesystems/ProductGamesystem";
|
||||
import {SimpleTemplateGamesystem} from "../../templates/simpleGamesystem/SimpleTemplateGamesystem";
|
||||
import {ProductTemplateCreator} from "../../templates/productGamesystem/ProductTemplateCreator";
|
||||
import {ProductTemplateSystem} from "../../templates/productGamesystem/ProductTemplateSystem";
|
||||
import {TemplateType} from "../../templates/TemplateType";
|
||||
|
||||
export class GamesystemCreator extends ModelComponentCreator{
|
||||
|
||||
|
||||
constructor(context: string, gameModel: GameModel, selectedComponent: ModelComponent | undefined) {
|
||||
super(context, gameModel, selectedComponent);
|
||||
}
|
||||
|
||||
createModelComponent(): ModelComponent | undefined {
|
||||
const templateType = TemplateTypeUtilities.fromString(this.context);
|
||||
let simpleGamesystem;
|
||||
if(templateType == undefined) /**Aka normal**/{
|
||||
simpleGamesystem = new SimpleGamesystem("New Simple Gamesystem", "");
|
||||
} else {
|
||||
simpleGamesystem = new SimpleTemplateGamesystem("New Simple Gamesystem", "", templateType)
|
||||
}
|
||||
|
||||
if(this.selectedComponent !== undefined && this.selectedComponent instanceof Gamesystem)/**Aka productGamesystem**/ {
|
||||
const productParentsystem: ProductGamesystem = this.constructProductFromSimple(this.selectedComponent, undefined)!
|
||||
productParentsystem.addChildGamesystem(simpleGamesystem);
|
||||
} else {
|
||||
this.gameModel!.gamesystems.push(simpleGamesystem);
|
||||
}
|
||||
|
||||
return simpleGamesystem;
|
||||
}
|
||||
|
||||
private constructProductFromSimple(simpleGamesystem: Gamesystem<any, any>, producttemplateType: TemplateType | undefined): ProductGamesystem | undefined {
|
||||
if(!(simpleGamesystem instanceof ProductTemplateSystem) && producttemplateType != undefined) {
|
||||
console.log("Wierd, Debug")
|
||||
return ProductTemplateCreator.convertProductToTemplate(simpleGamesystem as ProductGamesystem, this.gameModel, producttemplateType);
|
||||
}
|
||||
|
||||
if(simpleGamesystem instanceof ProductGamesystem) {
|
||||
console.log("Wierder Debug")
|
||||
return simpleGamesystem;
|
||||
}
|
||||
|
||||
let productGamesystem: ProductGamesystem
|
||||
if(producttemplateType != undefined) {
|
||||
productGamesystem = new ProductTemplateSystem(simpleGamesystem.componentName, simpleGamesystem.componentDescription, producttemplateType);
|
||||
} else {
|
||||
productGamesystem = new ProductGamesystem(simpleGamesystem.componentName, simpleGamesystem.componentDescription);
|
||||
}
|
||||
|
||||
this.constructGamesystemHierarchy(productGamesystem, simpleGamesystem as SimpleGamesystem)
|
||||
return productGamesystem;
|
||||
}
|
||||
|
||||
private constructGamesystemHierarchy(productGamesystem: ProductGamesystem, simpleGamesystem: SimpleGamesystem) {
|
||||
const simpleParentGamesystem = simpleGamesystem.parentGamesystem;
|
||||
|
||||
if(simpleGamesystem.states.length > 0) {
|
||||
simpleGamesystem.componentName += "(Child)";
|
||||
if(simpleParentGamesystem == undefined) {
|
||||
this.gameModel.removeGamesystem(simpleGamesystem);
|
||||
productGamesystem.addChildGamesystem(simpleGamesystem);
|
||||
this.gameModel.addGamesystem(productGamesystem);
|
||||
} else {
|
||||
simpleParentGamesystem.removeChildGamesystem(simpleGamesystem);
|
||||
productGamesystem.addChildGamesystem(simpleGamesystem);
|
||||
simpleParentGamesystem.addChildGamesystem(productGamesystem);
|
||||
}
|
||||
} else {
|
||||
if(simpleParentGamesystem == undefined) {
|
||||
this.gameModel.removeGamesystem(simpleGamesystem);
|
||||
this.gameModel.addGamesystem(productGamesystem);
|
||||
} else {
|
||||
simpleParentGamesystem.removeChildGamesystem(simpleGamesystem);
|
||||
simpleParentGamesystem.addChildGamesystem(productGamesystem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
import {ModelComponentCreator} from "./ModelComponentCreator";
|
||||
import {GameModel} from "../../GameModel";
|
||||
import {ModelComponent} from "../../ModelComponent";
|
||||
import {Item} from "../../inventory/Item";
|
||||
import {ModelComponentType} from "../../ModelComponentType";
|
||||
import {ConcreteItemGroup} from "../../inventory/ConcreteItemGroup";
|
||||
import {ItemGroup} from "../../inventory/ItemGroup";
|
||||
|
||||
export class ItemCreator extends ModelComponentCreator {
|
||||
|
||||
|
||||
constructor(context: string, gameModel: GameModel, selectedComponent: ModelComponent | undefined) {
|
||||
super(context, gameModel, selectedComponent);
|
||||
}
|
||||
|
||||
createModelComponent(): ModelComponent | undefined {
|
||||
if(this.selectedComponent != undefined && this.selectedComponent instanceof ConcreteItemGroup) {
|
||||
const item = new Item("New Item", "", ModelComponentType.ITEM);
|
||||
this.selectedComponent.addItem(item, this.getInheritedGroups(this.selectedComponent))
|
||||
return item;
|
||||
} else {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
private getInheritedGroups(baseGroup: ItemGroup): ItemGroup[] {
|
||||
const itemgroups: ItemGroup[] = []
|
||||
let currentGroup: ItemGroup | undefined = baseGroup;
|
||||
while(currentGroup != undefined) {
|
||||
itemgroups.push(currentGroup);
|
||||
currentGroup = currentGroup.parentGroup;
|
||||
}
|
||||
return itemgroups;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
import {ModelComponentCreator} from "./ModelComponentCreator";
|
||||
import {ModelComponent} from "../../ModelComponent";
|
||||
import {GameModel} from "../../GameModel";
|
||||
import {AbstractItemGroup} from "../../inventory/AbstractItemGroup";
|
||||
import {ModelComponentType} from "../../ModelComponentType";
|
||||
import {ConcreteItemGroup} from "../../inventory/ConcreteItemGroup";
|
||||
|
||||
export class ItemgroupCreator extends ModelComponentCreator {
|
||||
|
||||
|
||||
|
||||
constructor(context: string, gameModel: GameModel, selectedComponent: ModelComponent | undefined) {
|
||||
super(context, gameModel, selectedComponent);
|
||||
}
|
||||
|
||||
createModelComponent(): ModelComponent | undefined{
|
||||
let itemgroup;
|
||||
if(this.context === 'abstract') {
|
||||
itemgroup = new AbstractItemGroup("New Abstract Itemgroup", "", ModelComponentType.ITEMGROUP);
|
||||
} else if(this.context === 'concrete') {
|
||||
itemgroup = new ConcreteItemGroup("New Concrete Itemgroup", "", ModelComponentType.ITEMGROUP);
|
||||
} else {
|
||||
return undefined
|
||||
}
|
||||
|
||||
if(this.selectedComponent != null && this.selectedComponent instanceof AbstractItemGroup) {
|
||||
this.selectedComponent.addChildItemgroup(itemgroup);
|
||||
} else {
|
||||
this.gameModel.itemgroups.push(itemgroup);
|
||||
}
|
||||
|
||||
return itemgroup;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
import {ModelComponent} from "../../ModelComponent";
|
||||
import {GameModel} from "../../GameModel";
|
||||
import {Overview} from "../../../../side-overviews/Overview";
|
||||
|
||||
export abstract class ModelComponentCreator {
|
||||
context: string;
|
||||
gameModel: GameModel
|
||||
selectedComponent: ModelComponent | undefined
|
||||
|
||||
|
||||
protected constructor(context: string, gameModel: GameModel, selectedComponent: ModelComponent | undefined) {
|
||||
this.context = context;
|
||||
this.gameModel = gameModel;
|
||||
this.selectedComponent = selectedComponent;
|
||||
}
|
||||
|
||||
abstract createModelComponent(): ModelComponent | undefined;
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
import {ModelComponentCreator} from "./ModelComponentCreator";
|
||||
import {GameModel} from "../../GameModel";
|
||||
import {ModelComponent} from "../../ModelComponent";
|
||||
import {ScriptAccount} from "../../scriptAccounts/ScriptAccount";
|
||||
|
||||
export class ScriptAccountCreator extends ModelComponentCreator {
|
||||
|
||||
constructor(context: string, gameModel: GameModel, selectedComponent: ModelComponent | undefined) {
|
||||
super(context, gameModel, selectedComponent);
|
||||
}
|
||||
|
||||
createModelComponent(): ModelComponent | undefined {
|
||||
const scriptAccount = new ScriptAccount("New ScriptAccount", "");
|
||||
if(this.gameModel.addScriptAccount(scriptAccount)) {
|
||||
return scriptAccount;
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
export interface Overview {
|
||||
refresh(): void
|
||||
}
|
@ -5,17 +5,13 @@ import {MatIcon} from "@angular/material/icon";
|
||||
import {NgClass, NgForOf} from "@angular/common";
|
||||
import {ScriptAccount} from "../../project/game-model/scriptAccounts/ScriptAccount";
|
||||
import {Character} from "../../project/game-model/characters/Character";
|
||||
import {Overview} from "../Overview";
|
||||
|
||||
@Component({
|
||||
selector: 'app-character-overview',
|
||||
templateUrl: './character-overview.component.html',
|
||||
styleUrl: './character-overview.component.scss'
|
||||
})
|
||||
export class CharacterOverviewComponent implements Overview{
|
||||
refresh(): void {
|
||||
//Nothing to-do
|
||||
}
|
||||
export class CharacterOverviewComponent {
|
||||
|
||||
@Input() gameModel: GameModel | undefined
|
||||
@Output("onOpenCharacterEditor") openCharacterEmitter: EventEmitter<Character> = new EventEmitter<Character>();
|
||||
|
@ -8,7 +8,6 @@ import {State} from "../../project/game-model/gamesystems/states/State";
|
||||
import {Transition} from "../../project/game-model/gamesystems/transitions/Transition";
|
||||
import {ProductGamesystem} from "../../project/game-model/gamesystems/ProductGamesystem";
|
||||
import {SimpleGamesystem} from "../../project/game-model/gamesystems/SimpleGamesystem";
|
||||
import {Overview} from "../Overview";
|
||||
|
||||
|
||||
interface FlatNode {
|
||||
@ -21,7 +20,7 @@ interface FlatNode {
|
||||
templateUrl: './gamescript-overview.component.html',
|
||||
styleUrl: './gamescript-overview.component.scss'
|
||||
})
|
||||
export class GamescriptOverviewComponent implements OnInit, Overview {
|
||||
export class GamescriptOverviewComponent implements OnInit {
|
||||
|
||||
@Input('gameModel') gameModel: GameModel | undefined
|
||||
@Output('openGamesystemEditor') openGamesystemEmitter : EventEmitter<Gamesystem<State<any>, Transition<any>>> = new EventEmitter<Gamesystem<State<any>, Transition<any>>>();
|
||||
|
@ -8,7 +8,6 @@ import {ModelComponent} from "../../project/game-model/ModelComponent";
|
||||
import {ModelComponentType} from "../../project/game-model/ModelComponentType";
|
||||
import {ItemGroup} from "../../project/game-model/inventory/ItemGroup";
|
||||
import {Item} from "../../project/game-model/inventory/Item";
|
||||
import {Overview} from "../Overview";
|
||||
|
||||
interface FlatNode {
|
||||
expandable: boolean,
|
||||
@ -22,7 +21,7 @@ interface FlatNode {
|
||||
templateUrl: './item-overview.component.html',
|
||||
styleUrl: './item-overview.component.scss'
|
||||
})
|
||||
export class ItemOverviewComponent implements OnInit, Overview{
|
||||
export class ItemOverviewComponent implements OnInit{
|
||||
|
||||
@Input() gameModel: GameModel | undefined
|
||||
@Output() openItemgroupEmitter: EventEmitter<ItemGroup> = new EventEmitter();
|
||||
@ -121,33 +120,4 @@ export class ItemOverviewComponent implements OnInit, Overview{
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
get selectedModelComponent() {
|
||||
if(this.selectedItem) {
|
||||
if(this.selectedItem.type === ModelComponentType.ITEMGROUP) {
|
||||
let groupQueue: ItemGroup[] = this.gameModel!.itemgroups.concat();
|
||||
while(groupQueue.length > 0) {
|
||||
const currentGroup = groupQueue.shift()!;
|
||||
|
||||
if(currentGroup.componentName === this.selectedItem.name) {
|
||||
return currentGroup;
|
||||
}
|
||||
|
||||
if(currentGroup instanceof AbstractItemGroup) {
|
||||
groupQueue = groupQueue.concat(currentGroup.children);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return this.searchItemByName(this.selectedItem!.name)
|
||||
}
|
||||
} else {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
refresh(): void {
|
||||
this.dataSource.data = this.gameModel!.itemgroups;
|
||||
console.log("Opened Refreshed")
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,14 +2,13 @@ import {Component, EventEmitter, Input, NgZone, Output} from '@angular/core';
|
||||
import {ElectronService} from "../../core/services";
|
||||
import {GameModel} from "../../project/game-model/GameModel";
|
||||
import {ScriptAccount} from "../../project/game-model/scriptAccounts/ScriptAccount";
|
||||
import {Overview} from "../Overview";
|
||||
|
||||
@Component({
|
||||
selector: 'app-script-account-overview',
|
||||
templateUrl: './script-account-overview.component.html',
|
||||
styleUrl: './script-account-overview.component.css'
|
||||
})
|
||||
export class ScriptAccountOverviewComponent implements Overview{
|
||||
export class ScriptAccountOverviewComponent {
|
||||
@Input("gameModel") gameModel: GameModel | undefined
|
||||
@Output("onOpenScriptAccount") openScriptAccountEmitter: EventEmitter<ScriptAccount> = new EventEmitter<ScriptAccount>();
|
||||
|
||||
@ -18,10 +17,6 @@ export class ScriptAccountOverviewComponent implements Overview{
|
||||
constructor() {
|
||||
}
|
||||
|
||||
refresh(): void {
|
||||
//Nothing to do
|
||||
}
|
||||
|
||||
onOpenScriptAccount(scriptAccount: ScriptAccount) {
|
||||
console.log("onOpenScriptAccount (overview)")
|
||||
this.openScriptAccountEmitter.emit(scriptAccount);
|
||||
|
@ -1,7 +0,0 @@
|
||||
{
|
||||
"componentName": "Parentgamesystem",
|
||||
"componentDescription": "",
|
||||
"states": [],
|
||||
"transitions": [],
|
||||
"generateIsolatedStates": false
|
||||
}
|
@ -7,5 +7,5 @@
|
||||
"characteristicDescription": ""
|
||||
}
|
||||
],
|
||||
"itemgroupType": 0
|
||||
"itemgroupType": 1
|
||||
}
|
Loading…
Reference in New Issue
Block a user