Rename cloned variables to help with readability

This commit is contained in:
Dev 2024-02-05 14:43:46 +00:00
parent 183e71370a
commit bf5f3316b1
15 changed files with 130 additions and 116 deletions

View File

@ -212,12 +212,12 @@ export class BotController
let cacheKey = "";
for (let i = 0; i < botGenerationDetails.botCountToGenerate; i++)
{
const details = this.jsonUtil.clone(botGenerationDetails);
const detailsClone = this.jsonUtil.clone(botGenerationDetails);
cacheKey = `${details.role}${details.botDifficulty}`;
cacheKey = `${detailsClone.role}${detailsClone.botDifficulty}`;
// Generate and add bot to cache
const botToCache = this.botGenerator.prepareAndGenerateBot(sessionId, details);
const botToCache = this.botGenerator.prepareAndGenerateBot(sessionId, detailsClone);
this.botGenerationCacheService.storeBots(cacheKey, [botToCache]);
}

View File

@ -40,19 +40,19 @@ export class BuildController
}
// Ensure the secure container in the default presets match what the player has equipped
const defaultEquipmentPresets = this.jsonUtil.clone(
const defaultEquipmentPresetsClone = this.jsonUtil.clone(
this.databaseServer.getTables().templates.defaultEquipmentPresets,
);
const playerSecureContainer = profile.characters.pmc.Inventory.items?.find((x) =>
x.slotId === secureContainerSlotId
);
const firstDefaultItemsSecureContainer = defaultEquipmentPresets[0]?.Items?.find((x) =>
const firstDefaultItemsSecureContainer = defaultEquipmentPresetsClone[0]?.Items?.find((x) =>
x.slotId === secureContainerSlotId
);
if (playerSecureContainer && playerSecureContainer?._tpl !== firstDefaultItemsSecureContainer?._tpl)
{
// Default equipment presets' secure container tpl doesn't match players secure container tpl
for (const defaultPreset of defaultEquipmentPresets)
for (const defaultPreset of defaultEquipmentPresetsClone)
{
// Find presets secure container
const secureContainer = defaultPreset.Items.find((item) => item.slotId === secureContainerSlotId);
@ -64,10 +64,10 @@ export class BuildController
}
// Clone player build data from profile and append the above defaults onto end
const result = this.jsonUtil.clone(profile.userbuilds);
result.equipmentBuilds.push(...defaultEquipmentPresets);
const userBuildsClone = this.jsonUtil.clone(profile.userbuilds);
userBuildsClone.equipmentBuilds.push(...defaultEquipmentPresetsClone);
return result;
return userBuildsClone;
}
/** Handle client/builds/weapon/save */

View File

@ -725,17 +725,17 @@ export class GameController
for (let index = indexOfWaveToSplit + 1; index < indexOfWaveToSplit + waveSize; index++)
{
// Clone wave ready to insert into array
const waveToAdd = this.jsonUtil.clone(wave);
const waveToAddClone = this.jsonUtil.clone(wave);
// Some waves have value of 0 for some reason, preserve
if (waveToAdd.number !== 0)
if (waveToAddClone.number !== 0)
{
// Update wave number to new location in array
waveToAdd.number = index;
waveToAddClone.number = index;
}
// Place wave into array in just-edited position + 1
location.base.waves.splice(index, 0, waveToAdd);
location.base.waves.splice(index, 0, waveToAddClone);
wavesAddedCount++;
}

View File

@ -582,14 +582,16 @@ export class HideoutController
const recipe = this.databaseServer.getTables().hideout.production.find((p) => p._id === body.recipeId);
// Find the actual amount of items we need to remove because body can send weird data
const requirements = this.jsonUtil.clone(recipe.requirements.filter((i) => i.type === "Item"));
const recipeRequirementsClone = this.jsonUtil.clone(recipe.requirements.filter((i) => i.type === "Item"));
const output = this.eventOutputHolder.getOutput(sessionID);
for (const itemToDelete of body.items)
{
const itemToCheck = pmcData.Inventory.items.find((i) => i._id === itemToDelete.id);
const requirement = requirements.find((requirement) => requirement.templateId === itemToCheck._tpl);
const requirement = recipeRequirementsClone.find((requirement) =>
requirement.templateId === itemToCheck._tpl
);
if (requirement.count <= 0)
{
continue;

View File

@ -79,14 +79,14 @@ export class LocationController
{
const db = this.databaseServer.getTables();
const location: ILocation = db.locations[name];
const output: ILocationBase = this.jsonUtil.clone(location.base);
const locationBaseClone: ILocationBase = this.jsonUtil.clone(location.base);
output.UnixDateTime = this.timeUtil.getTimestamp();
locationBaseClone.UnixDateTime = this.timeUtil.getTimestamp();
// Don't generate loot for hideout
if (name === "hideout")
{
return output;
return locationBaseClone;
}
// Check for a loot multipler adjustment in app context and apply if one is found
@ -97,25 +97,25 @@ export class LocationController
if (raidAdjustments)
{
locationConfigCopy = this.jsonUtil.clone(this.locationConfig); // Clone values so they can be used to reset originals later
this.raidTimeAdjustmentService.makeAdjustmentsToMap(raidAdjustments, output);
this.raidTimeAdjustmentService.makeAdjustmentsToMap(raidAdjustments, locationBaseClone);
}
const staticAmmoDist = this.jsonUtil.clone(db.loot.staticAmmo);
// Create containers and add loot to them
const staticLoot = this.locationGenerator.generateStaticContainers(output, staticAmmoDist);
output.Loot.push(...staticLoot);
const staticLoot = this.locationGenerator.generateStaticContainers(locationBaseClone, staticAmmoDist);
locationBaseClone.Loot.push(...staticLoot);
// Add dynamic loot to output loot
const dynamicLootDist: ILooseLoot = this.jsonUtil.clone(location.looseLoot);
const dynamicLootDistClone: ILooseLoot = this.jsonUtil.clone(location.looseLoot);
const dynamicSpawnPoints: SpawnpointTemplate[] = this.locationGenerator.generateDynamicLoot(
dynamicLootDist,
dynamicLootDistClone,
staticAmmoDist,
name,
);
for (const spawnPoint of dynamicSpawnPoints)
{
output.Loot.push(spawnPoint);
locationBaseClone.Loot.push(spawnPoint);
}
// Done generating, log results
@ -134,7 +134,7 @@ export class LocationController
this.applicationContext.clearValues(ContextVariableType.RAID_ADJUSTMENTS);
}
return output;
return locationBaseClone;
}
/**

View File

@ -492,7 +492,7 @@ export class QuestController
const preCompleteProfileQuests = this.jsonUtil.clone(pmcData.Quests);
const completedQuestId = body.qid;
const beforeQuests = this.jsonUtil.clone(this.getClientQuests(sessionID)); // Must be gathered prior to applyQuestReward() & failQuests()
const clientQuestsClone = this.jsonUtil.clone(this.getClientQuests(sessionID)); // Must be gathered prior to applyQuestReward() & failQuests()
const newQuestState = QuestStatus.Success;
this.questHelper.updateQuestState(pmcData, newQuestState, completedQuestId);
@ -508,7 +508,7 @@ export class QuestController
this.sendSuccessDialogMessageOnQuestComplete(sessionID, pmcData, completedQuestId, questRewards);
// Add diff of quests before completion vs after for client response
const questDelta = this.questHelper.getDeltaQuests(beforeQuests, this.getClientQuests(sessionID));
const questDelta = this.questHelper.getDeltaQuests(clientQuestsClone, this.getClientQuests(sessionID));
// Check newly available + failed quests for timegates and add them to profile
this.addTimeLockedQuestsToProfile(pmcData, [...questDelta], body.qid);

View File

@ -57,8 +57,8 @@ export class TraderController
// Create dict of trader assorts on server start
if (!this.traderAssortService.getPristineTraderAssort(traderId))
{
const assorts = this.jsonUtil.clone(trader.assort);
this.traderAssortService.setPristineTraderAssort(traderId, assorts);
const assortsClone = this.jsonUtil.clone(trader.assort);
this.traderAssortService.setPristineTraderAssort(traderId, assortsClone);
}
this.traderPurchasePersisterService.removeStalePurchasesFromProfiles(traderId);

View File

@ -109,11 +109,11 @@ export class BotGenerator
bot.Info.Settings.BotDifficulty = botGenerationDetails.botDifficulty;
// Get raw json data for bot (Cloned)
const botJsonTemplate = this.jsonUtil.clone(
const botJsonTemplateClone = this.jsonUtil.clone(
this.botHelper.getBotTemplate((botGenerationDetails.isPmc) ? bot.Info.Side : botGenerationDetails.role),
);
bot = this.generateBot(sessionId, bot, botJsonTemplate, botGenerationDetails);
bot = this.generateBot(sessionId, bot, botJsonTemplateClone, botGenerationDetails);
return bot;
}

View File

@ -87,27 +87,27 @@ export class LocationGenerator
const db = this.databaseServer.getTables();
const staticWeaponsOnMap = this.jsonUtil.clone(db.loot.staticContainers[locationBase.Name]?.staticWeapons);
if (!staticWeaponsOnMap)
const staticWeaponsOnMapClone = this.jsonUtil.clone(db.loot.staticContainers[locationBase.Name]?.staticWeapons);
if (!staticWeaponsOnMapClone)
{
this.logger.error(`Unable to find static weapon data for map: ${locationBase.Name}`);
}
// Add mounted weapons to output loot
result.push(...staticWeaponsOnMap ?? []);
result.push(...staticWeaponsOnMapClone ?? []);
const allStaticContainersOnMap = this.jsonUtil.clone(
const allStaticContainersOnMapClone = this.jsonUtil.clone(
db.loot.staticContainers[locationBase.Name]?.staticContainers,
);
if (!allStaticContainersOnMap)
if (!allStaticContainersOnMapClone)
{
this.logger.error(`Unable to find static container data for map: ${locationBase.Name}`);
}
const staticRandomisableContainersOnMap = this.getRandomisableContainersOnMap(allStaticContainersOnMap);
const staticRandomisableContainersOnMap = this.getRandomisableContainersOnMap(allStaticContainersOnMapClone);
// Containers that MUST be added to map (quest containers etc)
const staticForcedOnMap = this.jsonUtil.clone(db.loot.staticContainers[locationBase.Name]?.staticForced);
if (!staticForcedOnMap)
const staticForcedOnMapClone = this.jsonUtil.clone(db.loot.staticContainers[locationBase.Name]?.staticForced);
if (!staticForcedOnMapClone)
{
this.logger.error(`Unable to find forced static data for map: ${locationBase.Name}`);
}
@ -117,7 +117,7 @@ export class LocationGenerator
// Find all 100% spawn containers
const staticLootDist = db.loot.staticLoot;
const guaranteedContainers = this.getGuaranteedContainers(allStaticContainersOnMap);
const guaranteedContainers = this.getGuaranteedContainers(allStaticContainersOnMapClone);
staticContainerCount += guaranteedContainers.length;
// Add loot to guaranteed containers and add to result
@ -125,7 +125,7 @@ export class LocationGenerator
{
const containerWithLoot = this.addLootToContainer(
container,
staticForcedOnMap,
staticForcedOnMapClone,
staticLootDist,
staticAmmoDist,
locationId,
@ -150,7 +150,7 @@ export class LocationGenerator
{
const containerWithLoot = this.addLootToContainer(
container,
staticForcedOnMap,
staticForcedOnMapClone,
staticLootDist,
staticAmmoDist,
locationId,
@ -239,7 +239,7 @@ export class LocationGenerator
// Add loot to container and push into result object
const containerWithLoot = this.addLootToContainer(
containerObject,
staticForcedOnMap,
staticForcedOnMapClone,
staticLootDist,
staticAmmoDist,
locationId,
@ -400,13 +400,13 @@ export class LocationGenerator
locationName: string,
): IStaticContainerData
{
const container = this.jsonUtil.clone(staticContainer);
const containerTpl = container.template.Items[0]._tpl;
const containerClone = this.jsonUtil.clone(staticContainer);
const containerTpl = containerClone.template.Items[0]._tpl;
// Create new unique parent id to prevent any collisions
const parentId = this.objectId.generate();
container.template.Root = parentId;
container.template.Items[0]._id = parentId;
containerClone.template.Root = parentId;
containerClone.template.Items[0]._id = parentId;
let containerMap = this.getContainerMapping(containerTpl);
@ -417,7 +417,9 @@ export class LocationGenerator
const containerLootPool = this.getPossibleLootItemsForContainer(containerTpl, staticLootDist);
// Some containers need to have items forced into it (quest keys etc)
const tplsForced = staticForced.filter((x) => x.containerId === container.template.Id).map((x) => x.itemTpl);
const tplsForced = staticForced.filter((x) => x.containerId === containerClone.template.Id).map((x) =>
x.itemTpl
);
// Draw random loot
// Money spawn more than once in container
@ -473,11 +475,11 @@ export class LocationGenerator
// Add loot to container before returning
for (const item of items)
{
container.template.Items.push(item);
containerClone.template.Items.push(item);
}
}
return container;
return containerClone;
}
/**

View File

@ -64,11 +64,13 @@ export class PlayerScavGenerator
{
// get karma level from profile
const profile = this.saveServer.getProfile(sessionID);
const pmcData = this.jsonUtil.clone(profile.characters.pmc);
const existingScavData = this.jsonUtil.clone(profile.characters.scav);
const pmcDataClone = this.jsonUtil.clone(profile.characters.pmc);
const existingScavDataClone = this.jsonUtil.clone(profile.characters.scav);
// scav profile can be empty on first profile creation
const scavKarmaLevel = (Object.keys(existingScavData).length === 0) ? 0 : this.getScavKarmaLevel(pmcData);
const scavKarmaLevel = (Object.keys(existingScavDataClone).length === 0)
? 0
: this.getScavKarmaLevel(pmcDataClone);
// use karma level to get correct karmaSettings
const playerScavKarmaSettings = this.playerScavConfig.karmaLevel[scavKarmaLevel];
@ -95,28 +97,28 @@ export class PlayerScavGenerator
// Add scav metadata
scavData.savage = null;
scavData.aid = pmcData.aid;
scavData.TradersInfo = pmcData.TradersInfo;
scavData.aid = pmcDataClone.aid;
scavData.TradersInfo = pmcDataClone.TradersInfo;
scavData.Info.Settings = {} as Settings;
scavData.Info.Bans = [];
scavData.Info.RegistrationDate = pmcData.Info.RegistrationDate;
scavData.Info.GameVersion = pmcData.Info.GameVersion;
scavData.Info.RegistrationDate = pmcDataClone.Info.RegistrationDate;
scavData.Info.GameVersion = pmcDataClone.Info.GameVersion;
scavData.Info.MemberCategory = MemberCategory.UNIQUE_ID;
scavData.Info.lockedMoveCommands = true;
scavData.RagfairInfo = pmcData.RagfairInfo;
scavData.UnlockedInfo = pmcData.UnlockedInfo;
scavData.RagfairInfo = pmcDataClone.RagfairInfo;
scavData.UnlockedInfo = pmcDataClone.UnlockedInfo;
// Persist previous scav data into new scav
scavData._id = existingScavData._id ?? pmcData.savage;
scavData.sessionId = existingScavData.sessionId ?? pmcData.sessionId;
scavData.Skills = this.getScavSkills(existingScavData);
scavData.Stats = this.getScavStats(existingScavData);
scavData.Info.Level = this.getScavLevel(existingScavData);
scavData.Info.Experience = this.getScavExperience(existingScavData);
scavData.Quests = existingScavData.Quests ?? [];
scavData.TaskConditionCounters = existingScavData.TaskConditionCounters ?? {};
scavData.Notes = existingScavData.Notes ?? { Notes: [] };
scavData.WishList = existingScavData.WishList ?? [];
scavData._id = existingScavDataClone._id ?? pmcDataClone.savage;
scavData.sessionId = existingScavDataClone.sessionId ?? pmcDataClone.sessionId;
scavData.Skills = this.getScavSkills(existingScavDataClone);
scavData.Stats = this.getScavStats(existingScavDataClone);
scavData.Info.Level = this.getScavLevel(existingScavDataClone);
scavData.Info.Experience = this.getScavExperience(existingScavDataClone);
scavData.Quests = existingScavDataClone.Quests ?? [];
scavData.TaskConditionCounters = existingScavDataClone.TaskConditionCounters ?? {};
scavData.Notes = existingScavDataClone.Notes ?? { Notes: [] };
scavData.WishList = existingScavDataClone.WishList ?? [];
// Add an extra labs card to pscav backpack based on config chance
if (this.randomUtil.getChance100(playerScavKarmaSettings.labsAccessCardChancePercent))
@ -145,7 +147,7 @@ export class PlayerScavGenerator
scavData = this.profileHelper.removeSecureContainer(scavData);
// Set cooldown timer
scavData = this.setScavCooldownTimer(scavData, pmcData);
scavData = this.setScavCooldownTimer(scavData, pmcDataClone);
// Add scav to the profile
this.saveServer.getProfile(sessionID).characters.scav = scavData;

View File

@ -996,11 +996,11 @@ export class RepeatableQuestGenerator
{
// Add a random default preset weapon as reward
const defaultPresets = Object.values(this.presetHelper.getDefaultPresets());
const defaultPreset = this.jsonUtil.clone(this.randomUtil.getArrayValue(defaultPresets));
const defaultPresetClone = this.jsonUtil.clone(this.randomUtil.getArrayValue(defaultPresets));
// use _encyclopedia as its always the base items _tpl, items[0] isnt guaranteed to be base item
rewards.Success.push(
this.generateRewardItem(defaultPreset._encyclopedia, 1, rewardIndex, defaultPreset._items),
this.generateRewardItem(defaultPresetClone._encyclopedia, 1, rewardIndex, defaultPresetClone._items),
);
rewardIndex++;
}
@ -1286,11 +1286,11 @@ export class RepeatableQuestGenerator
// @Incomplete: define Type for "type".
protected generateRepeatableTemplate(type: string, traderId: string, side: string): IRepeatableQuest
{
const quest = this.jsonUtil.clone<IRepeatableQuest>(
const questClone = this.jsonUtil.clone<IRepeatableQuest>(
this.databaseServer.getTables().templates.repeatableQuests.templates[type],
);
quest._id = this.objectId.generate();
quest.traderId = traderId;
questClone._id = this.objectId.generate();
questClone.traderId = traderId;
/* in locale, these id correspond to the text of quests
template ids -pmc : Elimination = 616052ea3054fc0e2c24ce6e / Completion = 61604635c725987e815b1a46 / Exploration = 616041eb031af660100c9967
@ -1298,40 +1298,49 @@ export class RepeatableQuestGenerator
*/
// Get template id from config based on side and type of quest
quest.templateId = this.questConfig.questTemplateIds[side.toLowerCase()][type.toLowerCase()];
questClone.templateId = this.questConfig.questTemplateIds[side.toLowerCase()][type.toLowerCase()];
quest.name = quest.name.replace("{traderId}", traderId).replace("{templateId}", quest.templateId);
quest.note = quest.note.replace("{traderId}", traderId).replace("{templateId}", quest.templateId);
quest.description = quest.description.replace("{traderId}", traderId).replace("{templateId}", quest.templateId);
quest.successMessageText = quest.successMessageText.replace("{traderId}", traderId).replace(
questClone.name = questClone.name.replace("{traderId}", traderId).replace(
"{templateId}",
quest.templateId,
questClone.templateId,
);
quest.failMessageText = quest.failMessageText.replace("{traderId}", traderId).replace(
questClone.note = questClone.note.replace("{traderId}", traderId).replace(
"{templateId}",
quest.templateId,
questClone.templateId,
);
quest.startedMessageText = quest.startedMessageText.replace("{traderId}", traderId).replace(
questClone.description = questClone.description.replace("{traderId}", traderId).replace(
"{templateId}",
quest.templateId,
questClone.templateId,
);
quest.changeQuestMessageText = quest.changeQuestMessageText.replace("{traderId}", traderId).replace(
questClone.successMessageText = questClone.successMessageText.replace("{traderId}", traderId).replace(
"{templateId}",
quest.templateId,
questClone.templateId,
);
quest.acceptPlayerMessage = quest.acceptPlayerMessage.replace("{traderId}", traderId).replace(
questClone.failMessageText = questClone.failMessageText.replace("{traderId}", traderId).replace(
"{templateId}",
quest.templateId,
questClone.templateId,
);
quest.declinePlayerMessage = quest.declinePlayerMessage.replace("{traderId}", traderId).replace(
questClone.startedMessageText = questClone.startedMessageText.replace("{traderId}", traderId).replace(
"{templateId}",
quest.templateId,
questClone.templateId,
);
quest.completePlayerMessage = quest.completePlayerMessage.replace("{traderId}", traderId).replace(
questClone.changeQuestMessageText = questClone.changeQuestMessageText.replace("{traderId}", traderId).replace(
"{templateId}",
quest.templateId,
questClone.templateId,
);
questClone.acceptPlayerMessage = questClone.acceptPlayerMessage.replace("{traderId}", traderId).replace(
"{templateId}",
questClone.templateId,
);
questClone.declinePlayerMessage = questClone.declinePlayerMessage.replace("{traderId}", traderId).replace(
"{templateId}",
questClone.templateId,
);
questClone.completePlayerMessage = questClone.completePlayerMessage.replace("{traderId}", traderId).replace(
"{templateId}",
questClone.templateId,
);
return quest;
return questClone;
}
}

View File

@ -556,12 +556,12 @@ export class ItemHelper
while (remainingCount)
{
const amount = Math.min(remainingCount, maxStackSize);
const newStack = this.jsonUtil.clone(itemToSplit);
const newStackClone = this.jsonUtil.clone(itemToSplit);
newStack._id = this.hashUtil.generate();
newStack.upd.StackObjectsCount = amount;
newStackClone._id = this.hashUtil.generate();
newStackClone.upd.StackObjectsCount = amount;
remainingCount -= amount;
rootAndChildren.push(newStack);
rootAndChildren.push(newStackClone);
}
return rootAndChildren;
@ -589,12 +589,12 @@ export class ItemHelper
while (remainingCount)
{
const amount = Math.min(remainingCount, itemMaxStackSize);
const newItem = this.jsonUtil.clone(itemToSplit);
const newItemClone = this.jsonUtil.clone(itemToSplit);
newItem._id = this.hashUtil.generate();
newItem.upd.StackObjectsCount = amount;
newItemClone._id = this.hashUtil.generate();
newItemClone.upd.StackObjectsCount = amount;
remainingCount -= amount;
result.push([newItem]);
result.push([newItemClone]);
}
return result;

View File

@ -324,16 +324,16 @@ export class QuestHelper
for (const target of targets)
{
// This has all the original id relations since we reset the id to the original after the splitStack
const items = [this.jsonUtil.clone(target)];
const itemsClone = [this.jsonUtil.clone(target)];
// Here we generate a new id for the root item
target._id = this.hashUtil.generate();
for (const mod of mods)
{
items.push(this.jsonUtil.clone(mod));
itemsClone.push(this.jsonUtil.clone(mod));
}
rewardItems = rewardItems.concat(this.itemHelper.reparentItemAndChildren(target, items));
rewardItems = rewardItems.concat(this.itemHelper.reparentItemAndChildren(target, itemsClone));
}
return rewardItems;

View File

@ -6,7 +6,6 @@ import { TraderAssortHelper } from "@spt-aki/helpers/TraderAssortHelper";
import { TraderHelper } from "@spt-aki/helpers/TraderHelper";
import { IPmcData } from "@spt-aki/models/eft/common/IPmcData";
import { Item } from "@spt-aki/models/eft/common/tables/IItem";
import { IAddItemDirectRequest } from "@spt-aki/models/eft/inventory/IAddItemDirectRequest";
import { IAddItemsDirectRequest } from "@spt-aki/models/eft/inventory/IAddItemsDirectRequest";
import { IItemEventRouterResponse } from "@spt-aki/models/eft/itemEvent/IItemEventRouterResponse";
import { IProcessBuyTradeRequestData } from "@spt-aki/models/eft/trade/IProcessBuyTradeRequestData";

View File

@ -69,7 +69,7 @@ export class TraderAssortHelper
return this.getRagfairDataAsTraderAssort();
}
const trader = this.jsonUtil.clone(this.databaseServer.getTables().traders[traderId]);
const traderClone = this.jsonUtil.clone(this.databaseServer.getTables().traders[traderId]);
const pmcProfile = this.profileHelper.getPmcProfile(sessionId);
if (traderId === Traders.FENCE)
@ -80,13 +80,13 @@ export class TraderAssortHelper
// Strip assorts player should not see yet
if (!flea)
{
trader.assort = this.assortHelper.stripLockedLoyaltyAssort(pmcProfile, traderId, trader.assort);
traderClone.assort = this.assortHelper.stripLockedLoyaltyAssort(pmcProfile, traderId, traderClone.assort);
}
this.resetBuyRestrictionCurrentValue(trader.assort.items);
this.resetBuyRestrictionCurrentValue(traderClone.assort.items);
// Append nextResupply value to assorts so client knows when refresh is occuring
trader.assort.nextResupply = trader.base.nextResupply;
traderClone.assort.nextResupply = traderClone.base.nextResupply;
// Adjust displayed assort counts based on values stored in profile
const assortPurchasesfromTrader = this.traderPurchasePersisterService.getProfileTraderPurchases(
@ -96,11 +96,11 @@ export class TraderAssortHelper
for (const assortId in assortPurchasesfromTrader)
{
// Find assort we want to update current buy count of
const assortToAdjust = trader.assort.items.find((x) => x._id === assortId);
const assortToAdjust = traderClone.assort.items.find((x) => x._id === assortId);
if (!assortToAdjust)
{
this.logger.debug(
`Cannot find trader: ${trader.base.nickname} assort: ${assortId} to adjust BuyRestrictionCurrent value, skipping`,
`Cannot find trader: ${traderClone.base.nickname} assort: ${assortId} to adjust BuyRestrictionCurrent value, skipping`,
);
continue;
@ -124,10 +124,10 @@ export class TraderAssortHelper
this.hydrateMergedQuestAssorts();
this.createdMergedQuestAssorts = true;
}
trader.assort = this.assortHelper.stripLockedQuestAssort(
traderClone.assort = this.assortHelper.stripLockedQuestAssort(
pmcProfile,
traderId,
trader.assort,
traderClone.assort,
this.mergedQuestAssorts,
flea,
);
@ -135,10 +135,10 @@ export class TraderAssortHelper
// Multiply price if multiplier is other than 1
if (this.traderConfig.traderPriceMultipler !== 1)
{
this.multiplyItemPricesByConfigMultiplier(trader.assort);
this.multiplyItemPricesByConfigMultiplier(traderClone.assort);
}
return trader.assort;
return traderClone.assort;
}
/**