Skip to content

Commit

Permalink
Modify files to make linter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchangelWTF committed Jan 9, 2025
1 parent 5d7d20f commit 7c20e16
Show file tree
Hide file tree
Showing 25 changed files with 137 additions and 72 deletions.
10 changes: 6 additions & 4 deletions project/src/controllers/DialogueController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,12 @@ export class DialogueController {

// Add any friends the user has after the chatbots
const profile = this.profileHelper.getFullProfile(sessionID);
for (const friendId of profile?.friends) {
const friendProfile = this.profileHelper.getChatRoomMemberFromSessionId(friendId);
if (friendProfile) {
friends.push(friendProfile);
if (profile?.friends) {
for (const friendId of profile.friends) {
const friendProfile = this.profileHelper.getChatRoomMemberFromSessionId(friendId);
if (friendProfile) {
friends.push(friendProfile);
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions project/src/controllers/GameController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ export class GameController {
// Hideout Improvement property changed name
if ((fullProfile.characters.pmc.Hideout as any).Improvement) {
fullProfile.characters.pmc.Hideout.Improvements = (fullProfile.characters.pmc.Hideout as any).Improvement;
// biome-ignore lint/performance/noDelete: Delete is fine here, as we're seeking to remove these entirely
delete (fullProfile.characters.pmc.Hideout as any).Improvement;
this.logger.warning(`Migration: Moved Hideout Improvement data to new property 'Improvements'`);
}
Expand All @@ -273,12 +274,14 @@ export class GameController {
// Remove PMC 'ragfair' from trader list
if (fullProfile.characters.pmc.TradersInfo.ragfair) {
this.logger.warning("Migration: deleting: ragfair traderinfo object from PMC");
// biome-ignore lint/performance/noDelete: Delete is fine here, as we're seeking to remove these entirely
delete fullProfile.characters.pmc.TradersInfo.ragfair;
}

// Remove SCAV 'ragfair' from trader list
if (fullProfile.characters.scav.TradersInfo.ragfair) {
this.logger.warning("Migration: deleting: ragfair traderinfo object from PMC");
// biome-ignore lint/performance/noDelete: Delete is fine here, as we're seeking to remove these entirely
delete fullProfile.characters.scav.TradersInfo.ragfair;
}

Expand Down Expand Up @@ -561,6 +564,7 @@ export class GameController {
protected checkForAndRemoveUndefinedDialogs(fullProfile: ISptProfile): void {
const undefinedDialog = fullProfile.dialogues.undefined;
if (undefinedDialog) {
// biome-ignore lint/performance/noDelete: Delete is fine here, as we're seeking to delete undefined dialogs.
delete fullProfile.dialogues.undefined;
}
}
Expand Down
1 change: 1 addition & 0 deletions project/src/controllers/HealthController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ export class HealthController {

// Remove empty effect object
if (Object.keys(pmcData.Health.BodyParts[bodyPartKey].Effects).length === 0) {
// biome-ignore lint/performance/noDelete: Delete is fine here as we entirely want to get rid of the effect.
delete pmcData.Health.BodyParts[bodyPartKey].Effects;
}
}
Expand Down
1 change: 1 addition & 0 deletions project/src/controllers/HideoutController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,7 @@ export class HideoutController {

if (hasMildPain) {
// Already has mild pain, remove mild and add severe
// biome-ignore lint/performance/noDelete: Deleting is fine here, we're removing the effect to replace it with another.
delete pmcData.Health.BodyParts.Chest.Effects.MildMusclePain;

pmcData.Health.BodyParts.Chest.Effects.SevereMusclePain = {
Expand Down
5 changes: 4 additions & 1 deletion project/src/controllers/InventoryController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ export class InventoryController {

// Remove FiR status from destination stack when source stack has no FiR but destination does
if (!sourceItem.upd.SpawnedInSession && destinationItem.upd.SpawnedInSession) {
delete destinationItem.upd.SpawnedInSession;
destinationItem.upd.SpawnedInSession = false;
}

destinationItem.upd.StackObjectsCount += sourceItem.upd.StackObjectsCount; // Add source stackcount to destination
Expand Down Expand Up @@ -408,6 +408,7 @@ export class InventoryController {
if (request.to.location) {
itemOne.location = request.to.location;
} else {
// biome-ignore lint/performance/noDelete: Delete is fine here as we entirely want to get rid of the location.
delete itemOne.location;
}

Expand All @@ -416,6 +417,7 @@ export class InventoryController {
if (request.to2.location) {
itemTwo.location = request.to2.location;
} else {
// biome-ignore lint/performance/noDelete: Delete is fine here as we entirely want to get rid of the location.
delete itemTwo.location;
}

Expand Down Expand Up @@ -721,6 +723,7 @@ export class InventoryController {
if (change.location) {
inventoryItem.location = change.location;
} else {
// biome-ignore lint/performance/noDelete: Delete is fine here as we entirely want to get rid of the location.
delete inventoryItem.location;
}
}
Expand Down
9 changes: 6 additions & 3 deletions project/src/generators/BotWeaponGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,12 @@ export class BotWeaponGenerator {
}

// Inner join the weapons allowed + passed in cartridge pool to get compatible cartridges
const compatibleCartridges = Object.keys(cartridgePoolForWeapon)
.filter((cartridge) => compatibleCartridgesInTemplate.includes(cartridge))
.reduce((acc, key) => ({ ...acc, [key]: cartridgePoolForWeapon[key] }), {});
const compatibleCartridges = {};
for (const cartridge of Object.keys(cartridgePoolForWeapon)) {
if (compatibleCartridgesInTemplate.includes(cartridge)) {
compatibleCartridges[cartridge] = cartridgePoolForWeapon[cartridge];
}
}

if (!compatibleCartridges) {
// No compatible cartridges, use default
Expand Down
4 changes: 2 additions & 2 deletions project/src/generators/LootGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,9 @@ export class LootGenerator {
const presetAndMods: IItem[] = this.itemHelper.replaceIDs(chosenPreset._items);
this.itemHelper.remapRootItemId(presetAndMods);
// Add chosen preset tpl to result array
presetAndMods.forEach((item) => {
for (const item of presetAndMods) {
result.push(item);
});
}

if (itemLimitCount) {
// Increment item count as item has been chosen and its inside itemLimitCount dictionary
Expand Down
2 changes: 2 additions & 0 deletions project/src/generators/RagfairOfferGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,9 @@ export class RagfairOfferGenerator {
this.itemHelper.reparentItemAndChildren(clonedAssort[0], clonedAssort);

// Clear unnecessary properties
// biome-ignore lint/performance/noDelete: Deleting is fine here, we're getting rid of unecessary properties.
delete clonedAssort[0].parentId;
// biome-ignore lint/performance/noDelete: Deleting is fine here, we're getting rid of unecessary properties.
delete clonedAssort[0].slotId;

assortSingleOfferProcesses.push(
Expand Down
10 changes: 6 additions & 4 deletions project/src/generators/RepeatableQuestRewardGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,20 +309,22 @@ export class RepeatableQuestRewardGenerator {
itemsToReturn.push({ item: chosenItemFromPool, stackSize: rewardItemStackCount });

const itemCost = this.presetHelper.getDefaultPresetOrItemPrice(chosenItemFromPool._id);
itemRewardBudget -= rewardItemStackCount * itemCost;
const calculatedItemRewardBudget = itemRewardBudget - rewardItemStackCount * itemCost;
this.logger.debug(`Added item: ${chosenItemFromPool._id} with price: ${rewardItemStackCount * itemCost}`);

// If we still have budget narrow down possible items
if (itemRewardBudget > 0) {
if (calculatedItemRewardBudget > 0) {
// Filter possible reward items to only items with a price below the remaining budget
exhausableItemPool = new ExhaustableArray(
this.filterRewardPoolWithinBudget(itemPool, itemRewardBudget, 0),
this.filterRewardPoolWithinBudget(itemPool, calculatedItemRewardBudget, 0),
this.randomUtil,
this.cloner,
);

if (!exhausableItemPool.hasValues()) {
this.logger.debug(`Reward pool empty with: ${itemRewardBudget} roubles of budget remaining`);
this.logger.debug(
`Reward pool empty with: ${calculatedItemRewardBudget} roubles of budget remaining`,
);
break; // No reward items left, exit
}
}
Expand Down
1 change: 1 addition & 0 deletions project/src/generators/ScavCaseRewardGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ export class ScavCaseRewardGenerator {

// Clean up upd object if it wasn't used
if (!rootItem.upd) {
// biome-ignore lint/performance/noDelete: Delete is fine here, we're cleaning up this object without leaving an undefined.
delete rootItem.upd;
}

Expand Down
2 changes: 2 additions & 0 deletions project/src/helpers/HealthHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ export class HealthHelper {
for (const bodyPart in bodyPartsWithEffects) {
// clear effects from profile bodyPart
if (deleteExistingEffects) {
// biome-ignore lint/performance/noDelete: Delete is fine here as we entirely want to get rid of the effect.
delete pmcData.Health.BodyParts[bodyPart].Effects;
}

Expand Down Expand Up @@ -339,6 +340,7 @@ export class HealthHelper {

// Delete empty property to prevent client bugs
if (this.isEmpty(profileBodyPart.Effects)) {
// biome-ignore lint/performance/noDelete: Delete is fine here, we're removing an empty property to prevent game bugs.
delete profileBodyPart.Effects;
}
}
Expand Down
5 changes: 5 additions & 0 deletions project/src/helpers/HideoutHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,11 @@ export class HideoutHelper {
break;
case BonusType.TEXT_BONUS:
// Delete values before they're added to profile
// biome-ignore lint/performance/noDelete: Delete is fine here as we entirely want to get rid of the data.
delete bonus.passive;
// biome-ignore lint/performance/noDelete: Delete is fine here as we entirely want to get rid of the data.
delete bonus.production;
// biome-ignore lint/performance/noDelete: Delete is fine here as we entirely want to get rid of the data.
delete bonus.visible;
break;
}
Expand Down Expand Up @@ -781,6 +784,7 @@ export class HideoutHelper {
}

// Filter ran out / used up
// biome-ignore lint/performance/noDelete: Delete is fine here, as we're seeking to entirely delete the water filter.
delete waterFilterArea.slots[i].item;
// Update remaining resources to be subtracted
filterDrainRate = Math.abs(resourceValue);
Expand Down Expand Up @@ -919,6 +923,7 @@ export class HideoutHelper {
break; // Break here to avoid updating all filters
}

// biome-ignore lint/performance/noDelete: Delete is fine here, as we're seeking to entirely delete the air filter.
delete airFilterArea.slots[i].item;
// Update remaining resources to be subtracted
filterDrainRate = Math.abs(resourceValue);
Expand Down
4 changes: 3 additions & 1 deletion project/src/helpers/InRaidHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ export class InRaidHelper {
});

for (const item of itemsToRemovePropertyFrom) {
delete item.upd.SpawnedInSession;
if (item.upd) {
item.upd.SpawnedInSession = false;
}
}
}

Expand Down
11 changes: 10 additions & 1 deletion project/src/helpers/InventoryHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,14 @@ export class InventoryHelper {
// Ensure item has upd object
this.itemHelper.addUpdObjectToItem(item);

if (!item.upd) {
item.upd = {};
}

if (foundInRaid) {
item.upd.SpawnedInSession = foundInRaid;
} else {
delete item.upd.SpawnedInSession;
item.upd.SpawnedInSession = false;
}
}
}
Expand All @@ -191,14 +195,17 @@ export class InventoryHelper {
*/
protected removeTraderRagfairRelatedUpdProperties(upd: IUpd): void {
if (upd.UnlimitedCount !== undefined) {
// biome-ignore lint/performance/noDelete: Delete is fine here since we're attempting to remove this fully here.
delete upd.UnlimitedCount;
}

if (upd.BuyRestrictionCurrent !== undefined) {
// biome-ignore lint/performance/noDelete: Delete is fine here since we're attempting to remove this fully here.
delete upd.BuyRestrictionCurrent;
}

if (upd.BuyRestrictionMax !== undefined) {
// biome-ignore lint/performance/noDelete: Delete is fine here since we're attempting to remove this fully here.
delete upd.BuyRestrictionMax;
}
}
Expand Down Expand Up @@ -997,6 +1004,7 @@ export class InventoryHelper {
} else {
// No location in request, delete it
if (itemToMove.location) {
// biome-ignore lint/performance/noDelete: Delete is fine here as we're trying to remove the entire data property.
delete itemToMove.location;
}
}
Expand Down Expand Up @@ -1059,6 +1067,7 @@ export class InventoryHelper {
} else {
// Moved from slot with location to one without, clean up
if (matchingInventoryItem.location) {
// biome-ignore lint/performance/noDelete: Delete is fine here as we're trying to remove the entire data property.
delete matchingInventoryItem.location;
}
}
Expand Down
8 changes: 7 additions & 1 deletion project/src/helpers/ItemHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,7 @@ export class ItemHelper {

// In live no ammo box has the first cartridge item with a location
if (location === 0) {
// biome-ignore lint/performance/noDelete: Delete is fine here as we entirely want to get rid of the location.
delete cartridgeItemToAdd.location;
}

Expand Down Expand Up @@ -1366,6 +1367,7 @@ export class ItemHelper {

// Only one cartridge stack added, remove location property as its only used for 2 or more stacks
if (location === 1) {
// biome-ignore lint/performance/noDelete: Delete is fine here as we entirely want to get rid of the location.
delete magazineWithChildCartridges[1].location;
}
}
Expand Down Expand Up @@ -1706,6 +1708,7 @@ export class ItemHelper {
if (!parentExists && item.parentId !== rootId && item.slotId !== "hideout") {
item.parentId = rootId;
item.slotId = "hideout";
// biome-ignore lint/performance/noDelete: Delete is fine here as we entirely want to get rid of the location.
delete item.location;
}
}
Expand Down Expand Up @@ -1800,7 +1803,10 @@ export class ItemHelper {
*/
public removeSpawnedInSessionPropertyFromItems(items: IItem[]): void {
for (const item of items) {
delete item.upd.SpawnedInSession;
if (item.upd) {
// biome-ignore lint/performance/noDelete: Delete is fine here as we're removing the entire property.
delete item.upd.SpawnedInSession;
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions project/src/helpers/QuestHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ export class QuestHelper {
existingQuest.completedConditions = [];

if (existingQuest.availableAfter) {
// biome-ignore lint/performance/noDelete: Delete is fine here as we're trying to remove the entire data property.
delete existingQuest.availableAfter;
}

Expand Down
1 change: 1 addition & 0 deletions project/src/models/eft/common/IEmptyRequestData.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
// biome-ignore lint/complexity/noBannedTypes: Empty request is empty, this is fine.
export type IEmptyRequestData = {};
2 changes: 1 addition & 1 deletion project/src/services/BotEquipmentModPoolService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class BotEquipmentModPoolService {

// Check item added into array for slots, need to iterate over those
const subItemDetails = this.itemHelper.getItem(itemToAdd)[1];
const hasSubItemsToAdd = subItemDetails?._props?.Slots?.length ?? 0 > 0;
const hasSubItemsToAdd = (subItemDetails?._props?.Slots?.length ?? 0) > 0;
if (hasSubItemsToAdd && !pool[subItemDetails._id]) {
// Recursive call
this.generatePool([subItemDetails], poolType);
Expand Down
9 changes: 6 additions & 3 deletions project/src/services/FenceService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export class FenceService {
}

// Clean up the items
// biome-ignore lint/performance/noDelete: Delete is fine here as we're getting rid of the items before updating.
delete root.location;

const createAssort: ICreateFenceAssortsResult = { sptItems: [], barter_scheme: {}, loyal_level_items: {} };
Expand Down Expand Up @@ -1115,14 +1116,16 @@ export class FenceService {
continue;
}

let armorWithMods = armorItemAndMods;

const modItemDbDetails = this.itemHelper.getItem(plateTpl)[1];

// Chance to remove plate
const plateExistsChance =
this.traderConfig.fence.chancePlateExistsInArmorPercent[modItemDbDetails._props?.armorClass ?? "3"];
if (!this.randomUtil.getChance100(plateExistsChance)) {
// Remove plate from armor
armorItemAndMods = armorItemAndMods.filter(
armorWithMods = armorItemAndMods.filter(
(item) => item.slotId.toLowerCase() !== plateSlot._name.toLowerCase(),
);

Expand All @@ -1135,13 +1138,13 @@ export class FenceService {
);

// Find items mod to apply dura changes to
const modItemToAdjust = armorItemAndMods.find(
const modItemToAdjust = armorWithMods.find(
(mod) => mod.slotId.toLowerCase() === plateSlot._name.toLowerCase(),
);

if (!modItemToAdjust) {
this.logger.warning(
`Unable to randomise armor items ${armorItemAndMods[0]._tpl} ${plateSlot._name} slot as it cannot be found, skipping`,
`Unable to randomise armor items ${armorWithMods[0]._tpl} ${plateSlot._name} slot as it cannot be found, skipping`,
);
continue;
}
Expand Down
8 changes: 6 additions & 2 deletions project/src/services/ItemFilterService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ export class ItemFilterService {
*/
public isItemBlacklisted(tpl: string): boolean {
if (this.itemBlacklistCache.size === 0) {
this.itemConfig.blacklist.forEach((item) => this.itemBlacklistCache.add(item));
for (const item of this.itemConfig.blacklist) {
this.itemBlacklistCache.add(item);
}
}

return this.itemBlacklistCache.has(tpl);
Expand All @@ -42,7 +44,9 @@ export class ItemFilterService {
*/
public isLootableItemBlacklisted(tpl: string): boolean {
if (this.lootableItemBlacklistCache.size === 0) {
this.itemConfig.lootableItemBlacklist.forEach((item) => this.itemBlacklistCache.add(item));
for (const item of this.itemConfig.lootableItemBlacklist) {
this.itemBlacklistCache.add(item);
}
}

return this.lootableItemBlacklistCache.has(tpl);
Expand Down
Loading

0 comments on commit 7c20e16

Please sign in to comment.