|
@@ -49,12 +49,6 @@ export class JournalInventoryComponent {
|
|
private data = inject(DataService);
|
|
private data = inject(DataService);
|
|
private modal = inject(ModalService);
|
|
private modal = inject(ModalService);
|
|
|
|
|
|
- // constructor(
|
|
|
|
- // private detailsAccessor: DetailsService,
|
|
|
|
- // private dataAccessor: DataService,
|
|
|
|
- // private modalAccessor: ModalService,
|
|
|
|
- // ) {}
|
|
|
|
-
|
|
|
|
public ngOnInit(): void {
|
|
public ngOnInit(): void {
|
|
this.weaponsAndArmor = this.data.weaponsAndArmor;
|
|
this.weaponsAndArmor = this.data.weaponsAndArmor;
|
|
this.consumables = this.data.consumables;
|
|
this.consumables = this.data.consumables;
|
|
@@ -166,6 +160,21 @@ export class JournalInventoryComponent {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Consumes one unit of food from the inventory.
|
|
|
|
+ * It always uses the first entry in the list.
|
|
|
|
+ * If the food item is empty, it will be removed from the list.
|
|
|
|
+ */
|
|
|
|
+ public consumeFood(): void {
|
|
|
|
+ if (this.food.length > 0) {
|
|
|
|
+ this.food[0].quantity--;
|
|
|
|
+ if (this.food[0].quantity === 0) {
|
|
|
|
+ this.food.splice(0, 1);
|
|
|
|
+ }
|
|
|
|
+ this.updateFood();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
// Updates
|
|
// Updates
|
|
|
|
|
|
public updateDatabase(listname: string): void {
|
|
public updateDatabase(listname: string): void {
|