diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 152535a..f756385 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -91,6 +91,12 @@ import { import { InheritedItemCharacteristicEditorComponent } from "./editor/items/item-editor/inherited-item-characteristic-editor/inherited-item-characteristic-editor.component"; +import { + InventorySlotEditorComponent +} from "./editor/character-editor/inventory-slot-editor/inventory-slot-editor.component"; +import { + InventorySlotCreatorComponent +} from "./editor/character-editor/inventory-slot-editor/inventory-slot-creator/inventory-slot-creator.component"; // AoT requires an exported function for factories const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new TranslateHttpLoader(http, './assets/i18n/', '.json'); @@ -120,7 +126,9 @@ const httpLoaderFactory = (http: HttpClient): TranslateHttpLoader => new Transl ItemGroupEditorComponent, ItemEditorComponent, ItemgroupInheritorComponent, - InheritedItemCharacteristicEditorComponent + InheritedItemCharacteristicEditorComponent, + InventorySlotEditorComponent, + InventorySlotCreatorComponent ], imports: [ BrowserModule, diff --git a/src/app/editor/character-editor/character-editor.component.html b/src/app/editor/character-editor/character-editor.component.html index 959cad6..a8a7060 100644 --- a/src/app/editor/character-editor/character-editor.component.html +++ b/src/app/editor/character-editor/character-editor.component.html @@ -56,3 +56,13 @@ + + + + + Inventory-Slots + + + + + diff --git a/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-creator/inventory-slot-creator.component.html b/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-creator/inventory-slot-creator.component.html new file mode 100644 index 0000000..3dd619f --- /dev/null +++ b/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-creator/inventory-slot-creator.component.html @@ -0,0 +1,11 @@ +

Create Inventory Slot

+ + + Slot-Name + + + + + + + diff --git a/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-creator/inventory-slot-creator.component.scss b/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-creator/inventory-slot-creator.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-creator/inventory-slot-creator.component.spec.ts b/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-creator/inventory-slot-creator.component.spec.ts new file mode 100644 index 0000000..c8771c8 --- /dev/null +++ b/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-creator/inventory-slot-creator.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { InventorySlotCreatorComponent } from './inventory-slot-creator.component'; + +describe('InventorySlotCreatorComponent', () => { + let component: InventorySlotCreatorComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [InventorySlotCreatorComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(InventorySlotCreatorComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-creator/inventory-slot-creator.component.ts b/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-creator/inventory-slot-creator.component.ts new file mode 100644 index 0000000..1058c63 --- /dev/null +++ b/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-creator/inventory-slot-creator.component.ts @@ -0,0 +1,27 @@ +import {Component, Inject} from '@angular/core'; +import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog"; +import {InventorySlot} from "../../../../project/game-model/inventory/intentory-slots/InventorySlot"; +import {FormControl, Validators} from "@angular/forms"; + +@Component({ + selector: 'app-inventory-slot-creator', + templateUrl: './inventory-slot-creator.component.html', + styleUrl: './inventory-slot-creator.component.scss' +}) +export class InventorySlotCreatorComponent { + + slotNameCtrl = new FormControl('', [Validators.required]); + + constructor(private dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: InventorySlot | undefined) { + } + + + submit() { + this.dialogRef.close(new InventorySlot(this.slotNameCtrl.value!)) + } + + cancel() { + this.dialogRef.close() + } +} diff --git a/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-editor.component.html b/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-editor.component.html new file mode 100644 index 0000000..71a6528 --- /dev/null +++ b/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-editor.component.html @@ -0,0 +1,12 @@ + + + + {{slot.slotName}} + +
+ + +
+
+ +
diff --git a/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-editor.component.scss b/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-editor.component.scss new file mode 100644 index 0000000..bbb5df8 --- /dev/null +++ b/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-editor.component.scss @@ -0,0 +1,6 @@ +.panel-actions { + float: right; +} +.add-btn { + width: 100%; +} diff --git a/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-editor.component.spec.ts b/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-editor.component.spec.ts new file mode 100644 index 0000000..8e5c454 --- /dev/null +++ b/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-editor.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { InventorySlotEditorComponent } from './inventory-slot-editor.component'; + +describe('InventorySlotEditorComponent', () => { + let component: InventorySlotEditorComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [InventorySlotEditorComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(InventorySlotEditorComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-editor.component.ts b/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-editor.component.ts new file mode 100644 index 0000000..c364410 --- /dev/null +++ b/src/app/editor/character-editor/inventory-slot-editor/inventory-slot-editor.component.ts @@ -0,0 +1,32 @@ +import {Component, Input} from '@angular/core'; +import {Character} from "../../../project/game-model/characters/Character"; +import {ItemGroup} from "../../../project/game-model/inventory/ItemGroup"; +import {InventorySlot} from "../../../project/game-model/inventory/intentory-slots/InventorySlot"; +import {MatDialog} from "@angular/material/dialog"; +import {InventorySlotCreatorComponent} from "./inventory-slot-creator/inventory-slot-creator.component"; + +@Component({ + selector: 'app-inventory-slot-editor', + templateUrl: './inventory-slot-editor.component.html', + styleUrl: './inventory-slot-editor.component.scss' +}) +export class InventorySlotEditorComponent { + + @Input() character: Character | undefined + @Input() itemgroups: ItemGroup[] = [] + + constructor(private dialog: MatDialog) { + } + + addInventorySlot() { + const dialogRef = this.dialog.open(InventorySlotCreatorComponent, { + minWidth: "400px" + }) + + dialogRef.afterClosed().subscribe(res => { + if(res != undefined) { + this.character!.inventorySlots.push(res) + } + }) + } +} diff --git a/src/app/project/game-model/characters/Character.ts b/src/app/project/game-model/characters/Character.ts index 51ec902..b787090 100644 --- a/src/app/project/game-model/characters/Character.ts +++ b/src/app/project/game-model/characters/Character.ts @@ -7,19 +7,41 @@ import {SimpleTemplateGamesystem} from "../templates/simpleGamesystem/SimpleTemp import {ProductTemplateSystem} from "../templates/productGamesystem/ProductTemplateSystem"; import {ProductGamesystem} from "../gamesystems/ProductGamesystem"; import {CharacterRelation} from "./CharacterRelation"; +import {InventorySlot} from "../inventory/intentory-slots/InventorySlot"; +import {Tupel} from "../../../shared/Tupel"; export class Character extends ModelComponent implements TemplateElement { characterSpecificTemplateSystems: Gamesystem[] = [] - characterRelations: CharacterRelation[] = [] - characterRelationGamesystems: Gamesystem[] = [] + inventorySlots: InventorySlot[] = [] + combinableInventorySlots: Tupel[] = [] constructor(componentName: string, componentDescription: string) { super(componentName, componentDescription, ModelComponentType.CHARACTER); } + addInventorySlot(inventorySlot: InventorySlot) { + if(this.inventorySlots.find(slot => slot.slotName === inventorySlot.slotName) == undefined) { + this.inventorySlots.push(inventorySlot); + } + } + + removeInventorySlot(removedInventorySlot: InventorySlot) { + this.inventorySlots = this.inventorySlots.filter(slot => removedInventorySlot.slotName !== slot.slotName); + } + + addCombinedInventorySlot(combinedSlot: Tupel) { + if(this.combinableInventorySlots.find(tupel => tupel.value00 === combinedSlot.value00 && tupel.value01 === combinedSlot.value01) != undefined) { + this.combinableInventorySlots.push(combinedSlot); + } + } + + removeCombinedInventorySlot(combinedSlot: Tupel) { + this.combinableInventorySlots = this.combinableInventorySlots.filter(slots => slots.value00 != combinedSlot.value00 && slots.value01 != combinedSlot.value01); + } + addCharacterSpecificSimpleTemplatesystem(gamesystem: Gamesystem, recursiveCall: boolean = false) { if(!this.isTemplateSystemCharacterSpecific(gamesystem.componentName)) { if(gamesystem instanceof SimpleTemplateGamesystem) { @@ -65,9 +87,6 @@ export class Character extends ModelComponent implements TemplateElement { this.addAsymetricCharacterRelationGamesystem(gamesystem.parentGamesystem, true) } - } else { - console.log("Was already added") - console.log(this) } } diff --git a/src/app/project/game-model/inventory/intentory-slots/InventoryCharacteristic.ts b/src/app/project/game-model/inventory/intentory-slots/InventoryCharacteristic.ts new file mode 100644 index 0000000..04c8c85 --- /dev/null +++ b/src/app/project/game-model/inventory/intentory-slots/InventoryCharacteristic.ts @@ -0,0 +1,14 @@ +import {ItemGroupCharacteristic} from "../ItemgroupCharacteristic"; + +export class InventoryCharacteristic { + increasingCharacteristic: ItemGroupCharacteristic + decreasingCharacteristic: ItemGroupCharacteristic + + + constructor(increasingCharacteristic: ItemGroupCharacteristic, decreasingCharacteristic: ItemGroupCharacteristic) { + this.increasingCharacteristic = increasingCharacteristic; + this.decreasingCharacteristic = decreasingCharacteristic; + } + + +} diff --git a/src/app/project/game-model/inventory/intentory-slots/InventorySlot.ts b/src/app/project/game-model/inventory/intentory-slots/InventorySlot.ts new file mode 100644 index 0000000..05290ae --- /dev/null +++ b/src/app/project/game-model/inventory/intentory-slots/InventorySlot.ts @@ -0,0 +1,16 @@ +import {ItemGroupCharacteristic} from "../ItemgroupCharacteristic"; +import {InventoryCharacteristic} from "./InventoryCharacteristic"; +import {ItemGroup} from "../ItemGroup"; + +export class InventorySlot { + slotName: string + slotCharacteristics: InventoryCharacteristic[] = [] + requiredInheritances: ItemGroup[] = [] //if empty: non reqierements + + + constructor(slotName: string) { + this.slotName = slotName; + } + + +}