From 43bed3a8a80b4cc0f5e228d63e6de7d4eed27658 Mon Sep 17 00:00:00 2001 From: Dev Date: Tue, 5 Nov 2024 09:27:21 +0000 Subject: [PATCH] Fixed `hydrateLookup()` storing data from `handbookPriceOverride` with incorrect parent keys Increased prices of overrides --- project/assets/configs/item.json | 6 +++--- project/src/helpers/HandbookHelper.ts | 16 +++++++++------- project/src/models/spt/config/IItemConfig.ts | 9 ++++++++- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/project/assets/configs/item.json b/project/assets/configs/item.json index c982192b..b4d42eef 100644 --- a/project/assets/configs/item.json +++ b/project/assets/configs/item.json @@ -149,8 +149,8 @@ "5c1a1e3f2e221602b66cc4c2" ], "handbookPriceOverride": { - "63a8970d7108f713591149f5": 1000, - "63a898a328e385334e0640a5": 5000, - "63a897c6b1ff6e29734fcc95": 10000 + "63a8970d7108f713591149f5": {"price": 5000, "parentId": "5b5f6fa186f77409407a7eb7"}, + "63a898a328e385334e0640a5": {"price": 10000, "parentId": "5b5f6fa186f77409407a7eb7"}, + "63a897c6b1ff6e29734fcc95": {"price": 20000, "parentId": "5b5f6fa186f77409407a7eb7"} } } diff --git a/project/src/helpers/HandbookHelper.ts b/project/src/helpers/HandbookHelper.ts index 08b3b4cd..bc5d0edb 100644 --- a/project/src/helpers/HandbookHelper.ts +++ b/project/src/helpers/HandbookHelper.ts @@ -48,18 +48,20 @@ export class HandbookHelper { public hydrateLookup(): void { const handbook = this.databaseService.getHandbook(); // Add handbook overrides found in items.json config into db - for (const itemTpl in this.itemConfig.handbookPriceOverride) { - let itemToUpdate = handbook.Items.find((item) => item.Id === itemTpl); + for (const itemTplKey of Object.keys(this.itemConfig.handbookPriceOverride)) { + const data = this.itemConfig.handbookPriceOverride[itemTplKey]; + + let itemToUpdate = handbook.Items.find((item) => item.Id === itemTplKey); if (!itemToUpdate) { handbook.Items.push({ - Id: itemTpl, - ParentId: this.databaseService.getItems()[itemTpl]._parent, - Price: this.itemConfig.handbookPriceOverride[itemTpl], + Id: itemTplKey, + ParentId: data.parentId, + Price: data.price, }); - itemToUpdate = handbook.Items.find((item) => item.Id === itemTpl); + itemToUpdate = handbook.Items.find((item) => item.Id === itemTplKey); } - itemToUpdate.Price = this.itemConfig.handbookPriceOverride[itemTpl]; + itemToUpdate.Price = data.price; } const handbookDbClone = this.cloner.clone(handbook); diff --git a/project/src/models/spt/config/IItemConfig.ts b/project/src/models/spt/config/IItemConfig.ts index cf3b38eb..b13a328f 100644 --- a/project/src/models/spt/config/IItemConfig.ts +++ b/project/src/models/spt/config/IItemConfig.ts @@ -10,5 +10,12 @@ export interface IItemConfig extends IBaseConfig { rewardItemBlacklist: string[]; /** Items that can only be found on bosses */ bossItems: string[]; - handbookPriceOverride: Record; + handbookPriceOverride: Record; +} + +export interface IHandbookPriceOverride { + /** Price in roubles */ + price: number; + /** NOT parentId from items.json, but handbook.json */ + parentId: string; }