Allow armor items without plates to be listed on flea

This commit is contained in:
Dev 2024-01-23 12:46:29 +00:00
parent 8816e27298
commit b766fa1220
2 changed files with 48 additions and 25 deletions

View File

@ -19,6 +19,16 @@ export class RagfairAssortGenerator
protected generatedAssortItems: Item[] = [];
protected ragfairConfig: IRagfairConfig;
protected ragfairItemInvalidBaseTypes: string[] = [
BaseClasses.LOOT_CONTAINER, // Safe, barrel cache etc
BaseClasses.STASH, // Player inventory stash
BaseClasses.SORTING_TABLE,
BaseClasses.INVENTORY,
BaseClasses.STATIONARY_CONTAINER,
BaseClasses.POCKETS,
BaseClasses.BUILT_IN_INSERTS,
];
constructor(
@inject("JsonUtil") protected jsonUtil: JsonUtil,
@inject("HashUtil") protected hashUtil: HashUtil,
@ -62,34 +72,34 @@ export class RagfairAssortGenerator
protected generateRagfairAssortItems(): Item[]
{
const results: Item[] = [];
const items = this.itemHelper.getItems().filter(item => item._type !== "Node");
const presets = (this.ragfairConfig.dynamic.showDefaultPresetsOnly)
? Object.values(this.presetHelper.getDefaultPresets())
: this.presetHelper.getAllPresets()
const ragfairItemInvalidBaseTypes: string[] = [
BaseClasses.LOOT_CONTAINER, // safe, barrel cache etc
BaseClasses.STASH, // player inventory stash
BaseClasses.SORTING_TABLE,
BaseClasses.INVENTORY,
BaseClasses.STATIONARY_CONTAINER,
BaseClasses.POCKETS,
BaseClasses.BUILT_IN_INSERTS,
BaseClasses.ARMOR, // Handled by presets
BaseClasses.VEST, // Handled by presets
BaseClasses.HEADWEAR, // Handled by presets
];
/** Get cloned items from db */
const dbItemsClone = this.itemHelper.getItems().filter(item => item._type !== "Node");
const processedArmorItems: string[] = [];
const seasonalEventActive = this.seasonalEventService.seasonalEventEnabled();
const seasonalItemTplBlacklist = this.seasonalEventService.getInactiveSeasonalEventItems();
for (const item of items)
const presets = this.getPresetsToAdd();
for (const preset of presets)
{
if (!this.itemHelper.isValidItem(item._id, ragfairItemInvalidBaseTypes))
const presetItemTpl = preset._items[0]._tpl;
// Add presets base item tpl to the processed list so its skipped later on when processing items
processedArmorItems.push(presetItemTpl)
// Preset id must be passed through to ensure flea shows preset
results.push(this.createRagfairAssortItem(presetItemTpl, preset._id));
}
for (const item of dbItemsClone)
{
if (!this.itemHelper.isValidItem(item._id, this.ragfairItemInvalidBaseTypes))
{
continue;
}
// Skip seasonal items when not in-season
if (
this.ragfairConfig.dynamic.removeSeasonalItemsWhenNotInEvent && !seasonalEventActive
&& seasonalItemTplBlacklist.includes(item._id)
@ -98,17 +108,30 @@ export class RagfairAssortGenerator
continue;
}
if (processedArmorItems.includes(item._id))
{
// Already processed
continue;
}
results.push(this.createRagfairAssortItem(item._id, item._id)); // tplid and id must be the same so hideout recipe rewards work
}
for (const preset of presets)
{
results.push(this.createRagfairAssortItem(preset._items[0]._tpl, preset._id)); // Preset id must be passed through to ensure flea shows preset
}
return results;
}
/**
* Get presets from globals to add to flea
* ragfairConfig.dynamic.showDefaultPresetsOnly decides if its all presets or just defaults
* @returns IPreset array
*/
protected getPresetsToAdd(): IPreset[]
{
return (this.ragfairConfig.dynamic.showDefaultPresetsOnly)
? Object.values(this.presetHelper.getDefaultPresets())
: this.presetHelper.getAllPresets()
}
/**
* Create a base assort item and return it with populated values + 999999 stack count + unlimited count = true
* @param tplId tplid to add to item

View File

@ -757,7 +757,7 @@ export class RagfairOfferGenerator
for (const item of armorWithMods)
{
const itemDbDetails = this.itemHelper.getItem(item._tpl)[1];
if ((parseInt(<string>itemDbDetails._props.armorClass)) > 0)
if ((parseInt(<string>itemDbDetails._props.armorClass)) > 1)
{
if (!item.upd)
{