diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 23968d5..152535a 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -88,6 +88,9 @@ import {ItemEditorComponent} from "./editor/items/item-editor/item-editor.compon import { ItemgroupInheritorComponent } from "./editor/items/item-editor/itemgroup-inheritor/itemgroup-inheritor.component"; +import { + InheritedItemCharacteristicEditorComponent +} from "./editor/items/item-editor/inherited-item-characteristic-editor/inherited-item-characteristic-editor.component"; // AoT requires an exported function for factories const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new TranslateHttpLoader(http, './assets/i18n/', '.json'); @@ -116,7 +119,8 @@ const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new Transl ItemOverviewComponent, ItemGroupEditorComponent, ItemEditorComponent, - ItemgroupInheritorComponent + ItemgroupInheritorComponent, + InheritedItemCharacteristicEditorComponent ], imports: [ BrowserModule, diff --git a/src/app/editor/items/item-editor/item-editor.component.html b/src/app/editor/items/item-editor/item-editor.component.html index e3b6fc9..c15b565 100644 --- a/src/app/editor/items/item-editor/item-editor.component.html +++ b/src/app/editor/items/item-editor/item-editor.component.html @@ -9,7 +9,7 @@ {{itemgroup.componentName}} {{itemgroup.componentDescription}} - +
diff --git a/src/app/editor/items/item-editor/item-editor.component.ts b/src/app/editor/items/item-editor/item-editor.component.ts index d5a13fc..d259cb1 100644 --- a/src/app/editor/items/item-editor/item-editor.component.ts +++ b/src/app/editor/items/item-editor/item-editor.component.ts @@ -16,6 +16,8 @@ export class ItemEditorComponent { @Input() item: Item | undefined @Input() gameModel: GameModel | undefined; + + constructor(private dialog: MatDialog) { } diff --git a/src/app/editor/items/item-group-editor/item-group-editor.component.ts b/src/app/editor/items/item-group-editor/item-group-editor.component.ts index f973998..c47c0aa 100644 --- a/src/app/editor/items/item-group-editor/item-group-editor.component.ts +++ b/src/app/editor/items/item-group-editor/item-group-editor.component.ts @@ -20,7 +20,6 @@ export class ItemGroupEditorComponent implements OnInit{ ngOnInit(): void { - this.itemgroup!.itemGroupCharacteristics.push(new ItemGroupCharacteristic("Inventory", "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.")) this.itemQualityDatasource.data = this.itemgroup!.itemGroupCharacteristics; } @@ -38,7 +37,7 @@ export class ItemGroupEditorComponent implements OnInit{ } addItemgroupCharacteristic() { - const itemgroupCharacteristic = new ItemGroupCharacteristic("", ""); + const itemgroupCharacteristic = new ItemGroupCharacteristic("", "", this.itemgroup!); this.itemgroup!.itemGroupCharacteristics.push(itemgroupCharacteristic); this.itemQualityDatasource.data = this.itemgroup!.itemGroupCharacteristics; this.editedCharacteristic = itemgroupCharacteristic; diff --git a/src/app/project/game-model/inventory/AbstractItemGroup.ts b/src/app/project/game-model/inventory/AbstractItemGroup.ts index 9cb8a32..e1b058a 100644 --- a/src/app/project/game-model/inventory/AbstractItemGroup.ts +++ b/src/app/project/game-model/inventory/AbstractItemGroup.ts @@ -6,5 +6,6 @@ export class AbstractItemGroup extends ItemGroup { addChildItemgroup(itemGroup: ItemGroup) { this.children.push(itemGroup) + itemGroup.parentGroup = this; } } diff --git a/src/app/project/game-model/inventory/Item.ts b/src/app/project/game-model/inventory/Item.ts index e978f12..6241ca9 100644 --- a/src/app/project/game-model/inventory/Item.ts +++ b/src/app/project/game-model/inventory/Item.ts @@ -1,11 +1,27 @@ import {ModelComponent} from "../ModelComponent"; import {ItemGroup} from "./ItemGroup"; import {ItemgroupCharacteristicValue} from "./ItemgroupCharacteristicValue"; +import {ItemGroupCharacteristic} from "./ItemgroupCharacteristic"; export class Item extends ModelComponent { inheritedGroups: ItemGroup[] = [] - itemCharacteristics: ItemgroupCharacteristicValue[] = [] + itemCharacteristicValues: ItemgroupCharacteristicValue[] = [] + + initializeItemCharacteristics() { + this.inheritedGroups.forEach(itemGroup => { + itemGroup.itemGroupCharacteristics.forEach(characteristic => { + const characteristicValue = new ItemgroupCharacteristicValue(characteristic, 0); + if(!this.isValueInitialized(characteristic)) { + this.itemCharacteristicValues.push(characteristicValue); + } + }) + }) + } + + private isValueInitialized(characteristic: ItemGroupCharacteristic) { + return this.itemCharacteristicValues.find(value => value.key.characteristicName === characteristic.characteristicName) !== undefined + } addInheritedGroup(itemgroup: ItemGroup) { if(this.findItemgroupByName(itemgroup.componentName) == undefined) { diff --git a/src/app/project/game-model/inventory/ItemGroup.ts b/src/app/project/game-model/inventory/ItemGroup.ts index 471aa9e..9205238 100644 --- a/src/app/project/game-model/inventory/ItemGroup.ts +++ b/src/app/project/game-model/inventory/ItemGroup.ts @@ -1,8 +1,10 @@ import {ModelComponent} from "../ModelComponent"; import {ItemGroupCharacteristic} from "./ItemgroupCharacteristic"; +import {AbstractItemGroup} from "./AbstractItemGroup"; export abstract class ItemGroup extends ModelComponent { itemGroupCharacteristics: ItemGroupCharacteristic[] = [] + parentGroup: AbstractItemGroup | undefined } diff --git a/src/app/project/game-model/inventory/ItemgroupCharacteristic.ts b/src/app/project/game-model/inventory/ItemgroupCharacteristic.ts index 11fdda6..d28b9a1 100644 --- a/src/app/project/game-model/inventory/ItemgroupCharacteristic.ts +++ b/src/app/project/game-model/inventory/ItemgroupCharacteristic.ts @@ -1,10 +1,14 @@ +import {ItemGroup} from "./ItemGroup"; + export class ItemGroupCharacteristic { characteristicName: string; characteristicDescription: string + itemgroup: ItemGroup - constructor(characteristicName: string, characteristicDescription: string) { + constructor(characteristicName: string, characteristicDescription: string, itemgroup: ItemGroup) { this.characteristicName = characteristicName; this.characteristicDescription = characteristicDescription; + this.itemgroup = itemgroup; } }