Fixes Linting Issues
- Reorders imports - Removes unnecessary `else` control statements - Simplifies some logic - Converts key access to dot notation - Converts Array.forEach loops to for...of loops
This commit is contained in:
parent
90492f3aa2
commit
69a1723646
@ -157,7 +157,7 @@ export class DataCallbacks
|
||||
|
||||
if (result === undefined)
|
||||
{
|
||||
result = tables.locales.menu["en"];
|
||||
result = tables.locales.menu.en;
|
||||
}
|
||||
|
||||
return this.httpResponse.getBody(result);
|
||||
|
@ -792,7 +792,7 @@ export class QuestController
|
||||
for (const itemHandover of handoverQuestRequest.items)
|
||||
{
|
||||
const matchingItemInProfile = pmcData.Inventory.items.find((item) => item._id === itemHandover.id);
|
||||
if (!matchingItemInProfile || !handoverRequirements.target.includes(matchingItemInProfile._tpl))
|
||||
if (!(matchingItemInProfile && handoverRequirements.target.includes(matchingItemInProfile._tpl)))
|
||||
{
|
||||
// Item handed in by player doesnt match what was requested
|
||||
return this.showQuestItemHandoverMatchError(
|
||||
|
@ -366,20 +366,18 @@ export class RagfairController
|
||||
|
||||
return { avg: (min + max) / 2, min: min, max: max };
|
||||
}
|
||||
|
||||
// No offers listed, get price from live ragfair price list prices.json
|
||||
else
|
||||
const templatesDb = this.databaseServer.getTables().templates;
|
||||
|
||||
let tplPrice = templatesDb.prices[getPriceRequest.templateId];
|
||||
if (!tplPrice)
|
||||
{
|
||||
const templatesDb = this.databaseServer.getTables().templates;
|
||||
|
||||
let tplPrice = templatesDb.prices[getPriceRequest.templateId];
|
||||
if (!tplPrice)
|
||||
{
|
||||
// No flea price, get handbook price
|
||||
tplPrice = this.handbookHelper.getTemplatePrice(getPriceRequest.templateId);
|
||||
}
|
||||
|
||||
return { avg: tplPrice, min: tplPrice, max: tplPrice };
|
||||
// No flea price, get handbook price
|
||||
tplPrice = this.handbookHelper.getTemplatePrice(getPriceRequest.templateId);
|
||||
}
|
||||
|
||||
return { avg: tplPrice, min: tplPrice, max: tplPrice };
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -226,6 +226,7 @@ import { RepairService } from "@spt-aki/services/RepairService";
|
||||
import { SeasonalEventService } from "@spt-aki/services/SeasonalEventService";
|
||||
import { TraderAssortService } from "@spt-aki/services/TraderAssortService";
|
||||
import { TraderPurchasePersisterService } from "@spt-aki/services/TraderPurchasePersisterService";
|
||||
import { TraderServicesService } from "@spt-aki/services/TraderServicesService";
|
||||
import { CustomItemService } from "@spt-aki/services/mod/CustomItemService";
|
||||
import { DynamicRouterModService } from "@spt-aki/services/mod/dynamicRouter/DynamicRouterModService";
|
||||
import { HttpListenerModService } from "@spt-aki/services/mod/httpListener/HttpListenerModService";
|
||||
@ -250,7 +251,6 @@ import { VFS } from "@spt-aki/utils/VFS";
|
||||
import { Watermark, WatermarkLocale } from "@spt-aki/utils/Watermark";
|
||||
import { WinstonMainLogger } from "@spt-aki/utils/logging/WinstonMainLogger";
|
||||
import { WinstonRequestLogger } from "@spt-aki/utils/logging/WinstonRequestLogger";
|
||||
import { TraderServicesService } from "@spt-aki/services/TraderServicesService";
|
||||
|
||||
/**
|
||||
* Handle the registration of classes to be used by the Dependency Injection code
|
||||
|
@ -31,10 +31,7 @@ export class Router
|
||||
{
|
||||
return this.getInternalHandledRoutes().filter((r) => r.dynamic).some((r) => url.includes(r.route));
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.getInternalHandledRoutes().filter((r) => !r.dynamic).some((r) => r.route === url);
|
||||
}
|
||||
return this.getInternalHandledRoutes().filter((r) => !r.dynamic).some((r) => r.route === url);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -895,7 +895,7 @@ export class BotEquipmentModGenerator
|
||||
}
|
||||
|
||||
// Some mod combos will never work, make sure this isnt the case
|
||||
if (!chosenModResult.incompatible && !this.weaponModComboIsIncompatible(weapon, chosenTpl))
|
||||
if (!(chosenModResult.incompatible || this.weaponModComboIsIncompatible(weapon, chosenTpl)))
|
||||
{
|
||||
// Success
|
||||
chosenModResult.found = true;
|
||||
|
@ -311,9 +311,10 @@ export class LocationGenerator
|
||||
|
||||
// Create probability array with all possible container ids in this group and their relataive probability of spawning
|
||||
const containerDistribution = new ProbabilityObjectArray<string>(this.mathUtil, this.jsonUtil);
|
||||
containerIds.forEach((x) =>
|
||||
containerDistribution.push(new ProbabilityObject(x, containerData.containerIdsWithProbability[x]))
|
||||
);
|
||||
for (const x of containerIds)
|
||||
{
|
||||
containerDistribution.push(new ProbabilityObject(x, containerData.containerIdsWithProbability[x]));
|
||||
}
|
||||
|
||||
chosenContainerIds.push(...containerDistribution.draw(containerData.chosenCount));
|
||||
|
||||
|
@ -69,8 +69,9 @@ export class ExternalInventoryMagGen implements IInventoryMagGen
|
||||
// No containers to fit magazines, stop trying
|
||||
break;
|
||||
}
|
||||
|
||||
// No space for magazine and we haven't reached desired magazine count
|
||||
else if (fitsIntoInventory === ItemAddedResult.NO_SPACE && i < randomizedMagazineCount)
|
||||
if (fitsIntoInventory === ItemAddedResult.NO_SPACE && i < randomizedMagazineCount)
|
||||
{
|
||||
// Prevent infinite loop by only allowing 5 attempts at fitting a magazine into inventory
|
||||
if (fitAttempts > 5)
|
||||
@ -141,7 +142,7 @@ export class ExternalInventoryMagGen implements IInventoryMagGen
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a random compatible external magazine for a weapon, excluses internal magazines from possible pool
|
||||
* Get a random compatible external magazine for a weapon, exclude internal magazines from possible pool
|
||||
* @param weaponTpl Weapon to get mag for
|
||||
* @returns tpl of magazine
|
||||
*/
|
||||
|
@ -85,11 +85,13 @@ export class AssortHelper
|
||||
status: [QuestStatus.Started, QuestStatus.AvailableForFinish, QuestStatus.Success],
|
||||
};
|
||||
}
|
||||
else if (assortId in mergedQuestAssorts.success)
|
||||
|
||||
if (assortId in mergedQuestAssorts.success)
|
||||
{
|
||||
return { questId: mergedQuestAssorts.success[assortId], status: [QuestStatus.Success] };
|
||||
}
|
||||
else if (assortId in mergedQuestAssorts.fail)
|
||||
|
||||
if (assortId in mergedQuestAssorts.fail)
|
||||
{
|
||||
return { questId: mergedQuestAssorts.fail[assortId], status: [QuestStatus.Fail] };
|
||||
}
|
||||
|
@ -555,10 +555,10 @@ export class InRaidHelper
|
||||
&& this.itemHelper.itemIsInsideContainer(x, "SecuredContainer", postRaidProfile.Inventory.items));
|
||||
});
|
||||
|
||||
itemsToRemovePropertyFrom.forEach((item) =>
|
||||
for (const item of itemsToRemovePropertyFrom)
|
||||
{
|
||||
delete item.upd.SpawnedInSession;
|
||||
});
|
||||
}
|
||||
|
||||
return postRaidProfile;
|
||||
}
|
||||
@ -601,11 +601,11 @@ export class InRaidHelper
|
||||
{
|
||||
// Get inventory item ids to remove from players profile
|
||||
const itemIdsToDeleteFromProfile = this.getInventoryItemsLostOnDeath(pmcData).map((x) => x._id);
|
||||
itemIdsToDeleteFromProfile.forEach((x) =>
|
||||
for (const x of itemIdsToDeleteFromProfile)
|
||||
{
|
||||
// Items inside containers are handed as part of function
|
||||
// Items inside containers are handled as part of function
|
||||
this.inventoryHelper.removeItem(pmcData, x, sessionID);
|
||||
});
|
||||
}
|
||||
|
||||
// Remove contents of fast panel
|
||||
pmcData.Inventory.fastPanel = {};
|
||||
|
@ -146,12 +146,11 @@ export class PreAkiModLoader implements IModLoader
|
||||
const modOrder = this.vfs.readFile(this.modOrderPath, { encoding: "utf8" });
|
||||
try
|
||||
{
|
||||
this.jsonUtil.deserialize<any>(modOrder, this.modOrderPath).order.forEach(
|
||||
(mod: string, index: number) =>
|
||||
{
|
||||
this.order[mod] = index;
|
||||
},
|
||||
);
|
||||
const modOrderArray = this.jsonUtil.deserialize<any>(modOrder, this.modOrderPath).order;
|
||||
for (const [index, mod] of modOrderArray.entries())
|
||||
{
|
||||
this.order[mod] = index;
|
||||
}
|
||||
}
|
||||
catch (error)
|
||||
{
|
||||
@ -215,11 +214,10 @@ export class PreAkiModLoader implements IModLoader
|
||||
validMods.sort((prev, next) => this.sortMods(prev, next, missingFromOrderJSON));
|
||||
|
||||
// log the missing mods from order.json
|
||||
Object.keys(missingFromOrderJSON).forEach((
|
||||
missingMod,
|
||||
) => (this.logger.debug(
|
||||
this.localisationService.getText("modloader-mod_order_missing_from_json", missingMod),
|
||||
)));
|
||||
for (const missingMod of Object.keys(missingFromOrderJSON))
|
||||
{
|
||||
this.logger.debug(this.localisationService.getText("modloader-mod_order_missing_from_json", missingMod));
|
||||
}
|
||||
|
||||
// add mods
|
||||
for (const mod of validMods)
|
||||
@ -250,7 +248,8 @@ export class PreAkiModLoader implements IModLoader
|
||||
|
||||
return 1;
|
||||
}
|
||||
else if (nextindex === undefined)
|
||||
|
||||
if (nextindex === undefined)
|
||||
{
|
||||
missingFromOrderJSON[next] = true;
|
||||
|
||||
@ -436,10 +435,8 @@ export class PreAkiModLoader implements IModLoader
|
||||
{
|
||||
return this.jsonUtil.deserialize(this.vfs.readFile(loadOrderPath), loadOrderPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.modLoadOrder.getLoadOrder();
|
||||
}
|
||||
|
||||
return this.modLoadOrder.getLoadOrder();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -737,9 +734,7 @@ export class PreAkiModLoader implements IModLoader
|
||||
{
|
||||
return PreAkiModLoader.container;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Error(this.localisationService.getText("modloader-dependency_container_not_initalized"));
|
||||
}
|
||||
|
||||
throw new Error(this.localisationService.getText("modloader-dependency_container_not_initalized"));
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,7 @@
|
||||
// biome-ignore lint/suspicious/noEmptyInterface: <explanation>
|
||||
export interface IAcceptFriendRequestData extends IBaseFriendRequest
|
||||
{
|
||||
}
|
||||
|
||||
// biome-ignore lint/suspicious/noEmptyInterface: <explanation>
|
||||
export interface ICancelFriendRequestData extends IBaseFriendRequest
|
||||
{
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
import { QteActivityType } from "@spt-aki/models/enums/hideout/QteActivityType";
|
||||
import { QteEffectType } from "@spt-aki/models/enums/hideout/QteEffectType";
|
||||
import { QteType } from "@spt-aki/models/enums/hideout/QteType";
|
||||
import { HideoutAreas } from "@spt-aki/models/enums/HideoutAreas";
|
||||
import { RequirementType } from "@spt-aki/models/enums/hideout/RequirementType";
|
||||
import { SkillTypes } from "@spt-aki/models/enums/SkillTypes";
|
||||
import { Traders } from "@spt-aki/models/enums/Traders";
|
||||
import { Effect } from "@spt-aki/models/eft/health/Effect";
|
||||
import { BodyPart } from "@spt-aki/models/eft/health/IOffraidHealRequestData";
|
||||
import { QteRewardType } from "@spt-aki/models/enums/hideout/QteRewardType";
|
||||
import { HideoutAreas } from "@spt-aki/models/enums/HideoutAreas";
|
||||
import { SkillTypes } from "@spt-aki/models/enums/SkillTypes";
|
||||
import { Traders } from "@spt-aki/models/enums/Traders";
|
||||
import { QteActivityType } from "@spt-aki/models/enums/hideout/QteActivityType";
|
||||
import { QteEffectType } from "@spt-aki/models/enums/hideout/QteEffectType";
|
||||
import { QteResultType } from "@spt-aki/models/enums/hideout/QteResultType";
|
||||
import { QteRewardType } from "@spt-aki/models/enums/hideout/QteRewardType";
|
||||
import { QteType } from "@spt-aki/models/enums/hideout/QteType";
|
||||
import { RequirementType } from "@spt-aki/models/enums/hideout/RequirementType";
|
||||
|
||||
export interface IQteData
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
export enum ModSpawn
|
||||
{
|
||||
DEFAULT_MOD,
|
||||
SPAWN,
|
||||
SKIP,
|
||||
DEFAULT_MOD = 0,
|
||||
SPAWN = 1,
|
||||
SKIP = 2,
|
||||
}
|
||||
|
@ -2,14 +2,14 @@ import { inject, injectAll, injectable } from "tsyringe";
|
||||
|
||||
import { SaveLoadRouter } from "@spt-aki/di/Router";
|
||||
import { IAkiProfile, Info } from "@spt-aki/models/eft/profile/IAkiProfile";
|
||||
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
|
||||
import { ICoreConfig } from "@spt-aki/models/spt/config/ICoreConfig";
|
||||
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
|
||||
import { LocalisationService } from "@spt-aki/services/LocalisationService";
|
||||
import { HashUtil } from "@spt-aki/utils/HashUtil";
|
||||
import { JsonUtil } from "@spt-aki/utils/JsonUtil";
|
||||
import { VFS } from "@spt-aki/utils/VFS";
|
||||
import { ConfigServer } from "./ConfigServer";
|
||||
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
|
||||
import { ICoreConfig } from "@spt-aki/models/spt/config/ICoreConfig";
|
||||
|
||||
@injectable()
|
||||
export class SaveServer
|
||||
|
@ -3,6 +3,7 @@ import { inject, injectable } from "tsyringe";
|
||||
import WebSocket from "ws";
|
||||
|
||||
import { HttpServerHelper } from "@spt-aki/helpers/HttpServerHelper";
|
||||
import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper";
|
||||
import { INotification, NotificationType } from "@spt-aki/models/eft/notifier/INotifier";
|
||||
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
|
||||
import { IHttpConfig } from "@spt-aki/models/spt/config/IHttpConfig";
|
||||
@ -11,7 +12,6 @@ import { ConfigServer } from "@spt-aki/servers/ConfigServer";
|
||||
import { LocalisationService } from "@spt-aki/services/LocalisationService";
|
||||
import { JsonUtil } from "@spt-aki/utils/JsonUtil";
|
||||
import { RandomUtil } from "@spt-aki/utils/RandomUtil";
|
||||
import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper";
|
||||
|
||||
@injectable()
|
||||
export class WebSocketServer
|
||||
|
@ -1379,7 +1379,7 @@ export class ProfileFixerService
|
||||
|
||||
for (let i = 0; i < profileQuests.length; i++)
|
||||
{
|
||||
if (!quests[profileQuests[i].qid] && !repeatableQuests.find((x) => x._id == profileQuests[i].qid))
|
||||
if (!(quests[profileQuests[i].qid] || repeatableQuests.find((x) => x._id === profileQuests[i].qid)))
|
||||
{
|
||||
profileQuests.splice(i, 1);
|
||||
this.logger.success("Successfully removed orphaned quest that doesnt exist in our quest data");
|
||||
|
@ -34,7 +34,7 @@ export class RagfairCategoriesService
|
||||
const isTraderOffer = offer.user.memberType === MemberCategory.TRADER;
|
||||
|
||||
// Not level 15 and offer is from player, skip
|
||||
if (!fleaUnlocked && !isTraderOffer)
|
||||
if (!(fleaUnlocked || isTraderOffer))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -274,7 +274,8 @@ export class RagfairPriceService implements OnLoad
|
||||
{
|
||||
return priceRanges.preset;
|
||||
}
|
||||
else if (isPack)
|
||||
|
||||
if (isPack)
|
||||
{
|
||||
return priceRanges.pack;
|
||||
}
|
||||
@ -283,7 +284,7 @@ export class RagfairPriceService implements OnLoad
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if an items price is below its handbook price and adjust accoring to values set to config/ragfair.json
|
||||
* Check to see if an items price is below its handbook price and adjust according to values set to config/ragfair.json
|
||||
* @param itemPrice price of item
|
||||
* @param itemTpl item template Id being checked
|
||||
* @returns adjusted price value in roubles
|
||||
|
@ -211,11 +211,9 @@ export class RepairService
|
||||
this.repairConfig.maxIntellectGainPerRepair.kit,
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Trader repair - Not as accurate as kit, needs data from live
|
||||
return Math.min(repairDetails.repairAmount / 10, this.repairConfig.maxIntellectGainPerRepair.trader);
|
||||
}
|
||||
|
||||
// Trader repair - Not as accurate as kit, needs data from live
|
||||
return Math.min(repairDetails.repairAmount / 10, this.repairConfig.maxIntellectGainPerRepair.trader);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -351,14 +349,12 @@ export class RepairService
|
||||
|
||||
return durabilityPointCostArmor * armorBonus * destructability * armorClassMultiplier;
|
||||
}
|
||||
else
|
||||
{
|
||||
const repairWeaponBonus = this.getBonusMultiplierValue(BonusType.REPAIR_WEAPON_BONUS, pmcData) - 1;
|
||||
const repairPointMultiplier = 1.0 - repairWeaponBonus - intellectPointReduction;
|
||||
const durabilityPointCostGuns = globals.config.RepairSettings.durabilityPointCostGuns;
|
||||
|
||||
return durabilityPointCostGuns * repairPointMultiplier;
|
||||
}
|
||||
const repairWeaponBonus = this.getBonusMultiplierValue(BonusType.REPAIR_WEAPON_BONUS, pmcData) - 1;
|
||||
const repairPointMultiplier = 1.0 - repairWeaponBonus - intellectPointReduction;
|
||||
const durabilityPointCostGuns = globals.config.RepairSettings.durabilityPointCostGuns;
|
||||
|
||||
return durabilityPointCostGuns * repairPointMultiplier;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -540,30 +536,34 @@ export class RepairService
|
||||
* @param itemTemplate Item to check for skill
|
||||
* @returns Skill name
|
||||
*/
|
||||
protected getItemSkillType(itemTemplate: ITemplateItem): SkillTypes
|
||||
protected getItemSkillType(itemTemplate: ITemplateItem): SkillTypes | undefined
|
||||
{
|
||||
if (
|
||||
this.itemHelper.isOfBaseclasses(itemTemplate._id, [
|
||||
BaseClasses.ARMOR,
|
||||
BaseClasses.VEST,
|
||||
BaseClasses.HEADWEAR,
|
||||
])
|
||||
)
|
||||
const isArmorRelated = this.itemHelper.isOfBaseclasses(itemTemplate._id, [
|
||||
BaseClasses.ARMOR,
|
||||
BaseClasses.VEST,
|
||||
BaseClasses.HEADWEAR,
|
||||
]);
|
||||
|
||||
if (isArmorRelated)
|
||||
{
|
||||
if (itemTemplate._props.ArmorType === "Light")
|
||||
const armorType = itemTemplate._props.ArmorType;
|
||||
if (armorType === "Light")
|
||||
{
|
||||
return SkillTypes.LIGHT_VESTS;
|
||||
}
|
||||
else if (itemTemplate._props.ArmorType === "Heavy")
|
||||
|
||||
if (armorType === "Heavy")
|
||||
{
|
||||
return SkillTypes.HEAVY_VESTS;
|
||||
}
|
||||
}
|
||||
else if (this.itemHelper.isOfBaseclass(itemTemplate._id, BaseClasses.WEAPON))
|
||||
|
||||
if (this.itemHelper.isOfBaseclass(itemTemplate._id, BaseClasses.WEAPON))
|
||||
{
|
||||
return SkillTypes.WEAPON_TREATMENT;
|
||||
}
|
||||
else if (this.itemHelper.isOfBaseclass(itemTemplate._id, BaseClasses.KNIFE))
|
||||
|
||||
if (this.itemHelper.isOfBaseclass(itemTemplate._id, BaseClasses.KNIFE))
|
||||
{
|
||||
return SkillTypes.MELEE;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ export class HttpFileUtil
|
||||
|| this.httpServerHelper.getMimeText("txt");
|
||||
const fileStream = fs.createReadStream(file);
|
||||
|
||||
fileStream.on("open", function()
|
||||
fileStream.on("open", () =>
|
||||
{
|
||||
resp.setHeader("Content-Type", type);
|
||||
fileStream.pipe(resp);
|
||||
|
@ -86,18 +86,17 @@ export class MathUtil
|
||||
{
|
||||
return y[y.length - 1];
|
||||
}
|
||||
else if (xp < x[0])
|
||||
|
||||
if (xp < x[0])
|
||||
{
|
||||
return y[0];
|
||||
}
|
||||
else
|
||||
|
||||
for (let i = 0; i < x.length - 1; i++)
|
||||
{
|
||||
for (let i = 0; i < x.length - 1; i++)
|
||||
if (xp >= x[i] && xp <= x[i + 1])
|
||||
{
|
||||
if (xp >= x[i] && xp <= x[i + 1])
|
||||
{
|
||||
return y[i] + (xp - x[i]) * (y[i + 1] - y[i]) / (x[i + 1] - x[i]);
|
||||
}
|
||||
return y[i] + (xp - x[i]) * (y[i + 1] - y[i]) / (x[i + 1] - x[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user