Move handbook override code into HandbookHelper.hydrate()
- changes now apply to ragfair
This commit is contained in:
parent
62f51be3aa
commit
5f873e73b8
@ -206,11 +206,13 @@
|
|||||||
},
|
},
|
||||||
"unreasonableModPrices": {
|
"unreasonableModPrices": {
|
||||||
"5448fe124bdc2da5018b4567": {
|
"5448fe124bdc2da5018b4567": {
|
||||||
|
"itemType": "Weapon Mod",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"handbookPriceOverMultiplier": 9,
|
"handbookPriceOverMultiplier": 9,
|
||||||
"newPriceHandbookMultiplier": 9
|
"newPriceHandbookMultiplier": 9
|
||||||
},
|
},
|
||||||
"57864a66245977548f04a81f": {
|
"57864a66245977548f04a81f": {
|
||||||
|
"itemType": "Electronics",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"handbookPriceOverMultiplier": 11,
|
"handbookPriceOverMultiplier": 11,
|
||||||
"newPriceHandbookMultiplier": 11
|
"newPriceHandbookMultiplier": 11
|
||||||
|
@ -54,8 +54,29 @@ export class HandbookHelper
|
|||||||
*/
|
*/
|
||||||
public hydrateLookup(): void
|
public hydrateLookup(): void
|
||||||
{
|
{
|
||||||
const handbookDb = this.jsonUtil.clone(this.databaseServer.getTables().templates.handbook);
|
// Add handbook overrides found in items.json config into db
|
||||||
for (const handbookItem of handbookDb.Items)
|
for (const itemTpl in this.itemConfig.handbookPriceOverride)
|
||||||
|
{
|
||||||
|
let itemToUpdate = this.databaseServer.getTables().templates.handbook.Items.find((item) =>
|
||||||
|
item.Id === itemTpl
|
||||||
|
);
|
||||||
|
if (!itemToUpdate)
|
||||||
|
{
|
||||||
|
this.databaseServer.getTables().templates.handbook.Items.push({
|
||||||
|
Id: itemTpl,
|
||||||
|
ParentId: this.databaseServer.getTables().templates.items[itemTpl]._parent,
|
||||||
|
Price: this.itemConfig.handbookPriceOverride[itemTpl],
|
||||||
|
});
|
||||||
|
itemToUpdate = this.databaseServer.getTables().templates.handbook.Items.find((item) =>
|
||||||
|
item.Id === itemTpl
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
itemToUpdate.Price = this.itemConfig.handbookPriceOverride[itemTpl];
|
||||||
|
}
|
||||||
|
|
||||||
|
const handbookDbClone = this.jsonUtil.clone(this.databaseServer.getTables().templates.handbook);
|
||||||
|
for (const handbookItem of handbookDbClone.Items)
|
||||||
{
|
{
|
||||||
this.handbookPriceCache.items.byId.set(handbookItem.Id, handbookItem.Price);
|
this.handbookPriceCache.items.byId.set(handbookItem.Id, handbookItem.Price);
|
||||||
if (!this.handbookPriceCache.items.byParent.has(handbookItem.ParentId))
|
if (!this.handbookPriceCache.items.byParent.has(handbookItem.ParentId))
|
||||||
@ -65,7 +86,7 @@ export class HandbookHelper
|
|||||||
this.handbookPriceCache.items.byParent.get(handbookItem.ParentId).push(handbookItem.Id);
|
this.handbookPriceCache.items.byParent.get(handbookItem.ParentId).push(handbookItem.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const handbookCategory of handbookDb.Categories)
|
for (const handbookCategory of handbookDbClone.Categories)
|
||||||
{
|
{
|
||||||
this.handbookPriceCache.categories.byId.set(handbookCategory.Id, handbookCategory.ParentId || null);
|
this.handbookPriceCache.categories.byId.set(handbookCategory.Id, handbookCategory.ParentId || null);
|
||||||
if (handbookCategory.ParentId)
|
if (handbookCategory.ParentId)
|
||||||
@ -93,11 +114,6 @@ export class HandbookHelper
|
|||||||
this.lookupCacheGenerated = true;
|
this.lookupCacheGenerated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.itemConfig.handbookPriceOverride[tpl])
|
|
||||||
{
|
|
||||||
return this.itemConfig.handbookPriceOverride[tpl];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.handbookPriceCache.items.byId.has(tpl))
|
if (this.handbookPriceCache.items.byId.has(tpl))
|
||||||
{
|
{
|
||||||
return this.handbookPriceCache.items.byId.get(tpl);
|
return this.handbookPriceCache.items.byId.get(tpl);
|
||||||
|
Loading…
Reference in New Issue
Block a user