Simple Parameter Reassignment Issues

Addresses some of the more simple linting errors regarding the reassignment of function parameters.
This commit is contained in:
Refringe 2024-02-05 18:51:32 -05:00
parent 34121182a1
commit 3a2b24b9b8
No known key found for this signature in database
GPG Key ID: 64E03E5F892C6F9E
6 changed files with 29 additions and 21 deletions

View File

@ -97,15 +97,12 @@ export class InsuranceController
protected filterInsuredItems(sessionID: string, time?: number): Insurance[]
{
// Use the current time by default.
if (!time)
{
time = this.timeUtil.getTimestamp();
}
const insuranceTime = time || this.timeUtil.getTimestamp();
const profileInsuranceDetails = this.saveServer.getProfile(sessionID).insurance;
this.logger.debug(`Found ${profileInsuranceDetails.length} insurance packages in profile ${sessionID}`);
return profileInsuranceDetails.filter((insured) => time >= insured.scheduledTime);
return profileInsuranceDetails.filter((insured) => insuranceTime >= insured.scheduledTime);
}
/**

View File

@ -468,13 +468,15 @@ export class InventoryController
*/
public foldItem(pmcData: IPmcData, body: IInventoryFoldRequestData, sessionID: string): IItemEventRouterResponse
{
let playerData = pmcData;
// Fix for folding weapons while on they're in the Scav inventory
if (body.fromOwner && body.fromOwner.type === "Profile" && body.fromOwner.id !== pmcData._id)
if (body.fromOwner && body.fromOwner.type === "Profile" && body.fromOwner.id !== playerData._id)
{
pmcData = this.profileHelper.getScavProfile(sessionID);
playerData = this.profileHelper.getScavProfile(sessionID);
}
for (const item of pmcData.Inventory.items)
for (const item of playerData.Inventory.items)
{
if (item._id && item._id === body.item)
{
@ -495,13 +497,15 @@ export class InventoryController
*/
public toggleItem(pmcData: IPmcData, body: IInventoryToggleRequestData, sessionID: string): IItemEventRouterResponse
{
let playerData = pmcData;
// Fix for toggling items while on they're in the Scav inventory
if (body.fromOwner && body.fromOwner.type === "Profile" && body.fromOwner.id !== pmcData._id)
if (body.fromOwner && body.fromOwner.type === "Profile" && body.fromOwner.id !== playerData._id)
{
pmcData = this.profileHelper.getScavProfile(sessionID);
playerData = this.profileHelper.getScavProfile(sessionID);
}
const itemToToggle = pmcData.Inventory.items.find((x) => x._id === body.item);
const itemToToggle = playerData.Inventory.items.find((x) => x._id === body.item);
if (itemToToggle)
{
if (!itemToToggle.upd)

View File

@ -263,14 +263,16 @@ export class RepeatableQuestController
public generateDebugDailies(dailiesPool: any, factory: any, number: number): any
{
let randomQuests = [];
let numberOfQuests = number;
if (factory)
{
// First is factory extract always add for debugging
randomQuests.push(dailiesPool[0]);
number -= 1;
numberOfQuests -= 1;
}
randomQuests = randomQuests.concat(this.randomUtil.drawRandomFromList(dailiesPool, number, false));
randomQuests = randomQuests.concat(this.randomUtil.drawRandomFromList(dailiesPool, numberOfQuests, false));
for (const element of randomQuests)
{

View File

@ -75,9 +75,11 @@ export class BotEquipmentModGenerator
parentId: string,
parentTemplate: ITemplateItem,
settings: IGenerateEquipmentProperties,
forceSpawn = false,
shouldForceSpawn = false,
): Item[]
{
let forceSpawn = shouldForceSpawn;
const compatibleModsPool = settings.modPool[parentTemplate._id];
if (!compatibleModsPool)
{

View File

@ -429,7 +429,7 @@ export class BotLootGenerator
// Must add soft inserts/plates
else if (this.itemHelper.itemRequiresSoftInserts(itemToAddTemplate._id))
{
itemToAddChildrenTo = this.itemHelper.addChildSlotItems(itemToAddChildrenTo, itemToAddTemplate, null, true);
this.itemHelper.addChildSlotItems(itemToAddChildrenTo, itemToAddTemplate, null, true);
}
}

View File

@ -193,13 +193,14 @@ export class ProfileHelper
public getExperience(level: number): number
{
let playerLevel = level;
const expTable = this.databaseServer.getTables().globals.config.exp.level.exp_table;
let exp = 0;
if (level >= expTable.length)
if (playerLevel >= expTable.length)
{
// make sure to not go out of bounds
level = expTable.length - 1;
playerLevel = expTable.length - 1;
}
for (let i = 0; i < level; i++)
@ -400,7 +401,9 @@ export class ProfileHelper
useSkillProgressRateMultipler = false,
): void
{
if (!pointsToAdd || pointsToAdd < 0)
let pointsToAddToSkill = pointsToAdd;
if (!pointsToAddToSkill || pointsToAddToSkill < 0)
{
this.logger.warning(
this.localisationService.getText("player-attempt_to_increment_skill_with_negative_value", skill),
@ -411,7 +414,7 @@ export class ProfileHelper
const profileSkills = pmcProfile?.Skills?.Common;
if (!profileSkills)
{
this.logger.warning(`Unable to add ${pointsToAdd} points to ${skill}, profile has no skills`);
this.logger.warning(`Unable to add ${pointsToAddToSkill} points to ${skill}, profile has no skills`);
return;
}
@ -426,10 +429,10 @@ export class ProfileHelper
{
const globals = this.databaseServer.getTables().globals;
const skillProgressRate = globals.config.SkillsSettings.SkillProgressRate;
pointsToAdd *= skillProgressRate;
pointsToAddToSkill *= skillProgressRate;
}
profileSkill.Progress += pointsToAdd;
profileSkill.Progress += pointsToAddToSkill;
profileSkill.Progress = Math.min(profileSkill.Progress, 5100); // Prevent skill from ever going above level 51 (5100)
profileSkill.LastAccess = this.timeUtil.getTimestamp();
}