inventory-items-2 #44

Closed
sebastian wants to merge 32 commits from inventory-items-2 into inventory
8 changed files with 34 additions and 6 deletions
Showing only changes of commit 6e65cc3a6a - Show all commits

View File

@ -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,

View File

@ -9,7 +9,7 @@
<mat-panel-title>{{itemgroup.componentName}}</mat-panel-title>
<mat-panel-description>{{itemgroup.componentDescription}}</mat-panel-description>
</mat-expansion-panel-header>
<app-inherited-item-characteristic-editor [inheritedItemgroup]="itemgroup" [item]="item"></app-inherited-item-characteristic-editor>
<div class="panel-actions">
<button mat-raised-button color="warn" [disabled]="automaticallyInheritedItemgroups.includes(itemgroup)" (click)="deleteInheritedItemgroup(itemgroup)">Delete</button>
</div>

View File

@ -16,6 +16,8 @@ export class ItemEditorComponent {
@Input() item: Item | undefined
@Input() gameModel: GameModel | undefined;
constructor(private dialog: MatDialog) {
}

View File

@ -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;

View File

@ -6,5 +6,6 @@ export class AbstractItemGroup extends ItemGroup {
addChildItemgroup(itemGroup: ItemGroup) {
this.children.push(itemGroup)
itemGroup.parentGroup = this;
}
}

View File

@ -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) {

View File

@ -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
}

View File

@ -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;
}
}