Replace single letter variables with better names

This commit is contained in:
Dev 2024-04-23 21:07:34 +01:00
parent 96208ed95f
commit d49bf4a378
3 changed files with 47 additions and 39 deletions

View File

@ -131,7 +131,7 @@ export class DialogueController
// User to user messages are special in that they need the player to exist in them, add if they don't
if (
messageType === MessageType.USER_MESSAGE
&& !dialog.Users?.find((x) => x._id === profile.characters.pmc.sessionId)
&& !dialog.Users?.find((userDialog) => userDialog._id === profile.characters.pmc.sessionId)
)
{
if (!dialog.Users)
@ -230,9 +230,9 @@ export class DialogueController
{
result.push(...dialogUsers);
// Player doesnt exist, add them in before returning
if (!result.find((x) => x._id === fullProfile.info.id))
if (!result.find((userDialog) => userDialog._id === fullProfile.info.id))
{
// Player doesnt exist, add them in before returning
const pmcProfile = fullProfile.characters.pmc;
result.push({
_id: fullProfile.info.id,
@ -278,7 +278,7 @@ export class DialogueController
*/
protected messagesHaveUncollectedRewards(messages: Message[]): boolean
{
return messages.some((x) => x.items?.data?.length > 0);
return messages.some((message) => message.items?.data?.length > 0);
}
/**
@ -391,7 +391,7 @@ export class DialogueController
{
const timeNow = this.timeUtil.getTimestamp();
const dialogs = this.dialogueHelper.getDialogsForProfile(sessionId);
return dialogs[dialogueId].messages.filter((x) => timeNow < (x.dt + x.maxStorageTime));
return dialogs[dialogueId].messages.filter((message) => timeNow < (message.dt + message.maxStorageTime));
}
/**
@ -401,7 +401,7 @@ export class DialogueController
*/
protected getMessagesWithAttachments(messages: Message[]): Message[]
{
return messages.filter((x) => x.items?.data?.length > 0);
return messages.filter((message) => message.items?.data?.length > 0);
}
/**

View File

@ -234,8 +234,8 @@ export class BotEquipmentModGenerator
}
// Get the front/back/side weights based on bots level
const plateSlotWeights = settings.botEquipmentConfig?.armorPlateWeighting?.find((x) =>
settings.botLevel >= x.levelRange.min && settings.botLevel <= x.levelRange.max
const plateSlotWeights = settings.botEquipmentConfig?.armorPlateWeighting?.find((armorWeight) =>
settings.botLevel >= armorWeight.levelRange.min && settings.botLevel <= armorWeight.levelRange.max
);
if (!plateSlotWeights)
{
@ -261,10 +261,10 @@ export class BotEquipmentModGenerator
const chosenArmorPlateLevel = this.weightedRandomHelper.getWeightedValue<string>(plateWeights);
// Convert the array of ids into database items
const platesFromDb = existingPlateTplPool.map((x) => this.itemHelper.getItem(x)[1]);
const platesFromDb = existingPlateTplPool.map((plateTpl) => this.itemHelper.getItem(plateTpl)[1]);
// Filter plates to the chosen level based on its armorClass property
const filteredPlates = platesFromDb.filter((x) => x._props.armorClass === chosenArmorPlateLevel);
const filteredPlates = platesFromDb.filter((item) => item._props.armorClass === chosenArmorPlateLevel);
if (filteredPlates.length === 0)
{
this.logger.debug(
@ -306,7 +306,7 @@ export class BotEquipmentModGenerator
// Only return the items ids
result.result = Result.SUCCESS;
result.plateModTpls = filteredPlates.map((x) => x._id);
result.plateModTpls = filteredPlates.map((item) => item._id);
return result;
}
@ -468,8 +468,10 @@ export class BotEquipmentModGenerator
// Handguard mod can take a sub handguard mod + weapon has no UBGL (takes same slot)
// Force spawn chance to be 100% to ensure it gets added
if (
modSlot === "mod_handguard" && modToAddTemplate._props.Slots.find((x) => x._name === "mod_handguard")
&& !weapon.find((x) => x.slotId === "mod_launcher")
modSlot === "mod_handguard" && modToAddTemplate._props.Slots.find((slot) =>
slot._name === "mod_handguard"
)
&& !weapon.find((item) => item.slotId === "mod_launcher")
)
{
// Needed for handguards with lower
@ -479,8 +481,8 @@ export class BotEquipmentModGenerator
// If stock mod can take a sub stock mod, force spawn chance to be 100% to ensure sub-stock gets added
// Or if mod_stock is configured to be forced on
if (
modSlot === "mod_stock" && (modToAddTemplate._props.Slots.find((x) =>
x._name.includes("mod_stock") || botEquipConfig.forceStock
modSlot === "mod_stock" && (modToAddTemplate._props.Slots.find((slot) =>
slot._name.includes("mod_stock") || botEquipConfig.forceStock
))
)
{
@ -1174,7 +1176,7 @@ export class BotEquipmentModGenerator
botEquipBlacklist: EquipmentFilterDetails,
): void
{
const desiredSlotObject = modTemplate._props.Slots.find((x) => x._name.includes(desiredSlotName));
const desiredSlotObject = modTemplate._props.Slots.find((slot) => slot._name.includes(desiredSlotName));
if (desiredSlotObject)
{
const supportedSubMods = desiredSlotObject._props.filters[0].Filter;
@ -1260,7 +1262,7 @@ export class BotEquipmentModGenerator
const blacklist = this.itemFilterService.getBlacklistedItems().concat(
botEquipBlacklist.equipment[modSlot] || [],
);
result = allowedMods.filter((x) => !blacklist.includes(x));
result = allowedMods.filter((tpl) => !blacklist.includes(tpl));
return result;
}
@ -1286,7 +1288,7 @@ export class BotEquipmentModGenerator
weaponName: parentTemplate._name,
}),
);
const camoraSlots = parentTemplate._props.Slots.filter((x) => x._name.startsWith("camora"));
const camoraSlots = parentTemplate._props.Slots.filter((slot) => slot._name.startsWith("camora"));
// Attempt to generate camora slots for item
modPool[parentTemplate._id] = {};
@ -1420,16 +1422,16 @@ export class BotEquipmentModGenerator
{
// Check to see if mount has a scope slot (only include primary slot, ignore the rest like the backup sight slots)
// Should only find 1 as there's currently no items with a mod_scope AND a mod_scope_000
const scopeSlot = itemDetails._props.Slots.filter((x) =>
["mod_scope", "mod_scope_000"].includes(x._name)
const scopeSlot = itemDetails._props.Slots.filter((slot) =>
["mod_scope", "mod_scope_000"].includes(slot._name)
);
// Mods scope slot found must allow ALL whitelisted scope types OR be a mount
if (
scopeSlot?.every((x) =>
x._props.filters[0].Filter.every((x) =>
this.itemHelper.isOfBaseclasses(x, whitelistedSightTypes)
|| this.itemHelper.isOfBaseclass(x, BaseClasses.MOUNT)
scopeSlot?.every((slot) =>
slot._props.filters[0].Filter.every((tpl) =>
this.itemHelper.isOfBaseclasses(tpl, whitelistedSightTypes)
|| this.itemHelper.isOfBaseclass(tpl, BaseClasses.MOUNT)
)
)
)

View File

@ -218,8 +218,8 @@ export class LocationGenerator
for (const chosenContainerId of chosenContainerIds)
{
// Look up container object from full list of containers on map
const containerObject = staticRandomisableContainersOnMap.find((x) =>
x.template.Id === chosenContainerId
const containerObject = staticRandomisableContainersOnMap.find((staticContainer) =>
staticContainer.template.Id === chosenContainerId
);
if (!containerObject)
{
@ -262,10 +262,10 @@ export class LocationGenerator
*/
protected getRandomisableContainersOnMap(staticContainers: IStaticContainerData[]): IStaticContainerData[]
{
return staticContainers.filter((x) =>
x.probability !== 1 && !x.template.IsAlwaysSpawn
return staticContainers.filter((staticContainer) =>
staticContainer.probability !== 1 && !staticContainer.template.IsAlwaysSpawn
&& !this.locationConfig.containerRandomisationSettings.containerTypesToNotRandomise.includes(
x.template.Items[0]._tpl,
staticContainer.template.Items[0]._tpl,
)
);
}
@ -277,10 +277,10 @@ export class LocationGenerator
*/
protected getGuaranteedContainers(staticContainersOnMap: IStaticContainerData[]): IStaticContainerData[]
{
return staticContainersOnMap.filter((x) =>
x.probability === 1 || x.template.IsAlwaysSpawn
return staticContainersOnMap.filter((staticContainer) =>
staticContainer.probability === 1 || staticContainer.template.IsAlwaysSpawn
|| this.locationConfig.containerRandomisationSettings.containerTypesToNotRandomise.includes(
x.template.Items[0]._tpl,
staticContainer.template.Items[0]._tpl,
)
);
}
@ -659,7 +659,9 @@ export class LocationGenerator
}
// Filter out duplicate locationIds
chosenSpawnpoints = [...new Map(chosenSpawnpoints.map((x) => [x.locationId, x])).values()];
chosenSpawnpoints = [
...new Map(chosenSpawnpoints.map((spawnPoint) => [spawnPoint.locationId, spawnPoint])).values(),
];
// Do we have enough items in pool to fulfill requirement
const tooManySpawnPointsRequested = (desiredSpawnpointCount - chosenSpawnpoints.length) > 0;
@ -702,7 +704,7 @@ export class LocationGenerator
{
if (
!seasonalEventActive && seasonalItemTplBlacklist.includes(
spawnPoint.template.Items.find((x) => x._id === itemDist.composedKey.key)._tpl,
spawnPoint.template.Items.find((item) => item._id === itemDist.composedKey.key)._tpl,
)
)
{
@ -753,7 +755,9 @@ export class LocationGenerator
for (const itemTpl of lootToForceSingleAmountOnMap)
{
// Get all spawn positions for item tpl in forced loot array
const items = forcedSpawnPoints.filter((x) => x.template.Items[0]._tpl === itemTpl);
const items = forcedSpawnPoints.filter((forcedSpawnPoint) =>
forcedSpawnPoint.template.Items[0]._tpl === itemTpl
);
if (!items || items.length === 0)
{
this.logger.debug(
@ -776,7 +780,7 @@ export class LocationGenerator
// Choose 1 out of all found spawn positions for spawn id and add to loot array
for (const spawnPointLocationId of spawnpointArray.draw(1, false))
{
const itemToAdd = items.find((x) => x.locationId === spawnPointLocationId);
const itemToAdd = items.find((item) => item.locationId === spawnPointLocationId);
const lootItem = itemToAdd.template;
lootItem.Root = this.objectId.generate();
lootItem.Items[0]._id = lootItem.Root;
@ -812,7 +816,9 @@ export class LocationGenerator
locationTemplateToAdd.Items[0]._id = locationTemplateToAdd.Root;
// Push forced location into array as long as it doesnt exist already
const existingLocation = lootLocationTemplates.find((x) => x.Id === locationTemplateToAdd.Id);
const existingLocation = lootLocationTemplates.find((spawnPoint) =>
spawnPoint.Id === locationTemplateToAdd.Id
);
if (!existingLocation)
{
lootLocationTemplates.push(locationTemplateToAdd);
@ -839,7 +845,7 @@ export class LocationGenerator
staticAmmoDist: Record<string, IStaticAmmoDetails[]>,
): IContainerItem
{
const chosenItem = spawnPoint.template.Items.find((x) => x._id === chosenComposedKey);
const chosenItem = spawnPoint.template.Items.find((item) => item._id === chosenComposedKey);
const chosenTpl = chosenItem._tpl;
const itemTemplate = this.itemHelper.getItem(chosenTpl)[1];
@ -942,7 +948,7 @@ export class LocationGenerator
return items.find((v) => v._tpl === chosenTpl && v.parentId === undefined);
}
return items.find((x) => x._tpl === chosenTpl);
return items.find((item) => item._tpl === chosenTpl);
}
// TODO: rewrite, BIG yikes