Formatting for test classes.

This commit is contained in:
Refringe 2023-11-10 17:21:20 -05:00
parent 3ef51e771b
commit 320c8b7d48
No known key found for this signature in database
GPG Key ID: 64E03E5F892C6F9E
16 changed files with 1765 additions and 1749 deletions

View File

@ -9,8 +9,7 @@
"EditorConfig.EditorConfig", "EditorConfig.EditorConfig",
"dprint.dprint", "dprint.dprint",
"dbaeumer.vscode-eslint", "dbaeumer.vscode-eslint",
"biomejs.biome", "biomejs.biome"
"streetsidesoftware.code-spell-checker"
] ]
}, },
"settings": { "settings": {
@ -18,68 +17,7 @@
"editor.formatOnSave": true, "editor.formatOnSave": true,
"editor.defaultFormatter": "dprint.dprint", "editor.defaultFormatter": "dprint.dprint",
"editor.codeActionsOnSave": [ "editor.codeActionsOnSave": [
"source.fixAll.eslint",
"source.organizeImports.biome" "source.organizeImports.biome"
],
"cSpell.language": "en-GB",
"cSpell.words": [
"armor",
"asonline",
"behaviour",
"biomejs",
"botreload",
"currexp",
"currlvl",
"dbaeumer",
"deathmatch",
"dprint",
"edgeofdarkness",
"fulfill",
"gethideout",
"gifter",
"hpresource",
"inraid",
"isvalid",
"leftbehind",
"leveled",
"loadout",
"maxlvl",
"medkit",
"MEDSTATION",
"nextlvl",
"offraid",
"peacefullzryachiyevent",
"preparetoescape",
"prevexp",
"profileid",
"Protobuf",
"pscav",
"Ragfair",
"Regen",
"requestid",
"sanitise",
"Sanitised",
"scav",
"scavcase",
"scavs",
"Spawnpoint",
"spawnpoints",
"sptbear",
"sptdeveloper",
"spteasystart",
"sptusec",
"sptzerotohero",
"stackcount",
"statustimer",
"Tarkov",
"toggleable",
"tooshort",
"Ubgl",
"unrestartable",
"usec",
"userbuilds",
"weapongen",
"Wishlist"
] ]
} }
} }

View File

@ -1,17 +1,14 @@
import "reflect-metadata"; import "reflect-metadata";
import { container, DependencyContainer, Lifecycle } from "tsyringe"; import { container, DependencyContainer, Lifecycle } from "tsyringe";
// For the Vitest Custom Environment.
import type { Environment } from "vitest";
import { Container } from "@spt-aki/di/Container"; import { Container } from "@spt-aki/di/Container";
// Required for importing the database.
import path from "node:path";
import { IDatabaseTables } from "@spt-aki/models/spt/server/IDatabaseTables"; import { IDatabaseTables } from "@spt-aki/models/spt/server/IDatabaseTables";
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer"; import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
import { ImporterUtil } from "@spt-aki/utils/ImporterUtil"; import { ImporterUtil } from "@spt-aki/utils/ImporterUtil";
import path from "node:path";
import type { Environment } from "vitest";
// Manually mock for the logger. // Manually mock the logger.
import { WinstonLogger } from "@tests/__mocks__/WinstonLogger.mock"; import { WinstonLogger } from "@tests/__mocks__/WinstonLogger.mock";
export default <Environment>{ export default <Environment>{
@ -31,9 +28,9 @@ export default <Environment> {
return { return {
async teardown() async teardown()
{} {},
}; };
} },
}; };
/** /**

View File

@ -1,11 +1,12 @@
import "reflect-metadata"; import "reflect-metadata";
import { container } from "tsyringe"; import { container } from "tsyringe";
import { format } from "date-fns";
import { profileInsuranceFixture } from "@tests/__fixture__/profileInsurance.fixture";
import { Insurance } from "@spt-aki/models/eft/profile/IAkiProfile";
import { ItemHelper } from "@spt-aki/helpers/ItemHelper";
type DateInput = number | number[] | { [index: number]: number }; import { ItemHelper } from "@spt-aki/helpers/ItemHelper";
import { Insurance } from "@spt-aki/models/eft/profile/IAkiProfile";
import { profileInsuranceFixture } from "@tests/__fixture__/profileInsurance.fixture";
import { format } from "date-fns";
type DateInput = number | number[] | {[index: number]: number;};
export class ProfileInsuranceFactory export class ProfileInsuranceFactory
{ {
@ -61,7 +62,7 @@ export class ProfileInsuranceFactory
this.profileInsuranceFixture = this.profileInsuranceFixture.map((insurance) => this.profileInsuranceFixture = this.profileInsuranceFixture.map((insurance) =>
{ {
insurance.items = insurance.items.filter(item => !itemHelper.isAttachmentAttached(item)); insurance.items = insurance.items.filter((item) => !itemHelper.isAttachmentAttached(item));
return insurance; return insurance;
}); });
@ -78,8 +79,7 @@ export class ProfileInsuranceFactory
this.profileInsuranceFixture = this.profileInsuranceFixture.map((insurance) => this.profileInsuranceFixture = this.profileInsuranceFixture.map((insurance) =>
{ {
insurance.items = insurance.items.filter(item => itemHelper.isAttachmentAttached(item)); insurance.items = insurance.items.filter((item) => itemHelper.isAttachmentAttached(item));
return insurance; return insurance;
}); });

View File

@ -2,1411 +2,1411 @@ import { Insurance } from "@spt-aki/models/eft/profile/IAkiProfile";
export const profileInsuranceFixture: Insurance[] = [ export const profileInsuranceFixture: Insurance[] = [
{ {
"scheduledTime": 1698945140, scheduledTime: 1698945140,
"traderId": "54cb50c76803fa8b248b4571", // Prapor traderId: "54cb50c76803fa8b248b4571", // Prapor
"messageContent": { messageContent: {
"templateId": "58fe0e4586f774728248ca13 4", templateId: "58fe0e4586f774728248ca13 4",
"type": 8, type: 8,
"maxStorageTime": 345600, maxStorageTime: 345600,
"text": "", text: "",
"profileChangeEvents": [], profileChangeEvents: [],
"systemData": { systemData: {
"date": "01.11.2023", date: "01.11.2023",
"time": "10:51", time: "10:51",
"location": "factory4_day" location: "factory4_day",
} },
}, },
"items": [ items: [
{ {
"_id": "3679078e05f5b14466d6a730", _id: "3679078e05f5b14466d6a730",
"_tpl": "5d6d3716a4b9361bc8618872", _tpl: "5d6d3716a4b9361bc8618872",
"parentId": "5fe49444ae6628187a2e77b8", parentId: "5fe49444ae6628187a2e77b8",
"slotId": "hideout", slotId: "hideout",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 55, Durability: 55,
"MaxDurability": 55 MaxDurability: 55,
} },
} },
}, },
{ {
"_id": "911a0f04d5d9c7e239807ae0", _id: "911a0f04d5d9c7e239807ae0",
"_tpl": "5644bd2b4bdc2d3b4c8b4572", _tpl: "5644bd2b4bdc2d3b4c8b4572",
"parentId": "5fe49444ae6628187a2e77b8", parentId: "5fe49444ae6628187a2e77b8",
"slotId": "hideout", slotId: "hideout",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 97.7862549, Durability: 97.7862549,
"MaxDurability": 100 MaxDurability: 100,
} },
} },
}, },
{ {
"_id": "695b13896108f765e8985698", _id: "695b13896108f765e8985698",
"_tpl": "5648a69d4bdc2ded0b8b457b", _tpl: "5648a69d4bdc2ded0b8b457b",
"parentId": "5fe49444ae6628187a2e77b8", parentId: "5fe49444ae6628187a2e77b8",
"slotId": "hideout", slotId: "hideout",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "bb49d6ceb3e87d8563a06455", _id: "bb49d6ceb3e87d8563a06455",
"_tpl": "5df8a4d786f77412672a1e3b", _tpl: "5df8a4d786f77412672a1e3b",
"parentId": "5fe49444ae6628187a2e77b8", parentId: "5fe49444ae6628187a2e77b8",
"slotId": "hideout", slotId: "hideout",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "631f8492de748dec852f7ddf", _id: "631f8492de748dec852f7ddf",
"_tpl": "64abd93857958b4249003418", _tpl: "64abd93857958b4249003418",
"parentId": "5fe49444ae6628187a2e77b8", parentId: "5fe49444ae6628187a2e77b8",
"slotId": "hideout", slotId: "hideout",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 49.2865, Durability: 49.2865,
"MaxDurability": 60 MaxDurability: 60,
} },
} },
}, },
{ {
"_id": "a2b0c716162c5e31ec28c55a", _id: "a2b0c716162c5e31ec28c55a",
"_tpl": "5a16b8a9fcdbcb00165aa6ca", _tpl: "5a16b8a9fcdbcb00165aa6ca",
"parentId": "3679078e05f5b14466d6a730", parentId: "3679078e05f5b14466d6a730",
"slotId": "mod_nvg", slotId: "mod_nvg",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "dc565f750342cb2d19eeda06", _id: "dc565f750342cb2d19eeda06",
"_tpl": "5d6d3be5a4b9361bc73bc763", _tpl: "5d6d3be5a4b9361bc73bc763",
"parentId": "3679078e05f5b14466d6a730", parentId: "3679078e05f5b14466d6a730",
"slotId": "mod_equipment_001", slotId: "mod_equipment_001",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 29.33, Durability: 29.33,
"MaxDurability": 29.33 MaxDurability: 29.33,
} },
} },
}, },
{ {
"_id": "e9ff62601669d9e2ea9c2fbb", _id: "e9ff62601669d9e2ea9c2fbb",
"_tpl": "5d6d3943a4b9360dbc46d0cc", _tpl: "5d6d3943a4b9360dbc46d0cc",
"parentId": "3679078e05f5b14466d6a730", parentId: "3679078e05f5b14466d6a730",
"slotId": "mod_equipment_002", slotId: "mod_equipment_002",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "ac134d7cf6c9d8e25edd0015", _id: "ac134d7cf6c9d8e25edd0015",
"_tpl": "5c11046cd174af02a012e42b", _tpl: "5c11046cd174af02a012e42b",
"parentId": "a2b0c716162c5e31ec28c55a", parentId: "a2b0c716162c5e31ec28c55a",
"slotId": "mod_nvg", slotId: "mod_nvg",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "22274b895ecc80d51c3cba1c", _id: "22274b895ecc80d51c3cba1c",
"_tpl": "5c110624d174af029e69734c", _tpl: "5c110624d174af029e69734c",
"parentId": "ac134d7cf6c9d8e25edd0015", parentId: "ac134d7cf6c9d8e25edd0015",
"slotId": "mod_nvg", slotId: "mod_nvg",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 100, Durability: 100,
"MaxDurability": 100 MaxDurability: 100,
}, },
"Togglable": { Togglable: {
"On": true On: true,
} },
} },
}, },
{ {
"_id": "c9278dd8251e99578bf7a274", _id: "c9278dd8251e99578bf7a274",
"_tpl": "59c6633186f7740cf0493bb9", _tpl: "59c6633186f7740cf0493bb9",
"parentId": "911a0f04d5d9c7e239807ae0", parentId: "911a0f04d5d9c7e239807ae0",
"slotId": "mod_gas_block", slotId: "mod_gas_block",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "677c209ebb45445ebb42c405", _id: "677c209ebb45445ebb42c405",
"_tpl": "5649ab884bdc2ded0b8b457f", _tpl: "5649ab884bdc2ded0b8b457f",
"parentId": "911a0f04d5d9c7e239807ae0", parentId: "911a0f04d5d9c7e239807ae0",
"slotId": "mod_muzzle", slotId: "mod_muzzle",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "8ada5c9cc26585281577c6eb", _id: "8ada5c9cc26585281577c6eb",
"_tpl": "5649ae4a4bdc2d1b2b8b4588", _tpl: "5649ae4a4bdc2d1b2b8b4588",
"parentId": "911a0f04d5d9c7e239807ae0", parentId: "911a0f04d5d9c7e239807ae0",
"slotId": "mod_pistol_grip", slotId: "mod_pistol_grip",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "4bd10f89836fd9f86aedcac1", _id: "4bd10f89836fd9f86aedcac1",
"_tpl": "5649af094bdc2df8348b4586", _tpl: "5649af094bdc2df8348b4586",
"parentId": "911a0f04d5d9c7e239807ae0", parentId: "911a0f04d5d9c7e239807ae0",
"slotId": "mod_reciever", slotId: "mod_reciever",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "8b1327270791b142ac341b03", _id: "8b1327270791b142ac341b03",
"_tpl": "5649d9a14bdc2d79388b4580", _tpl: "5649d9a14bdc2d79388b4580",
"parentId": "911a0f04d5d9c7e239807ae0", parentId: "911a0f04d5d9c7e239807ae0",
"slotId": "mod_sight_rear", slotId: "mod_sight_rear",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "566335b3df586f34b47f5e35", _id: "566335b3df586f34b47f5e35",
"_tpl": "5649b2314bdc2d79388b4576", _tpl: "5649b2314bdc2d79388b4576",
"parentId": "911a0f04d5d9c7e239807ae0", parentId: "911a0f04d5d9c7e239807ae0",
"slotId": "mod_stock", slotId: "mod_stock",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "da8cde1b3024c336f6e06152", _id: "da8cde1b3024c336f6e06152",
"_tpl": "55d482194bdc2d1d4e8b456b", _tpl: "55d482194bdc2d1d4e8b456b",
"parentId": "911a0f04d5d9c7e239807ae0", parentId: "911a0f04d5d9c7e239807ae0",
"slotId": "mod_magazine", slotId: "mod_magazine",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 100, Durability: 100,
"MaxDurability": 100 MaxDurability: 100,
} },
} },
}, },
{ {
"_id": "1e0b177df108c0c117028812", _id: "1e0b177df108c0c117028812",
"_tpl": "57cffddc24597763133760c6", _tpl: "57cffddc24597763133760c6",
"parentId": "c9278dd8251e99578bf7a274", parentId: "c9278dd8251e99578bf7a274",
"slotId": "mod_handguard", slotId: "mod_handguard",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "bc041c0011d76f714b898400", _id: "bc041c0011d76f714b898400",
"_tpl": "57cffcd624597763133760c5", _tpl: "57cffcd624597763133760c5",
"parentId": "1e0b177df108c0c117028812", parentId: "1e0b177df108c0c117028812",
"slotId": "mod_mount_003", slotId: "mod_mount_003",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "9f8d7880a6e0a47a211ec5d3", _id: "9f8d7880a6e0a47a211ec5d3",
"_tpl": "58491f3324597764bc48fa02", _tpl: "58491f3324597764bc48fa02",
"parentId": "8b1327270791b142ac341b03", parentId: "8b1327270791b142ac341b03",
"slotId": "mod_scope", slotId: "mod_scope",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "402b4086535a50ef7d9cef88", _id: "402b4086535a50ef7d9cef88",
"_tpl": "5649be884bdc2d79388b4577", _tpl: "5649be884bdc2d79388b4577",
"parentId": "566335b3df586f34b47f5e35", parentId: "566335b3df586f34b47f5e35",
"slotId": "mod_stock", slotId: "mod_stock",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "db2ef9442178910eba985b51", _id: "db2ef9442178910eba985b51",
"_tpl": "58d2946386f774496974c37e", _tpl: "58d2946386f774496974c37e",
"parentId": "402b4086535a50ef7d9cef88", parentId: "402b4086535a50ef7d9cef88",
"slotId": "mod_stock_000", slotId: "mod_stock_000",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "3c32b7d47ad80e83749fa906", _id: "3c32b7d47ad80e83749fa906",
"_tpl": "58d2912286f7744e27117493", _tpl: "58d2912286f7744e27117493",
"parentId": "db2ef9442178910eba985b51", parentId: "db2ef9442178910eba985b51",
"slotId": "mod_stock", slotId: "mod_stock",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "574a9b5535585255cde19570", _id: "574a9b5535585255cde19570",
"_tpl": "55d482194bdc2d1d4e8b456b", _tpl: "55d482194bdc2d1d4e8b456b",
"parentId": "695b13896108f765e8985698", parentId: "695b13896108f765e8985698",
"slotId": "1", slotId: "1",
"location": { location: {
"x": 0, x: 0,
"y": 0, y: 0,
"r": "Horizontal", r: "Horizontal",
"isSearched": true isSearched: true,
}, },
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 100, Durability: 100,
"MaxDurability": 100 MaxDurability: 100,
} },
} },
}, },
{ {
"_id": "696835b2badfb96623ea887c", _id: "696835b2badfb96623ea887c",
"_tpl": "55d482194bdc2d1d4e8b456b", _tpl: "55d482194bdc2d1d4e8b456b",
"parentId": "695b13896108f765e8985698", parentId: "695b13896108f765e8985698",
"slotId": "2", slotId: "2",
"location": { location: {
"x": 0, x: 0,
"y": 0, y: 0,
"r": "Horizontal", r: "Horizontal",
"isSearched": true isSearched: true,
}, },
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 100, Durability: 100,
"MaxDurability": 100 MaxDurability: 100,
} },
} },
}, },
{ {
"_id": "c2d5e23c7886e8ff02010731", _id: "c2d5e23c7886e8ff02010731",
"_tpl": "55d482194bdc2d1d4e8b456b", _tpl: "55d482194bdc2d1d4e8b456b",
"parentId": "695b13896108f765e8985698", parentId: "695b13896108f765e8985698",
"slotId": "3", slotId: "3",
"location": { location: {
"x": 0, x: 0,
"y": 0, y: 0,
"r": "Horizontal", r: "Horizontal",
"isSearched": true isSearched: true,
}, },
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 100, Durability: 100,
"MaxDurability": 100 MaxDurability: 100,
} },
} },
}, },
{ {
"_id": "306de2f475a559610a4f6f1d", _id: "306de2f475a559610a4f6f1d",
"_tpl": "55d482194bdc2d1d4e8b456b", _tpl: "55d482194bdc2d1d4e8b456b",
"parentId": "695b13896108f765e8985698", parentId: "695b13896108f765e8985698",
"slotId": "4", slotId: "4",
"location": { location: {
"x": 0, x: 0,
"y": 0, y: 0,
"r": "Horizontal", r: "Horizontal",
"isSearched": true isSearched: true,
}, },
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 100, Durability: 100,
"MaxDurability": 100 MaxDurability: 100,
} },
} },
}, },
{ {
"_id": "eb0445b49a97e84e27d47f3c", _id: "eb0445b49a97e84e27d47f3c",
"_tpl": "5aa2ba71e5b5b000137b758f", _tpl: "5aa2ba71e5b5b000137b758f",
"parentId": "695b13896108f765e8985698", parentId: "695b13896108f765e8985698",
"slotId": "5", slotId: "5",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
}, },
"location": { location: {
"x": 0, x: 0,
"y": 0, y: 0,
"r": "Horizontal", r: "Horizontal",
"isSearched": true isSearched: true,
} },
}, },
{ {
"_id": "fad89a5bdfd23e3248123346", _id: "fad89a5bdfd23e3248123346",
"_tpl": "5fc5396e900b1d5091531e72", _tpl: "5fc5396e900b1d5091531e72",
"parentId": "695b13896108f765e8985698", parentId: "695b13896108f765e8985698",
"slotId": "6", slotId: "6",
"location": { location: {
"x": 0, x: 0,
"y": 0, y: 0,
"r": "Horizontal", r: "Horizontal",
"isSearched": true isSearched: true,
}, },
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "b16c2a938954cd69c687c51a", _id: "b16c2a938954cd69c687c51a",
"_tpl": "5b4736b986f77405cb415c10", _tpl: "5b4736b986f77405cb415c10",
"parentId": "695b13896108f765e8985698", parentId: "695b13896108f765e8985698",
"slotId": "7", slotId: "7",
"location": { location: {
"x": 0, x: 0,
"y": 0, y: 0,
"r": "Horizontal", r: "Horizontal",
"isSearched": true isSearched: true,
}, },
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 100, Durability: 100,
"MaxDurability": 100 MaxDurability: 100,
} },
} },
}, },
{ {
"_id": "a2b3019ac8d340eeb068d429", _id: "a2b3019ac8d340eeb068d429",
"_tpl": "5ea18c84ecf1982c7712d9a2", _tpl: "5ea18c84ecf1982c7712d9a2",
"parentId": "695b13896108f765e8985698", parentId: "695b13896108f765e8985698",
"slotId": "10", slotId: "10",
"location": { location: {
"x": 0, x: 0,
"y": 0, y: 0,
"r": "Vertical", r: "Vertical",
"isSearched": true isSearched: true,
}, },
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 29, Durability: 29,
"MaxDurability": 33 MaxDurability: 33,
} },
} },
}, },
{ {
"_id": "0b3c5d183e8b506d655f85c4", _id: "0b3c5d183e8b506d655f85c4",
"_tpl": "644a3df63b0b6f03e101e065", _tpl: "644a3df63b0b6f03e101e065",
"parentId": "fad89a5bdfd23e3248123346", parentId: "fad89a5bdfd23e3248123346",
"slotId": "mod_tactical", slotId: "mod_tactical",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 100, Durability: 100,
"MaxDurability": 100 MaxDurability: 100,
} },
} },
}, },
{ {
"_id": "757211a0b648fe27b0475ded", _id: "757211a0b648fe27b0475ded",
"_tpl": "59f8a37386f7747af3328f06", _tpl: "59f8a37386f7747af3328f06",
"parentId": "b16c2a938954cd69c687c51a", parentId: "b16c2a938954cd69c687c51a",
"slotId": "mod_foregrip", slotId: "mod_foregrip",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "870a887c63ca30fb15736b3d", _id: "870a887c63ca30fb15736b3d",
"_tpl": "62a1b7fbc30cfa1d366af586", _tpl: "62a1b7fbc30cfa1d366af586",
"parentId": "bb49d6ceb3e87d8563a06455", parentId: "bb49d6ceb3e87d8563a06455",
"slotId": "main", slotId: "main",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
}, },
"location": { location: {
"x": 0, x: 0,
"y": 0, y: 0,
"r": "Horizontal", r: "Horizontal",
"isSearched": true isSearched: true,
} },
}, },
{ {
"_id": "f3de631a1bb2b74bd0160d9a", _id: "f3de631a1bb2b74bd0160d9a",
"_tpl": "5d6d3be5a4b9361bc73bc763", _tpl: "5d6d3be5a4b9361bc73bc763",
"parentId": "bb49d6ceb3e87d8563a06455", parentId: "bb49d6ceb3e87d8563a06455",
"slotId": "main", slotId: "main",
"location": { location: {
"x": 5, x: 5,
"y": 0, y: 0,
"r": "Vertical", r: "Vertical",
"isSearched": true isSearched: true,
}, },
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 22.41, Durability: 22.41,
"MaxDurability": 22.41 MaxDurability: 22.41,
} },
} },
}, },
{ {
"_id": "351180f3248d45c71cb2ebdc", _id: "351180f3248d45c71cb2ebdc",
"_tpl": "57c44b372459772d2b39b8ce", _tpl: "57c44b372459772d2b39b8ce",
"parentId": "870a887c63ca30fb15736b3d", parentId: "870a887c63ca30fb15736b3d",
"slotId": "main", slotId: "main",
"location": { location: {
"x": 0, x: 0,
"y": 0, y: 0,
"r": "Horizontal", r: "Horizontal",
"isSearched": true isSearched: true,
}, },
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 100, Durability: 100,
"MaxDurability": 100 MaxDurability: 100,
} },
} },
}, },
{ {
"_id": "7237f722106866f2df8dc8d1", _id: "7237f722106866f2df8dc8d1",
"_tpl": "56e33680d2720be2748b4576", _tpl: "56e33680d2720be2748b4576",
"parentId": "870a887c63ca30fb15736b3d", parentId: "870a887c63ca30fb15736b3d",
"slotId": "main", slotId: "main",
"location": { location: {
"x": 0, x: 0,
"y": 3, y: 3,
"r": "Horizontal", r: "Horizontal",
"isSearched": true isSearched: true,
}, },
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "d0cf00aff56ea520cdd94330", _id: "d0cf00aff56ea520cdd94330",
"_tpl": "57c44dd02459772d2e0ae249", _tpl: "57c44dd02459772d2e0ae249",
"parentId": "351180f3248d45c71cb2ebdc", parentId: "351180f3248d45c71cb2ebdc",
"slotId": "mod_muzzle", slotId: "mod_muzzle",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "5119653b2c66d57ee219e26f", _id: "5119653b2c66d57ee219e26f",
"_tpl": "57c44f4f2459772d2c627113", _tpl: "57c44f4f2459772d2c627113",
"parentId": "351180f3248d45c71cb2ebdc", parentId: "351180f3248d45c71cb2ebdc",
"slotId": "mod_reciever", slotId: "mod_reciever",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "ed1ac0183a8af587110aa74e", _id: "ed1ac0183a8af587110aa74e",
"_tpl": "5a9e81fba2750c00164f6b11", _tpl: "5a9e81fba2750c00164f6b11",
"parentId": "351180f3248d45c71cb2ebdc", parentId: "351180f3248d45c71cb2ebdc",
"slotId": "mod_magazine", slotId: "mod_magazine",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "310a7d1bb07ae0e522f3f8e3", _id: "310a7d1bb07ae0e522f3f8e3",
"_tpl": "5a69a2ed8dc32e000d46d1f1", _tpl: "5a69a2ed8dc32e000d46d1f1",
"parentId": "351180f3248d45c71cb2ebdc", parentId: "351180f3248d45c71cb2ebdc",
"slotId": "mod_pistol_grip", slotId: "mod_pistol_grip",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 100, Durability: 100,
"MaxDurability": 100 MaxDurability: 100,
} },
} },
}, },
{ {
"_id": "8a7e3489197b3b98126447fd", _id: "8a7e3489197b3b98126447fd",
"_tpl": "6130ca3fd92c473c77020dbd", _tpl: "6130ca3fd92c473c77020dbd",
"parentId": "351180f3248d45c71cb2ebdc", parentId: "351180f3248d45c71cb2ebdc",
"slotId": "mod_charge", slotId: "mod_charge",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 100, Durability: 100,
"MaxDurability": 100 MaxDurability: 100,
} },
} },
}, },
{ {
"_id": "e818616e11ae07aa05388759", _id: "e818616e11ae07aa05388759",
"_tpl": "5dff8db859400025ea5150d4", _tpl: "5dff8db859400025ea5150d4",
"parentId": "351180f3248d45c71cb2ebdc", parentId: "351180f3248d45c71cb2ebdc",
"slotId": "mod_mount_000", slotId: "mod_mount_000",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "768812984debf2756bece089", _id: "768812984debf2756bece089",
"_tpl": "57c44e7b2459772d28133248", _tpl: "57c44e7b2459772d28133248",
"parentId": "d0cf00aff56ea520cdd94330", parentId: "d0cf00aff56ea520cdd94330",
"slotId": "mod_sight_rear", slotId: "mod_sight_rear",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "67c610585ed668baf4604931", _id: "67c610585ed668baf4604931",
"_tpl": "59eb7ebe86f7740b373438ce", _tpl: "59eb7ebe86f7740b373438ce",
"parentId": "d0cf00aff56ea520cdd94330", parentId: "d0cf00aff56ea520cdd94330",
"slotId": "mod_mount_000", slotId: "mod_mount_000",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 100, Durability: 100,
"MaxDurability": 100 MaxDurability: 100,
} },
} },
}, },
{ {
"_id": "80e9dffa49bfe263ab0128c7", _id: "80e9dffa49bfe263ab0128c7",
"_tpl": "6267c6396b642f77f56f5c1c", _tpl: "6267c6396b642f77f56f5c1c",
"parentId": "67c610585ed668baf4604931", parentId: "67c610585ed668baf4604931",
"slotId": "mod_tactical_000", slotId: "mod_tactical_000",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "dee323443ce23ba8c54b9f1c", _id: "dee323443ce23ba8c54b9f1c",
"_tpl": "5cc9c20cd7f00c001336c65d", _tpl: "5cc9c20cd7f00c001336c65d",
"parentId": "67c610585ed668baf4604931", parentId: "67c610585ed668baf4604931",
"slotId": "mod_tactical_001", slotId: "mod_tactical_001",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "3008088022dd55f1c99e5a32", _id: "3008088022dd55f1c99e5a32",
"_tpl": "5c1cd46f2e22164bef5cfedb", _tpl: "5c1cd46f2e22164bef5cfedb",
"parentId": "67c610585ed668baf4604931", parentId: "67c610585ed668baf4604931",
"slotId": "mod_foregrip", slotId: "mod_foregrip",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 100, Durability: 100,
"MaxDurability": 100 MaxDurability: 100,
} },
} },
}, },
{ {
"_id": "71e9f8d005c72940d857fe64", _id: "71e9f8d005c72940d857fe64",
"_tpl": "59d790f486f77403cb06aec6", _tpl: "59d790f486f77403cb06aec6",
"parentId": "80e9dffa49bfe263ab0128c7", parentId: "80e9dffa49bfe263ab0128c7",
"slotId": "mod_flashlight", slotId: "mod_flashlight",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "8c610c6cc67115a5fc1662ff", _id: "8c610c6cc67115a5fc1662ff",
"_tpl": "56eabf3bd2720b75698b4569", _tpl: "56eabf3bd2720b75698b4569",
"parentId": "310a7d1bb07ae0e522f3f8e3", parentId: "310a7d1bb07ae0e522f3f8e3",
"slotId": "mod_stock_000", slotId: "mod_stock_000",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 100, Durability: 100,
"MaxDurability": 100 MaxDurability: 100,
} },
} },
}, },
{ {
"_id": "9bf01177f0c1e346b2d65373", _id: "9bf01177f0c1e346b2d65373",
"_tpl": "58d2912286f7744e27117493", _tpl: "58d2912286f7744e27117493",
"parentId": "8c610c6cc67115a5fc1662ff", parentId: "8c610c6cc67115a5fc1662ff",
"slotId": "mod_stock", slotId: "mod_stock",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 100, Durability: 100,
"MaxDurability": 100 MaxDurability: 100,
} },
} },
}, },
{ {
"_id": "7dd43ffa6e03c2da6cddc56e", _id: "7dd43ffa6e03c2da6cddc56e",
"_tpl": "6171407e50224f204c1da3c5", _tpl: "6171407e50224f204c1da3c5",
"parentId": "e818616e11ae07aa05388759", parentId: "e818616e11ae07aa05388759",
"slotId": "mod_scope", slotId: "mod_scope",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "fa9da4ccf3630cb173c293f9", _id: "fa9da4ccf3630cb173c293f9",
"_tpl": "5b3b99475acfc432ff4dcbee", _tpl: "5b3b99475acfc432ff4dcbee",
"parentId": "7dd43ffa6e03c2da6cddc56e", parentId: "7dd43ffa6e03c2da6cddc56e",
"slotId": "mod_scope_000", slotId: "mod_scope_000",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 100, Durability: 100,
"MaxDurability": 100 MaxDurability: 100,
} },
} },
}, },
{ {
"_id": "6e2727806fb12e12123e9a57", _id: "6e2727806fb12e12123e9a57",
"_tpl": "616554fe50224f204c1da2aa", _tpl: "616554fe50224f204c1da2aa",
"parentId": "7dd43ffa6e03c2da6cddc56e", parentId: "7dd43ffa6e03c2da6cddc56e",
"slotId": "mod_scope_001", slotId: "mod_scope_001",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 100, Durability: 100,
"MaxDurability": 100 MaxDurability: 100,
} },
} },
}, },
{ {
"_id": "2c868d4676adc934f897e9a7", _id: "2c868d4676adc934f897e9a7",
"_tpl": "61605d88ffa6e502ac5e7eeb", _tpl: "61605d88ffa6e502ac5e7eeb",
"parentId": "7dd43ffa6e03c2da6cddc56e", parentId: "7dd43ffa6e03c2da6cddc56e",
"slotId": "mod_scope_002", slotId: "mod_scope_002",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "1b159fdc14c350f8a4a7e19e", _id: "1b159fdc14c350f8a4a7e19e",
"_tpl": "58d39b0386f77443380bf13c", _tpl: "58d39b0386f77443380bf13c",
"parentId": "6e2727806fb12e12123e9a57", parentId: "6e2727806fb12e12123e9a57",
"slotId": "mod_scope", slotId: "mod_scope",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 100, Durability: 100,
"MaxDurability": 100 MaxDurability: 100,
} },
} },
}, },
{ {
"_id": "7691790ffc5290da292cab99", _id: "7691790ffc5290da292cab99",
"_tpl": "61657230d92c473c770213d7", _tpl: "61657230d92c473c770213d7",
"parentId": "1b159fdc14c350f8a4a7e19e", parentId: "1b159fdc14c350f8a4a7e19e",
"slotId": "mod_scope", slotId: "mod_scope",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 100, Durability: 100,
"MaxDurability": 100 MaxDurability: 100,
} },
} },
}, },
{ {
"_id": "012a11e7dcb1280a1ab9d2f6", _id: "012a11e7dcb1280a1ab9d2f6",
"_tpl": "618168b350224f204c1da4d8", _tpl: "618168b350224f204c1da4d8",
"parentId": "7237f722106866f2df8dc8d1", parentId: "7237f722106866f2df8dc8d1",
"slotId": "main", slotId: "main",
"location": { location: {
"x": 0, x: 0,
"y": 0, y: 0,
"r": "Horizontal", r: "Horizontal",
"isSearched": true isSearched: true,
}, },
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "38ca7415a458c4d22ba2f3c3", _id: "38ca7415a458c4d22ba2f3c3",
"_tpl": "6130c43c67085e45ef1405a1", _tpl: "6130c43c67085e45ef1405a1",
"parentId": "012a11e7dcb1280a1ab9d2f6", parentId: "012a11e7dcb1280a1ab9d2f6",
"slotId": "mod_muzzle", slotId: "mod_muzzle",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 100, Durability: 100,
"MaxDurability": 100 MaxDurability: 100,
} },
} },
}, },
{ {
"_id": "c5a0621ebf856ce1b0945efc", _id: "c5a0621ebf856ce1b0945efc",
"_tpl": "61816fcad92c473c770215cc", _tpl: "61816fcad92c473c770215cc",
"parentId": "012a11e7dcb1280a1ab9d2f6", parentId: "012a11e7dcb1280a1ab9d2f6",
"slotId": "mod_sight_front", slotId: "mod_sight_front",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 100, Durability: 100,
"MaxDurability": 100 MaxDurability: 100,
} },
} },
}, },
{ {
"_id": "a74677b17c1c49edc002df9b", _id: "a74677b17c1c49edc002df9b",
"_tpl": "5dfa3d2b0dee1b22f862eade", _tpl: "5dfa3d2b0dee1b22f862eade",
"parentId": "38ca7415a458c4d22ba2f3c3", parentId: "38ca7415a458c4d22ba2f3c3",
"slotId": "mod_muzzle", slotId: "mod_muzzle",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 100, Durability: 100,
"MaxDurability": 100 MaxDurability: 100,
} },
} },
} },
] ],
}, },
{ {
"scheduledTime": 1698945140, scheduledTime: 1698945140,
"traderId": "54cb57776803fa99248b456e", // Therapist traderId: "54cb57776803fa99248b456e", // Therapist
"messageContent": { messageContent: {
"templateId": "58fe0e3486f77471f772c3f2 2", templateId: "58fe0e3486f77471f772c3f2 2",
"type": 8, type: 8,
"maxStorageTime": 518400, maxStorageTime: 518400,
"text": "", text: "",
"profileChangeEvents": [], profileChangeEvents: [],
"systemData": { systemData: {
"date": "01.11.2023", date: "01.11.2023",
"time": "11:18", time: "11:18",
"location": "factory4_day" location: "factory4_day",
} },
}, },
"items": [ items: [
{ {
"_id": "5ae1c2b99a0a339adc620148", _id: "5ae1c2b99a0a339adc620148",
"_tpl": "5cebec38d7f00c00110a652a", _tpl: "5cebec38d7f00c00110a652a",
"parentId": "ad018df9da0cbf2726394ef1", parentId: "ad018df9da0cbf2726394ef1",
"slotId": "mod_mount_000", slotId: "mod_mount_000",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "30f4bcb87bcc4604e27c02c1", _id: "30f4bcb87bcc4604e27c02c1",
"_tpl": "5cc70146e4a949000d73bf6b", _tpl: "5cc70146e4a949000d73bf6b",
"parentId": "ad018df9da0cbf2726394ef1", parentId: "ad018df9da0cbf2726394ef1",
"slotId": "mod_mount_001", slotId: "mod_mount_001",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "ad018df9da0cbf2726394ef1", _id: "ad018df9da0cbf2726394ef1",
"_tpl": "5cc70102e4a949035e43ba74", _tpl: "5cc70102e4a949035e43ba74",
"parentId": "3bc4ff5bd99f165dc75cbd25", parentId: "3bc4ff5bd99f165dc75cbd25",
"slotId": "main", slotId: "main",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
}, },
"location": { location: {
"x": 3, x: 3,
"y": 0, y: 0,
"r": "Horizontal", r: "Horizontal",
"isSearched": true isSearched: true,
} },
}, },
{ {
"_id": "12c243bd6b3e486e61325f81", _id: "12c243bd6b3e486e61325f81",
"_tpl": "5cc82d76e24e8d00134b4b83", _tpl: "5cc82d76e24e8d00134b4b83",
"parentId": "5fe49444ae6628187a2e77b8", parentId: "5fe49444ae6628187a2e77b8",
"slotId": "hideout", slotId: "hideout",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 99.93771, Durability: 99.93771,
"MaxDurability": 100 MaxDurability: 100,
} },
} },
}, },
{ {
"_id": "760652d86ee78eed513e0ad7", _id: "760652d86ee78eed513e0ad7",
"_tpl": "5ab8f39486f7745cd93a1cca", _tpl: "5ab8f39486f7745cd93a1cca",
"parentId": "5fe49444ae6628187a2e77b8", parentId: "5fe49444ae6628187a2e77b8",
"slotId": "hideout", slotId: "hideout",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "61ab4afefac354dfc64c7874", _id: "61ab4afefac354dfc64c7874",
"_tpl": "5b432d215acfc4771e1c6624", _tpl: "5b432d215acfc4771e1c6624",
"parentId": "5fe49444ae6628187a2e77b8", parentId: "5fe49444ae6628187a2e77b8",
"slotId": "hideout", slotId: "hideout",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 30, Durability: 30,
"MaxDurability": 30 MaxDurability: 30,
} },
} },
}, },
{ {
"_id": "285e9d9ae196ae4e336cd04f", _id: "285e9d9ae196ae4e336cd04f",
"_tpl": "5d5d87f786f77427997cfaef", _tpl: "5d5d87f786f77427997cfaef",
"parentId": "5fe49444ae6628187a2e77b8", parentId: "5fe49444ae6628187a2e77b8",
"slotId": "hideout", slotId: "hideout",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 75, Durability: 75,
"MaxDurability": 80 MaxDurability: 80,
} },
} },
}, },
{ {
"_id": "3bc4ff5bd99f165dc75cbd25", _id: "3bc4ff5bd99f165dc75cbd25",
"_tpl": "5f5e467b0bc58666c37e7821", _tpl: "5f5e467b0bc58666c37e7821",
"parentId": "5fe49444ae6628187a2e77b8", parentId: "5fe49444ae6628187a2e77b8",
"slotId": "hideout", slotId: "hideout",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "6bf5d8ee81a3c9aec21bbbad", _id: "6bf5d8ee81a3c9aec21bbbad",
"_tpl": "5d5fca1ea4b93635fd598c07", _tpl: "5d5fca1ea4b93635fd598c07",
"parentId": "5fe49444ae6628187a2e77b8", parentId: "5fe49444ae6628187a2e77b8",
"slotId": "hideout", slotId: "hideout",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "2371438cf809b5e483bf5d85", _id: "2371438cf809b5e483bf5d85",
"_tpl": "5cc70093e4a949033c734312", _tpl: "5cc70093e4a949033c734312",
"parentId": "12c243bd6b3e486e61325f81", parentId: "12c243bd6b3e486e61325f81",
"slotId": "mod_magazine", slotId: "mod_magazine",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "7f890346ea5b2cbc68c3170f", _id: "7f890346ea5b2cbc68c3170f",
"_tpl": "5cc700b9e4a949000f0f0f25", _tpl: "5cc700b9e4a949000f0f0f25",
"parentId": "12c243bd6b3e486e61325f81", parentId: "12c243bd6b3e486e61325f81",
"slotId": "mod_stock", slotId: "mod_stock",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "12fb79a9c4929009ff8d89e1", _id: "12fb79a9c4929009ff8d89e1",
"_tpl": "5cc700ede4a949033c734315", _tpl: "5cc700ede4a949033c734315",
"parentId": "12c243bd6b3e486e61325f81", parentId: "12c243bd6b3e486e61325f81",
"slotId": "mod_reciever", slotId: "mod_reciever",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "d4c5274082ed716e19447f46", _id: "d4c5274082ed716e19447f46",
"_tpl": "5cc701d7e4a94900100ac4e7", _tpl: "5cc701d7e4a94900100ac4e7",
"parentId": "12c243bd6b3e486e61325f81", parentId: "12c243bd6b3e486e61325f81",
"slotId": "mod_barrel", slotId: "mod_barrel",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "d819dd4d2b13de10e9d6d805", _id: "d819dd4d2b13de10e9d6d805",
"_tpl": "5cc6ea85e4a949000e1ea3c3", _tpl: "5cc6ea85e4a949000e1ea3c3",
"parentId": "12c243bd6b3e486e61325f81", parentId: "12c243bd6b3e486e61325f81",
"slotId": "mod_charge", slotId: "mod_charge",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "fc9a664cacc477c4e725a81a", _id: "fc9a664cacc477c4e725a81a",
"_tpl": "5cc700d4e4a949000f0f0f28", _tpl: "5cc700d4e4a949000f0f0f28",
"parentId": "7f890346ea5b2cbc68c3170f", parentId: "7f890346ea5b2cbc68c3170f",
"slotId": "mod_stock_000", slotId: "mod_stock_000",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "372891c593cf14e176b93ce2", _id: "372891c593cf14e176b93ce2",
"_tpl": "5cc7012ae4a949001252b43e", _tpl: "5cc7012ae4a949001252b43e",
"parentId": "12fb79a9c4929009ff8d89e1", parentId: "12fb79a9c4929009ff8d89e1",
"slotId": "mod_mount_000", slotId: "mod_mount_000",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "bd196435a57bdc433df1e49d", _id: "bd196435a57bdc433df1e49d",
"_tpl": "5cc7012ae4a949001252b43e", _tpl: "5cc7012ae4a949001252b43e",
"parentId": "12fb79a9c4929009ff8d89e1", parentId: "12fb79a9c4929009ff8d89e1",
"slotId": "mod_mount_001", slotId: "mod_mount_001",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "ea3349d29797354d835c2192", _id: "ea3349d29797354d835c2192",
"_tpl": "58491f3324597764bc48fa02", _tpl: "58491f3324597764bc48fa02",
"parentId": "12fb79a9c4929009ff8d89e1", parentId: "12fb79a9c4929009ff8d89e1",
"slotId": "mod_scope", slotId: "mod_scope",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 100, Durability: 100,
"MaxDurability": 100 MaxDurability: 100,
} },
} },
}, },
{ {
"_id": "4ccf7c74ca7d2167deb0ae5c", _id: "4ccf7c74ca7d2167deb0ae5c",
"_tpl": "626becf9582c3e319310b837", _tpl: "626becf9582c3e319310b837",
"parentId": "372891c593cf14e176b93ce2", parentId: "372891c593cf14e176b93ce2",
"slotId": "mod_tactical", slotId: "mod_tactical",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "adfd3640fc93daf21c721ca6", _id: "adfd3640fc93daf21c721ca6",
"_tpl": "5cc9c20cd7f00c001336c65d", _tpl: "5cc9c20cd7f00c001336c65d",
"parentId": "bd196435a57bdc433df1e49d", parentId: "bd196435a57bdc433df1e49d",
"slotId": "mod_tactical", slotId: "mod_tactical",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "deeb36b1812790b0145d2532", _id: "deeb36b1812790b0145d2532",
"_tpl": "5a16badafcdbcb001865f72d", _tpl: "5a16badafcdbcb001865f72d",
"parentId": "61ab4afefac354dfc64c7874", parentId: "61ab4afefac354dfc64c7874",
"slotId": "mod_equipment_000", slotId: "mod_equipment_000",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 12, Durability: 12,
"MaxDurability": 25 MaxDurability: 25,
} },
} },
}, },
{ {
"_id": "4c0e0548df904c384569190c", _id: "4c0e0548df904c384569190c",
"_tpl": "5ea058e01dbce517f324b3e2", _tpl: "5ea058e01dbce517f324b3e2",
"parentId": "61ab4afefac354dfc64c7874", parentId: "61ab4afefac354dfc64c7874",
"slotId": "mod_nvg", slotId: "mod_nvg",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 3, Durability: 3,
"MaxDurability": 39 MaxDurability: 39,
} },
} },
}, },
{ {
"_id": "da82c293cabc705b30fef93a", _id: "da82c293cabc705b30fef93a",
"_tpl": "5a398ab9c4a282000c5a9842", _tpl: "5a398ab9c4a282000c5a9842",
"parentId": "61ab4afefac354dfc64c7874", parentId: "61ab4afefac354dfc64c7874",
"slotId": "mod_mount", slotId: "mod_mount",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 100, Durability: 100,
"MaxDurability": 100 MaxDurability: 100,
} },
} },
}, },
{ {
"_id": "b8fc94611def6e9ba534a8b3", _id: "b8fc94611def6e9ba534a8b3",
"_tpl": "5a16b8a9fcdbcb00165aa6ca", _tpl: "5a16b8a9fcdbcb00165aa6ca",
"parentId": "4c0e0548df904c384569190c", parentId: "4c0e0548df904c384569190c",
"slotId": "mod_nvg", slotId: "mod_nvg",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 100, Durability: 100,
"MaxDurability": 100 MaxDurability: 100,
} },
} },
}, },
{ {
"_id": "20d6193c1f399e6326ebbc10", _id: "20d6193c1f399e6326ebbc10",
"_tpl": "5a16b93dfcdbcbcae6687261", _tpl: "5a16b93dfcdbcbcae6687261",
"parentId": "b8fc94611def6e9ba534a8b3", parentId: "b8fc94611def6e9ba534a8b3",
"slotId": "mod_nvg", slotId: "mod_nvg",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 100, Durability: 100,
"MaxDurability": 100 MaxDurability: 100,
} },
} },
}, },
{ {
"_id": "065c4f13b2bd8be266e1e809", _id: "065c4f13b2bd8be266e1e809",
"_tpl": "57235b6f24597759bf5a30f1", _tpl: "57235b6f24597759bf5a30f1",
"parentId": "20d6193c1f399e6326ebbc10", parentId: "20d6193c1f399e6326ebbc10",
"slotId": "mod_nvg", slotId: "mod_nvg",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 100, Durability: 100,
"MaxDurability": 100 MaxDurability: 100,
}, },
"Togglable": { Togglable: {
"On": true On: true,
} },
} },
}, },
{ {
"_id": "1883b955ab202fa099809278", _id: "1883b955ab202fa099809278",
"_tpl": "57d17c5e2459775a5c57d17d", _tpl: "57d17c5e2459775a5c57d17d",
"parentId": "da82c293cabc705b30fef93a", parentId: "da82c293cabc705b30fef93a",
"slotId": "mod_flashlight", slotId: "mod_flashlight",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "e3c9e50ce31900c950b4ff6f", _id: "e3c9e50ce31900c950b4ff6f",
"_tpl": "5cc70093e4a949033c734312", _tpl: "5cc70093e4a949033c734312",
"parentId": "285e9d9ae196ae4e336cd04f", parentId: "285e9d9ae196ae4e336cd04f",
"slotId": "1", slotId: "1",
"location": { location: {
"x": 0, x: 0,
"y": 0, y: 0,
"r": "Vertical", r: "Vertical",
"isSearched": true isSearched: true,
}, },
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "193259b5eb848af4d036bee5", _id: "193259b5eb848af4d036bee5",
"_tpl": "5cc70093e4a949033c734312", _tpl: "5cc70093e4a949033c734312",
"parentId": "285e9d9ae196ae4e336cd04f", parentId: "285e9d9ae196ae4e336cd04f",
"slotId": "2", slotId: "2",
"location": { location: {
"x": 0, x: 0,
"y": 0, y: 0,
"r": "Vertical", r: "Vertical",
"isSearched": true isSearched: true,
}, },
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "f97ce69443f63bbe8f8097a7", _id: "f97ce69443f63bbe8f8097a7",
"_tpl": "5cc70093e4a949033c734312", _tpl: "5cc70093e4a949033c734312",
"parentId": "285e9d9ae196ae4e336cd04f", parentId: "285e9d9ae196ae4e336cd04f",
"slotId": "3", slotId: "3",
"location": { location: {
"x": 0, x: 0,
"y": 0, y: 0,
"r": "Vertical", r: "Vertical",
"isSearched": true isSearched: true,
}, },
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "5d1c154a8abcfa934e477ac4", _id: "5d1c154a8abcfa934e477ac4",
"_tpl": "5cc70093e4a949033c734312", _tpl: "5cc70093e4a949033c734312",
"parentId": "285e9d9ae196ae4e336cd04f", parentId: "285e9d9ae196ae4e336cd04f",
"slotId": "4", slotId: "4",
"location": { location: {
"x": 0, x: 0,
"y": 0, y: 0,
"r": "Vertical", r: "Vertical",
"isSearched": true isSearched: true,
}, },
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "289f7af841690c5388095477", _id: "289f7af841690c5388095477",
"_tpl": "5cc70093e4a949033c734312", _tpl: "5cc70093e4a949033c734312",
"parentId": "285e9d9ae196ae4e336cd04f", parentId: "285e9d9ae196ae4e336cd04f",
"slotId": "5", slotId: "5",
"location": { location: {
"x": 0, x: 0,
"y": 0, y: 0,
"r": "Vertical", r: "Vertical",
"isSearched": true isSearched: true,
}, },
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "3e6d578165b61aef9865f677", _id: "3e6d578165b61aef9865f677",
"_tpl": "5cc70093e4a949033c734312", _tpl: "5cc70093e4a949033c734312",
"parentId": "285e9d9ae196ae4e336cd04f", parentId: "285e9d9ae196ae4e336cd04f",
"slotId": "6", slotId: "6",
"location": { location: {
"x": 0, x: 0,
"y": 0, y: 0,
"r": "Vertical", r: "Vertical",
"isSearched": true isSearched: true,
}, },
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "338682523f8504f97f84f3ab", _id: "338682523f8504f97f84f3ab",
"_tpl": "5cc70093e4a949033c734312", _tpl: "5cc70093e4a949033c734312",
"parentId": "285e9d9ae196ae4e336cd04f", parentId: "285e9d9ae196ae4e336cd04f",
"slotId": "7", slotId: "7",
"location": { location: {
"x": 0, x: 0,
"y": 0, y: 0,
"r": "Vertical", r: "Vertical",
"isSearched": true isSearched: true,
}, },
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "6d18ac01aa04b16e4f0d5d2f", _id: "6d18ac01aa04b16e4f0d5d2f",
"_tpl": "5cc70093e4a949033c734312", _tpl: "5cc70093e4a949033c734312",
"parentId": "285e9d9ae196ae4e336cd04f", parentId: "285e9d9ae196ae4e336cd04f",
"slotId": "8", slotId: "8",
"location": { location: {
"x": 0, x: 0,
"y": 0, y: 0,
"r": "Vertical", r: "Vertical",
"isSearched": true isSearched: true,
}, },
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "ac4ed54d61daa0c5219f8522", _id: "ac4ed54d61daa0c5219f8522",
"_tpl": "5cc70093e4a949033c734312", _tpl: "5cc70093e4a949033c734312",
"parentId": "285e9d9ae196ae4e336cd04f", parentId: "285e9d9ae196ae4e336cd04f",
"slotId": "9", slotId: "9",
"location": { location: {
"x": 0, x: 0,
"y": 0, y: 0,
"r": "Vertical", r: "Vertical",
"isSearched": true isSearched: true,
}, },
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "2460460ef3d3df5c1ce07edb", _id: "2460460ef3d3df5c1ce07edb",
"_tpl": "5cc70093e4a949033c734312", _tpl: "5cc70093e4a949033c734312",
"parentId": "285e9d9ae196ae4e336cd04f", parentId: "285e9d9ae196ae4e336cd04f",
"slotId": "10", slotId: "10",
"location": { location: {
"x": 0, x: 0,
"y": 0, y: 0,
"r": "Vertical", r: "Vertical",
"isSearched": true isSearched: true,
}, },
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "3aeb18aac0b532f34255f162", _id: "3aeb18aac0b532f34255f162",
"_tpl": "5cc70146e4a949000d73bf6b", _tpl: "5cc70146e4a949000d73bf6b",
"parentId": "285e9d9ae196ae4e336cd04f", parentId: "285e9d9ae196ae4e336cd04f",
"slotId": "11", slotId: "11",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
}, },
"location": { location: {
"x": 0, x: 0,
"y": 0, y: 0,
"r": "Horizontal", r: "Horizontal",
"isSearched": true isSearched: true,
} },
}, },
{ {
"_id": "bdb46107abbf1d92edaaf14e", _id: "bdb46107abbf1d92edaaf14e",
"_tpl": "6272379924e29f06af4d5ecb", _tpl: "6272379924e29f06af4d5ecb",
"parentId": "3aeb18aac0b532f34255f162", parentId: "3aeb18aac0b532f34255f162",
"slotId": "mod_tactical", slotId: "mod_tactical",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "0caadd8507a36d9ea871e88e", _id: "0caadd8507a36d9ea871e88e",
"_tpl": "5ab8f04f86f774585f4237d8", _tpl: "5ab8f04f86f774585f4237d8",
"parentId": "3bc4ff5bd99f165dc75cbd25", parentId: "3bc4ff5bd99f165dc75cbd25",
"slotId": "main", slotId: "main",
"location": { location: {
"x": 0, x: 0,
"y": 0, y: 0,
"r": "Horizontal", r: "Horizontal",
"isSearched": true isSearched: true,
}, },
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "240046eebc9040c1d7e58611", _id: "240046eebc9040c1d7e58611",
"_tpl": "5ac66d015acfc400180ae6e4", _tpl: "5ac66d015acfc400180ae6e4",
"parentId": "0caadd8507a36d9ea871e88e", parentId: "0caadd8507a36d9ea871e88e",
"slotId": "main", slotId: "main",
"location": { location: {
"x": 0, x: 0,
"y": 0, y: 0,
"r": "Horizontal", r: "Horizontal",
"isSearched": true isSearched: true,
}, },
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"sptPresetId": "5acf7dfc86f774401e19c390", sptPresetId: "5acf7dfc86f774401e19c390",
"Repairable": { Repairable: {
"Durability": 32, Durability: 32,
"MaxDurability": 59 MaxDurability: 59,
}, },
"Foldable": { Foldable: {
"Folded": true Folded: true,
} },
} },
}, },
{ {
"_id": "70b23c628fa17699d9a71e94", _id: "70b23c628fa17699d9a71e94",
"_tpl": "59c6633186f7740cf0493bb9", _tpl: "59c6633186f7740cf0493bb9",
"parentId": "240046eebc9040c1d7e58611", parentId: "240046eebc9040c1d7e58611",
"slotId": "mod_gas_block", slotId: "mod_gas_block",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"sptPresetId": "5acf7dfc86f774401e19c390", sptPresetId: "5acf7dfc86f774401e19c390",
"Repairable": { Repairable: {
"Durability": 32, Durability: 32,
"MaxDurability": 59 MaxDurability: 59,
} },
} },
}, },
{ {
"_id": "7cc2e24dc6bc0716bdddc472", _id: "7cc2e24dc6bc0716bdddc472",
"_tpl": "5943ee5a86f77413872d25ec", _tpl: "5943ee5a86f77413872d25ec",
"parentId": "240046eebc9040c1d7e58611", parentId: "240046eebc9040c1d7e58611",
"slotId": "mod_muzzle", slotId: "mod_muzzle",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 100, Durability: 100,
"MaxDurability": 100 MaxDurability: 100,
} },
} },
}, },
{ {
"_id": "7a51ebbad703082660d59d27", _id: "7a51ebbad703082660d59d27",
"_tpl": "5649ade84bdc2d1b2b8b4587", _tpl: "5649ade84bdc2d1b2b8b4587",
"parentId": "240046eebc9040c1d7e58611", parentId: "240046eebc9040c1d7e58611",
"slotId": "mod_pistol_grip", slotId: "mod_pistol_grip",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"sptPresetId": "5acf7dfc86f774401e19c390", sptPresetId: "5acf7dfc86f774401e19c390",
"Repairable": { Repairable: {
"Durability": 32, Durability: 32,
"MaxDurability": 59 MaxDurability: 59,
} },
} },
}, },
{ {
"_id": "b481bc57436ed9a0c3abe7f3", _id: "b481bc57436ed9a0c3abe7f3",
"_tpl": "5d2c76ed48f03532f2136169", _tpl: "5d2c76ed48f03532f2136169",
"parentId": "240046eebc9040c1d7e58611", parentId: "240046eebc9040c1d7e58611",
"slotId": "mod_reciever", slotId: "mod_reciever",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "5774ef80597c7f91bff40dbb", _id: "5774ef80597c7f91bff40dbb",
"_tpl": "5ac50c185acfc400163398d4", _tpl: "5ac50c185acfc400163398d4",
"parentId": "240046eebc9040c1d7e58611", parentId: "240046eebc9040c1d7e58611",
"slotId": "mod_stock", slotId: "mod_stock",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"sptPresetId": "5acf7dfc86f774401e19c390", sptPresetId: "5acf7dfc86f774401e19c390",
"Repairable": { Repairable: {
"Durability": 32, Durability: 32,
"MaxDurability": 59 MaxDurability: 59,
} },
} },
}, },
{ {
"_id": "8b7c8e6ba172ac390c99a2ae", _id: "8b7c8e6ba172ac390c99a2ae",
"_tpl": "5ac66c5d5acfc4001718d314", _tpl: "5ac66c5d5acfc4001718d314",
"parentId": "240046eebc9040c1d7e58611", parentId: "240046eebc9040c1d7e58611",
"slotId": "mod_magazine", slotId: "mod_magazine",
"upd": { upd: {
"StackObjectsCount": 1 StackObjectsCount: 1,
} },
}, },
{ {
"_id": "1ed3a416b1fc7adbed1160df", _id: "1ed3a416b1fc7adbed1160df",
"_tpl": "6130ca3fd92c473c77020dbd", _tpl: "6130ca3fd92c473c77020dbd",
"parentId": "240046eebc9040c1d7e58611", parentId: "240046eebc9040c1d7e58611",
"slotId": "mod_charge", slotId: "mod_charge",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 100, Durability: 100,
"MaxDurability": 100 MaxDurability: 100,
} },
} },
}, },
{ {
"_id": "bbe087661947c0d9c1cde146", _id: "bbe087661947c0d9c1cde146",
"_tpl": "5648b1504bdc2d9d488b4584", _tpl: "5648b1504bdc2d9d488b4584",
"parentId": "70b23c628fa17699d9a71e94", parentId: "70b23c628fa17699d9a71e94",
"slotId": "mod_handguard", slotId: "mod_handguard",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"sptPresetId": "5acf7dfc86f774401e19c390", sptPresetId: "5acf7dfc86f774401e19c390",
"Repairable": { Repairable: {
"Durability": 32, Durability: 32,
"MaxDurability": 59 MaxDurability: 59,
} },
} },
}, },
{ {
"_id": "724388f8110434efccd79b3a", _id: "724388f8110434efccd79b3a",
"_tpl": "544a3a774bdc2d3a388b4567", _tpl: "544a3a774bdc2d3a388b4567",
"parentId": "b481bc57436ed9a0c3abe7f3", parentId: "b481bc57436ed9a0c3abe7f3",
"slotId": "mod_scope", slotId: "mod_scope",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 100, Durability: 100,
"MaxDurability": 100 MaxDurability: 100,
} },
} },
}, },
{ {
"_id": "8581038b0f795618a3d26c94", _id: "8581038b0f795618a3d26c94",
"_tpl": "58d268fc86f774111273f8c2", _tpl: "58d268fc86f774111273f8c2",
"parentId": "724388f8110434efccd79b3a", parentId: "724388f8110434efccd79b3a",
"slotId": "mod_scope", slotId: "mod_scope",
"upd": { upd: {
"StackObjectsCount": 1, StackObjectsCount: 1,
"Repairable": { Repairable: {
"Durability": 100, Durability: 100,
"MaxDurability": 100 MaxDurability: 100,
} },
} },
} },
] ],
} },
]; ];

View File

@ -11,7 +11,11 @@ export class WinstonLogger implements ILogger
log(data: string | Record<string, unknown> | Error, color: string, backgroundColor?: string): void log(data: string | Record<string, unknown> | Error, color: string, backgroundColor?: string): void
{} {}
logWithColor(data: string | Record<string, unknown>, textColor: LogTextColor, backgroundColor?: LogBackgroundColor): void logWithColor(
data: string | Record<string, unknown>,
textColor: LogTextColor,
backgroundColor?: LogBackgroundColor,
): void
{} {}
error(data: string): void error(data: string): void

View File

@ -1,16 +1,16 @@
/* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable @typescript-eslint/naming-convention */
import "reflect-metadata"; import "reflect-metadata";
import { container } from "tsyringe"; import { container } from "tsyringe";
import { vi, afterEach, describe, expect, it, beforeEach } from "vitest"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { InsuranceController } from "@spt-aki/controllers/InsuranceController"; import { InsuranceController } from "@spt-aki/controllers/InsuranceController";
import { ProfileInsuranceFactory } from "@tests/__factories__/ProfileInsurance.factory"; import { ProfileInsuranceFactory } from "@tests/__factories__/ProfileInsurance.factory";
import { MessageType } from "@spt-aki/models/enums/MessageType"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper";
import { TraderHelper } from "@spt-aki/helpers/TraderHelper"; import { TraderHelper } from "@spt-aki/helpers/TraderHelper";
import { Item } from "@spt-aki/models/eft/common/tables/IItem"; import { Item } from "@spt-aki/models/eft/common/tables/IItem";
import { Insurance } from "@spt-aki/models/eft/profile/IAkiProfile"; import { Insurance } from "@spt-aki/models/eft/profile/IAkiProfile";
import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { MessageType } from "@spt-aki/models/enums/MessageType";
describe("InsuranceController", () => describe("InsuranceController", () =>
{ {
@ -36,10 +36,12 @@ describe("InsuranceController", () =>
const session2 = "session2"; const session2 = "session2";
const profiles = { const profiles = {
[session1]: {}, [session1]: {},
[session2]: {} [session2]: {},
}; };
const getProfilesSpy = vi.spyOn(insuranceController.saveServer, "getProfiles").mockReturnValue(profiles); const getProfilesSpy = vi.spyOn(insuranceController.saveServer, "getProfiles").mockReturnValue(profiles);
const processReturnByProfileSpy = vi.spyOn(insuranceController, "processReturnByProfile").mockReturnValue(vi.fn()); const processReturnByProfileSpy = vi.spyOn(insuranceController, "processReturnByProfile").mockReturnValue(
vi.fn(),
);
// Execute the method. // Execute the method.
insuranceController.processReturn(); insuranceController.processReturn();
@ -55,7 +57,8 @@ describe("InsuranceController", () =>
it("should not attempt to process profiles if no profiles exist", () => it("should not attempt to process profiles if no profiles exist", () =>
{ {
const processReturnByProfileSpy = vi.spyOn(insuranceController, "processReturnByProfile").mockImplementation(vi.fn()); const processReturnByProfileSpy = vi.spyOn(insuranceController, "processReturnByProfile")
.mockImplementation(vi.fn());
// Execute the method. // Execute the method.
insuranceController.processReturn(); insuranceController.processReturn();
@ -119,7 +122,9 @@ describe("InsuranceController", () =>
// Verify that the correct methods were called. // Verify that the correct methods were called.
expect(mockGetProfile).toBeCalledTimes(1); expect(mockGetProfile).toBeCalledTimes(1);
expect(mockLoggerDebug).toBeCalledWith(`Found ${insuranceFixture.length} insurance packages in profile ${sessionID}`); expect(mockLoggerDebug).toBeCalledWith(
`Found ${insuranceFixture.length} insurance packages in profile ${sessionID}`,
);
expect(insuredFiltered.length).toBe(insuranceFixture.length); expect(insuredFiltered.length).toBe(insuranceFixture.length);
}); });
@ -141,7 +146,9 @@ describe("InsuranceController", () =>
// Verify that the correct methods were called. // Verify that the correct methods were called.
expect(mockGetProfile).toBeCalledTimes(1); expect(mockGetProfile).toBeCalledTimes(1);
expect(mockLoggerDebug).toBeCalledWith(`Found ${insuranceFixture.length} insurance packages in profile ${sessionID}`); expect(mockLoggerDebug).toBeCalledWith(
`Found ${insuranceFixture.length} insurance packages in profile ${sessionID}`,
);
expect(insuredFiltered.length).toBe(insuranceFixture.length - 1); // Should be 1 less than the original fixture. expect(insuredFiltered.length).toBe(insuranceFixture.length - 1); // Should be 1 less than the original fixture.
}); });
@ -157,11 +164,16 @@ describe("InsuranceController", () =>
// Execute the method, passing in a time that's two hours in the past. The function should use this past // Execute the method, passing in a time that's two hours in the past. The function should use this past
// date as the target to judge if an insurance package is ready to be sent or not. // date as the target to judge if an insurance package is ready to be sent or not.
const insuredFiltered = insuranceController.filterInsuredItems(sessionID, Math.floor((Date.now() / 1000) - (2 * 60 * 60))); const insuredFiltered = insuranceController.filterInsuredItems(
sessionID,
Math.floor((Date.now() / 1000) - (2 * 60 * 60)),
);
// Verify that the correct methods were called. // Verify that the correct methods were called.
expect(mockGetProfile).toBeCalledTimes(1); expect(mockGetProfile).toBeCalledTimes(1);
expect(mockLoggerDebug).toBeCalledWith(`Found ${insuranceFixture.length} insurance packages in profile ${sessionID}`); expect(mockLoggerDebug).toBeCalledWith(
`Found ${insuranceFixture.length} insurance packages in profile ${sessionID}`,
);
// Verify that the returned array is empty. // Verify that the returned array is empty.
expect(insuredFiltered.length).toBe(0); expect(insuredFiltered.length).toBe(0);
@ -186,7 +198,11 @@ describe("InsuranceController", () =>
insuranceController.processInsuredItems(insuranceFixture, sessionId); insuranceController.processInsuredItems(insuranceFixture, sessionId);
// Verify that the log was written. // Verify that the log was written.
expect(mockLoggerDebug).toBeCalledWith(`Processing ${insuranceFixture.length} insurance packages, which includes a total of ${insuranceController.countAllInsuranceItems(insuranceFixture)} items, in profile ${sessionId}`); expect(mockLoggerDebug).toBeCalledWith(
`Processing ${insuranceFixture.length} insurance packages, which includes a total of ${
insuranceController.countAllInsuranceItems(insuranceFixture)
} items, in profile ${sessionId}`,
);
}); });
it("should call processing methods once per insurance package", () => it("should call processing methods once per insurance package", () =>
@ -195,11 +211,19 @@ describe("InsuranceController", () =>
const packageCount = insuranceFixture.length; const packageCount = insuranceFixture.length;
// Spy on the processing methods. // Spy on the processing methods.
const mockFindItemsToDelete = vi.spyOn(insuranceController, "findItemsToDelete").mockImplementation(vi.fn()); const mockFindItemsToDelete = vi.spyOn(insuranceController, "findItemsToDelete").mockImplementation(
const mockRemoveItemsFromInsurance = vi.spyOn(insuranceController, "removeItemsFromInsurance").mockImplementation(vi.fn()); vi.fn(),
const mockAdoptOrphanedItems = vi.spyOn(insuranceController, "adoptOrphanedItems").mockImplementation(vi.fn()); );
const mockRemoveItemsFromInsurance = vi.spyOn(insuranceController, "removeItemsFromInsurance")
.mockImplementation(vi.fn());
const mockAdoptOrphanedItems = vi.spyOn(insuranceController, "adoptOrphanedItems").mockImplementation(
vi.fn(),
);
const mockSendMail = vi.spyOn(insuranceController, "sendMail").mockImplementation(vi.fn()); const mockSendMail = vi.spyOn(insuranceController, "sendMail").mockImplementation(vi.fn());
const mockRemoveInsurancePackageFromProfile = vi.spyOn(insuranceController, "removeInsurancePackageFromProfile").mockImplementation(vi.fn()); const mockRemoveInsurancePackageFromProfile = vi.spyOn(
insuranceController,
"removeInsurancePackageFromProfile",
).mockImplementation(vi.fn());
// Execute the method. // Execute the method.
insuranceController.processInsuredItems(insuranceFixture, sessionId); insuranceController.processInsuredItems(insuranceFixture, sessionId);
@ -219,22 +243,22 @@ describe("InsuranceController", () =>
{ {
const insurance = [ const insurance = [
{ {
"_id": "1", _id: "1",
"upd": 1234567890, upd: 1234567890,
"items": [ items: [
{ "_id": "1", "parentId": "1", "slotId": "1" }, {_id: "1", parentId: "1", slotId: "1"},
{ "_id": "2", "parentId": "1", "slotId": "2" } {_id: "2", parentId: "1", slotId: "2"},
] ],
}, },
{ {
"_id": "2", _id: "2",
"upd": 1234567890, upd: 1234567890,
"items": [ items: [
{ "_id": "3", "parentId": "2", "slotId": "1" }, {_id: "3", parentId: "2", slotId: "1"},
{ "_id": "4", "parentId": "2", "slotId": "2" }, {_id: "4", parentId: "2", slotId: "2"},
{ "_id": "5", "parentId": "2", "slotId": "3" } {_id: "5", parentId: "2", slotId: "3"},
] ],
} },
]; ];
const expectedCount = 5; // 2 items in the first package + 3 items in the second package. const expectedCount = 5; // 2 items in the first package + 3 items in the second package.
@ -261,15 +285,15 @@ describe("InsuranceController", () =>
{ {
const insurance = [ const insurance = [
{ {
"_id": "1", _id: "1",
"upd": 1234567890, upd: 1234567890,
"items": [] items: [],
}, },
{ {
"_id": "2", _id: "2",
"upd": 1234567890, upd: 1234567890,
"items": [] items: [],
} },
]; ];
const expectedCount = 0; const expectedCount = 0;
@ -289,7 +313,7 @@ describe("InsuranceController", () =>
const packageToRemove = { const packageToRemove = {
date: "01.11.2023", date: "01.11.2023",
time: "10:51", time: "10:51",
location: "factory4_day" location: "factory4_day",
}; };
const profile = { const profile = {
insurance: [ insurance: [
@ -298,20 +322,20 @@ describe("InsuranceController", () =>
systemData: { systemData: {
date: "01.11.2023", date: "01.11.2023",
time: "11:18", time: "11:18",
location: "factory4_day" location: "factory4_day",
} },
} },
}, },
{ // This one should be removed { // This one should be removed
messageContent: { messageContent: {
systemData: { systemData: {
date: "01.11.2023", date: "01.11.2023",
time: "10:51", time: "10:51",
location: "factory4_day" location: "factory4_day",
} },
} },
} },
] ],
}; };
// Mock the getProfile method to return the above profile. // Mock the getProfile method to return the above profile.
@ -325,7 +349,7 @@ describe("InsuranceController", () =>
expect(profile.insurance[0].messageContent.systemData).toStrictEqual({ expect(profile.insurance[0].messageContent.systemData).toStrictEqual({
date: "01.11.2023", date: "01.11.2023",
time: "11:18", time: "11:18",
location: "factory4_day" location: "factory4_day",
}); });
}); });
@ -335,7 +359,7 @@ describe("InsuranceController", () =>
const packageToRemove = { const packageToRemove = {
date: "01.11.2023", date: "01.11.2023",
time: "10:51", time: "10:51",
location: "factory4_day" location: "factory4_day",
}; };
const profile = { const profile = {
insurance: [ insurance: [
@ -344,11 +368,11 @@ describe("InsuranceController", () =>
systemData: { systemData: {
date: "01.11.2023", date: "01.11.2023",
time: "10:51", time: "10:51",
location: "factory4_day" location: "factory4_day",
} },
} },
} },
] ],
}; };
// Mock the getProfile method to return the above profile. // Mock the getProfile method to return the above profile.
@ -361,7 +385,9 @@ describe("InsuranceController", () =>
insuranceController.removeInsurancePackageFromProfile(sessionID, packageToRemove); insuranceController.removeInsurancePackageFromProfile(sessionID, packageToRemove);
// Verify that the log was written. // Verify that the log was written.
expect(mockLoggerDebug).toBeCalledWith(`Removed insurance package with date: ${packageToRemove.date}, time: ${packageToRemove.time}, and location: ${packageToRemove.location} from profile ${sessionID}. Remaining packages: ${profile.insurance.length}`); expect(mockLoggerDebug).toBeCalledWith(
`Removed insurance package with date: ${packageToRemove.date}, time: ${packageToRemove.time}, and location: ${packageToRemove.location} from profile ${sessionID}. Remaining packages: ${profile.insurance.length}`,
);
}); });
it("should not remove any packages if the specified package is not found", () => it("should not remove any packages if the specified package is not found", () =>
@ -370,7 +396,7 @@ describe("InsuranceController", () =>
const packageToRemove = { const packageToRemove = {
date: "01.11.2023", date: "01.11.2023",
time: "10:51", time: "10:51",
location: "factory4_day" location: "factory4_day",
}; };
const profile = { const profile = {
insurance: [ insurance: [
@ -379,11 +405,11 @@ describe("InsuranceController", () =>
systemData: { systemData: {
date: "02.11.2023", date: "02.11.2023",
time: "10:50", time: "10:50",
location: "factory4_night" location: "factory4_night",
} },
} },
} },
] ],
}; };
// Mock the getProfile method to return the above profile. // Mock the getProfile method to return the above profile.
@ -399,7 +425,6 @@ describe("InsuranceController", () =>
describe("findItemsToDelete", () => describe("findItemsToDelete", () =>
{ {
it("should handle an empty insurance package", () => it("should handle an empty insurance package", () =>
{ {
const insurancePackage = insuranceFixture[0]; const insurancePackage = insuranceFixture[0];
@ -423,12 +448,14 @@ describe("InsuranceController", () =>
const mockPopulateItemsMap = vi.spyOn(insuranceController, "populateItemsMap"); const mockPopulateItemsMap = vi.spyOn(insuranceController, "populateItemsMap");
const mockPopulateParentAttachmentsMap = vi.spyOn(insuranceController, "populateParentAttachmentsMap"); const mockPopulateParentAttachmentsMap = vi.spyOn(insuranceController, "populateParentAttachmentsMap");
const mockIsAttachmentAttached = vi.spyOn(insuranceController.itemHelper, "isAttachmentAttached"); const mockIsAttachmentAttached = vi.spyOn(insuranceController.itemHelper, "isAttachmentAttached");
const mockProcessAttachments = vi.spyOn(insuranceController, "processAttachments").mockImplementation(vi.fn()); const mockProcessAttachments = vi.spyOn(insuranceController, "processAttachments").mockImplementation(
vi.fn(),
);
// Add all items to the toDelete set. Not realistic, but it's fine for this test. // Add all items to the toDelete set. Not realistic, but it's fine for this test.
const mockProcessRegularItems = vi.fn((insured, toDelete) => const mockProcessRegularItems = vi.fn((insured, toDelete) =>
{ {
insured.items.forEach(item => toDelete.add(item._id)); insured.items.forEach((item) => toDelete.add(item._id));
}); });
vi.spyOn(insuranceController, "processRegularItems").mockImplementation(mockProcessRegularItems); vi.spyOn(insuranceController, "processRegularItems").mockImplementation(mockProcessRegularItems);
@ -444,7 +471,7 @@ describe("InsuranceController", () =>
// Verify that the result is correct. // Verify that the result is correct.
expect(result.size).toBe(numberOfItems); expect(result.size).toBe(numberOfItems);
expect(result).toEqual(new Set(insured.items.map(item => item._id))); expect(result).toEqual(new Set(insured.items.map((item) => item._id)));
}); });
it("should ignore orphaned attachments", () => it("should ignore orphaned attachments", () =>
@ -463,7 +490,9 @@ describe("InsuranceController", () =>
{ {
return new Map<string, Item[]>(); return new Map<string, Item[]>();
}); });
vi.spyOn(insuranceController, "populateParentAttachmentsMap").mockImplementation(mockPopulateParentAttachmentsMap); vi.spyOn(insuranceController, "populateParentAttachmentsMap").mockImplementation(
mockPopulateParentAttachmentsMap,
);
// Execute the method. // Execute the method.
const result = insuranceController.findItemsToDelete(insured); const result = insuranceController.findItemsToDelete(insured);
@ -491,12 +520,12 @@ describe("InsuranceController", () =>
// Add all items to the toDelete set. Not realistic, but it's fine for this test. // Add all items to the toDelete set. Not realistic, but it's fine for this test.
const mockProcessRegularItems = vi.fn((insured, toDelete) => const mockProcessRegularItems = vi.fn((insured, toDelete) =>
{ {
insured.items.forEach(item => toDelete.add(item._id)); insured.items.forEach((item) => toDelete.add(item._id));
}); });
vi.spyOn(insuranceController, "processRegularItems").mockImplementation(mockProcessRegularItems); vi.spyOn(insuranceController, "processRegularItems").mockImplementation(mockProcessRegularItems);
const mockProcessAttachments = vi.fn((parentAttachmentsMap, itemsMap, traderId, toDelete) => const mockProcessAttachments = vi.fn((parentAttachmentsMap, itemsMap, traderId, toDelete) =>
{ {
insured.items.forEach(item => toDelete.add(item._id)); insured.items.forEach((item) => toDelete.add(item._id));
}); });
vi.spyOn(insuranceController, "processAttachments").mockImplementation(mockProcessAttachments); vi.spyOn(insuranceController, "processAttachments").mockImplementation(mockProcessAttachments);
@ -511,7 +540,7 @@ describe("InsuranceController", () =>
// Verify that the result is correct. // Verify that the result is correct.
expect(result.size).toBe(numberOfItems); expect(result.size).toBe(numberOfItems);
expect(result).toEqual(new Set(insured.items.map(item => item._id))); expect(result).toEqual(new Set(insured.items.map((item) => item._id)));
}); });
it("should return an empty set if no items are to be deleted", () => it("should return an empty set if no items are to be deleted", () =>
@ -523,8 +552,12 @@ describe("InsuranceController", () =>
const mockPopulateParentAttachmentsMap = vi.spyOn(insuranceController, "populateParentAttachmentsMap"); const mockPopulateParentAttachmentsMap = vi.spyOn(insuranceController, "populateParentAttachmentsMap");
// Don't add any items to the toDelete set. // Don't add any items to the toDelete set.
const mockProcessRegularItems = vi.spyOn(insuranceController, "processRegularItems").mockImplementation(vi.fn()); const mockProcessRegularItems = vi.spyOn(insuranceController, "processRegularItems").mockImplementation(
const mockProcessAttachments = vi.spyOn(insuranceController, "processAttachments").mockImplementation(vi.fn()); vi.fn(),
);
const mockProcessAttachments = vi.spyOn(insuranceController, "processAttachments").mockImplementation(
vi.fn(),
);
// Execute the method. // Execute the method.
const result = insuranceController.findItemsToDelete(insured); const result = insuranceController.findItemsToDelete(insured);
@ -551,12 +584,12 @@ describe("InsuranceController", () =>
// Add all items to the toDelete set. Not realistic, but it's fine for this test. // Add all items to the toDelete set. Not realistic, but it's fine for this test.
const mockProcessRegularItems = vi.fn((insured, toDelete) => const mockProcessRegularItems = vi.fn((insured, toDelete) =>
{ {
insured.items.forEach(item => toDelete.add(item._id)); insured.items.forEach((item) => toDelete.add(item._id));
}); });
vi.spyOn(insuranceController, "processRegularItems").mockImplementation(mockProcessRegularItems); vi.spyOn(insuranceController, "processRegularItems").mockImplementation(mockProcessRegularItems);
const mockProcessAttachments = vi.fn((parentAttachmentsMap, itemsMap, traderId, toDelete) => const mockProcessAttachments = vi.fn((parentAttachmentsMap, itemsMap, traderId, toDelete) =>
{ {
insured.items.forEach(item => toDelete.add(item._id)); insured.items.forEach((item) => toDelete.add(item._id));
}); });
vi.spyOn(insuranceController, "processAttachments").mockImplementation(mockProcessAttachments); vi.spyOn(insuranceController, "processAttachments").mockImplementation(mockProcessAttachments);
@ -595,12 +628,12 @@ describe("InsuranceController", () =>
"da8cde1b3024c336f6e06152", "da8cde1b3024c336f6e06152",
"bc041c0011d76f714b898400", "bc041c0011d76f714b898400",
"9f8d7880a6e0a47a211ec5d3", "9f8d7880a6e0a47a211ec5d3",
"db2ef9442178910eba985b51" "db2ef9442178910eba985b51",
]; ];
validAttachmentTemplates.forEach(value => validAttachmentTemplates.forEach((value) =>
{ {
// Verify that each template is present in the array of attachments. // Verify that each template is present in the array of attachments.
expect(gun.some(item => item._id === value)).toBe(true); expect(gun.some((item) => item._id === value)).toBe(true);
}); });
}); });
@ -625,11 +658,11 @@ describe("InsuranceController", () =>
"1e0b177df108c0c117028812", "1e0b177df108c0c117028812",
"c9278dd8251e99578bf7a274", "c9278dd8251e99578bf7a274",
"402b4086535a50ef7d9cef88", "402b4086535a50ef7d9cef88",
"566335b3df586f34b47f5e35" "566335b3df586f34b47f5e35",
]; ];
invalidAttachmentTemplates.forEach(value => invalidAttachmentTemplates.forEach((value) =>
{ {
expect(gun.every(item => item._id !== value)).toBe(true); expect(gun.every((item) => item._id !== value)).toBe(true);
}); });
}); });
@ -655,12 +688,12 @@ describe("InsuranceController", () =>
"dc565f750342cb2d19eeda06", "dc565f750342cb2d19eeda06",
"e9ff62601669d9e2ea9c2fbb", "e9ff62601669d9e2ea9c2fbb",
"ac134d7cf6c9d8e25edd0015", "ac134d7cf6c9d8e25edd0015",
"22274b895ecc80d51c3cba1c" "22274b895ecc80d51c3cba1c",
]; ];
validAttachmentTemplates.forEach(value => validAttachmentTemplates.forEach((value) =>
{ {
// Verify that each template is present in the array of attachments. // Verify that each template is present in the array of attachments.
expect(gun.some(item => item._id === value)).toBe(true); expect(gun.some((item) => item._id === value)).toBe(true);
}); });
}); });
@ -678,7 +711,7 @@ describe("InsuranceController", () =>
expect(result.size).toBe(6); // There are 6 base-level items in this insurance package. expect(result.size).toBe(6); // There are 6 base-level items in this insurance package.
const gun = result.get("351180f3248d45c71cb2ebdc"); const gun = result.get("351180f3248d45c71cb2ebdc");
expect(insured.items.find(item => item._id === "351180f3248d45c71cb2ebdc").slotId).toBe("main"); expect(insured.items.find((item) => item._id === "351180f3248d45c71cb2ebdc").slotId).toBe("main");
expect(gun.length).toBe(14); // This AS VAL has 14 valid attachments. expect(gun.length).toBe(14); // This AS VAL has 14 valid attachments.
}); });
@ -727,7 +760,10 @@ describe("InsuranceController", () =>
// Mock helper methods. // Mock helper methods.
const mockIsAttachmentAttached = vi.spyOn(insuranceController.itemHelper, "isAttachmentAttached"); const mockIsAttachmentAttached = vi.spyOn(insuranceController.itemHelper, "isAttachmentAttached");
const mockFindAndReturnChildrenAsItems = vi.spyOn(insuranceController.itemHelper, "findAndReturnChildrenAsItems"); const mockFindAndReturnChildrenAsItems = vi.spyOn(
insuranceController.itemHelper,
"findAndReturnChildrenAsItems",
);
// Mock rollForDelete to return true for all items. Not realistic, but it's fine for this test. // Mock rollForDelete to return true for all items. Not realistic, but it's fine for this test.
const mockRollForDelete = vi.spyOn(insuranceController, "rollForDelete").mockReturnValue(true); const mockRollForDelete = vi.spyOn(insuranceController, "rollForDelete").mockReturnValue(true);
@ -741,7 +777,7 @@ describe("InsuranceController", () =>
expect(mockRollForDelete).toHaveBeenCalledTimes(numberOfItems); expect(mockRollForDelete).toHaveBeenCalledTimes(numberOfItems);
// Verify that all items were added to the toDelete set. // Verify that all items were added to the toDelete set.
expect(toDelete).toEqual(new Set(insured.items.map(item => item._id))); expect(toDelete).toEqual(new Set(insured.items.map((item) => item._id)));
}); });
it("should not roll attached attachments", () => it("should not roll attached attachments", () =>
@ -783,7 +819,7 @@ describe("InsuranceController", () =>
insuranceController.processRegularItems(insured, toDelete); insuranceController.processRegularItems(insured, toDelete);
// Verify that all items were added to the toDelete set. // Verify that all items were added to the toDelete set.
expect(toDelete).toEqual(new Set(insured.items.map(item => item._id))); expect(toDelete).toEqual(new Set(insured.items.map((item) => item._id)));
}); });
}); });
@ -827,7 +863,9 @@ describe("InsuranceController", () =>
const parentItem = itemsMap.get(parentId); const parentItem = itemsMap.get(parentId);
if (parentItem) if (parentItem)
{ {
const expectedMessage = `Processing attachments for parent item: ${itemHelper.getItemName(parentItem._tpl)}`; const expectedMessage = `Processing attachments for parent item: ${
itemHelper.getItemName(parentItem._tpl)
}`;
expect(mockLoggerDebug).toHaveBeenCalledWith(expectedMessage); expect(mockLoggerDebug).toHaveBeenCalledWith(expectedMessage);
} }
} }
@ -911,14 +949,16 @@ describe("InsuranceController", () =>
const attachments = parentToAttachmentMap.values().next().value; const attachments = parentToAttachmentMap.values().next().value;
// Set the maxPrice of the first two attachments to null. // Set the maxPrice of the first two attachments to null.
vi.spyOn(insuranceController.itemHelper, "getItemMaxPrice").mockReturnValueOnce(null).mockReturnValueOnce(null); vi.spyOn(insuranceController.itemHelper, "getItemMaxPrice").mockReturnValueOnce(null).mockReturnValueOnce(
null,
);
// Execute the method. // Execute the method.
const sortedAttachments = insuranceController.sortAttachmentsByPrice(attachments); const sortedAttachments = insuranceController.sortAttachmentsByPrice(attachments);
// Verify that the attachments with null maxPrice are at the bottom of the list // Verify that the attachments with null maxPrice are at the bottom of the list
const nullPriceAttachments = sortedAttachments.slice(-2); const nullPriceAttachments = sortedAttachments.slice(-2);
nullPriceAttachments.forEach(attachment => nullPriceAttachments.forEach((attachment) =>
{ {
expect(attachment.maxPrice).toBeNull(); expect(attachment.maxPrice).toBeNull();
}); });
@ -937,7 +977,7 @@ describe("InsuranceController", () =>
{ {
const attachments = [ const attachments = [
{_id: "item1", name: "Item 1", maxPrice: 100}, {_id: "item1", name: "Item 1", maxPrice: 100},
{ _id: "item2", name: "Item 2", maxPrice: 200 } {_id: "item2", name: "Item 2", maxPrice: 200},
]; ];
// Mock the logger.debug function. // Mock the logger.debug function.
@ -1096,9 +1136,9 @@ describe("InsuranceController", () =>
insuranceController.removeItemsFromInsurance(insured, toDelete); insuranceController.removeItemsFromInsurance(insured, toDelete);
// Ensure that the items in the toDelete set are not present in the insured items array. // Ensure that the items in the toDelete set are not present in the insured items array.
toDelete.forEach(toDeleteId => toDelete.forEach((toDeleteId) =>
{ {
expect(insured.items.some(item => item._id === toDeleteId)).toBe(false); expect(insured.items.some((item) => item._id === toDeleteId)).toBe(false);
}); });
}); });
@ -1120,7 +1160,7 @@ describe("InsuranceController", () =>
const insured = insuranceFixture[0]; const insured = insuranceFixture[0];
const originalCount = insured.items.length; const originalCount = insured.items.length;
const toDelete = new Set<string>(); const toDelete = new Set<string>();
insured.items.forEach(item => toDelete.add(item._id)); insured.items.forEach((item) => toDelete.add(item._id));
// All of the items should be added to the toDelete set. // All of the items should be added to the toDelete set.
expect(originalCount).toBe(toDelete.size); expect(originalCount).toBe(toDelete.size);
@ -1146,7 +1186,9 @@ describe("InsuranceController", () =>
insured.items[0].slotId = "main"; // Should not be "hideout". insured.items[0].slotId = "main"; // Should not be "hideout".
// Iterate over the items and find an individual orphaned item. // Iterate over the items and find an individual orphaned item.
const orphanedItem = insured.items.find(item => !insured.items.some(parent => parent._id === item.parentId)); const orphanedItem = insured.items.find((item) =>
!insured.items.some((parent) => parent._id === item.parentId)
);
// Setup tests to verify that the orphaned item we added is in fact orphaned. // Setup tests to verify that the orphaned item we added is in fact orphaned.
expect(orphanedItem.parentId).toBe(insured.items[0].parentId); expect(orphanedItem.parentId).toBe(insured.items[0].parentId);
@ -1184,7 +1226,9 @@ describe("InsuranceController", () =>
insured.items[0].location = {x: 1, y: 2, r: 3, isSearched: true}; // Should be removed. insured.items[0].location = {x: 1, y: 2, r: 3, isSearched: true}; // Should be removed.
// Iterate over the items and find an individual orphaned item. // Iterate over the items and find an individual orphaned item.
const orphanedItem = insured.items.find(item => !insured.items.some(parent => parent._id === item.parentId)); const orphanedItem = insured.items.find((item) =>
!insured.items.some((parent) => parent._id === item.parentId)
);
// Setup tests to verify that the orphaned item we added is in fact orphaned. // Setup tests to verify that the orphaned item we added is in fact orphaned.
expect(orphanedItem.parentId).toBe(insured.items[0].parentId); expect(orphanedItem.parentId).toBe(insured.items[0].parentId);
@ -1275,7 +1319,7 @@ describe("InsuranceController", () =>
insuranceFailedTpl, insuranceFailedTpl,
insurance.items, insurance.items,
insurance.messageContent.maxStorageTime, insurance.messageContent.maxStorageTime,
insurance.messageContent.systemData insurance.messageContent.systemData,
); );
}); });
@ -1309,7 +1353,7 @@ describe("InsuranceController", () =>
insurance.messageContent.templateId, insurance.messageContent.templateId,
insurance.items, insurance.items,
insurance.messageContent.maxStorageTime, insurance.messageContent.maxStorageTime,
insurance.messageContent.systemData insurance.messageContent.systemData,
); );
}); });
}); });
@ -1322,8 +1366,8 @@ describe("InsuranceController", () =>
const traderId = "54cb57776803fa99248b456e"; // Therapist (85% return chance) const traderId = "54cb57776803fa99248b456e"; // Therapist (85% return chance)
insuranceController.insuranceConfig = { insuranceController.insuranceConfig = {
returnChancePercent: { returnChancePercent: {
[traderId]: 85 // Force 85% return chance [traderId]: 85, // Force 85% return chance
} },
}; };
// Execute the method. // Execute the method.
@ -1339,8 +1383,8 @@ describe("InsuranceController", () =>
const traderId = "54cb57776803fa99248b456e"; // Therapist (85% return chance) const traderId = "54cb57776803fa99248b456e"; // Therapist (85% return chance)
insuranceController.insuranceConfig = { insuranceController.insuranceConfig = {
returnChancePercent: { returnChancePercent: {
[traderId]: 85 // Force 85% return chance [traderId]: 85, // Force 85% return chance
} },
}; };
// Execute the method. // Execute the method.
@ -1356,8 +1400,8 @@ describe("InsuranceController", () =>
const traderId = "54cb57776803fa99248b456e"; // Therapist (85% return chance) const traderId = "54cb57776803fa99248b456e"; // Therapist (85% return chance)
insuranceController.insuranceConfig = { insuranceController.insuranceConfig = {
returnChancePercent: { returnChancePercent: {
[traderId]: 85 // Force 85% return chance [traderId]: 85, // Force 85% return chance
} },
}; };
// Execute the method. // Execute the method.
@ -1394,7 +1438,13 @@ describe("InsuranceController", () =>
describe("insure", () => describe("insure", () =>
{ {
let pmcData: any, body: any, sessionId: string, insuranceController: any, mockGetPremium: any, mockPayMoney: any, mockGetOutput: any; let pmcData: any,
body: any,
sessionId: string,
insuranceController: any,
mockGetPremium: any,
mockPayMoney: any,
mockGetOutput: any;
beforeEach(() => beforeEach(() =>
{ {
@ -1405,14 +1455,14 @@ describe("InsuranceController", () =>
Inventory: { Inventory: {
items: [ items: [
{_id: "item1", otherProps: "value1"}, {_id: "item1", otherProps: "value1"},
{ _id: "item2", otherProps: "value2" } {_id: "item2", otherProps: "value2"},
] ],
}, },
InsuredItems: [] InsuredItems: [],
}; };
body = { body = {
items: ["item1", "item2"], items: ["item1", "item2"],
tid: "someTraderId" tid: "someTraderId",
}; };
sessionId = "session-id"; sessionId = "session-id";
@ -1420,11 +1470,11 @@ describe("InsuranceController", () =>
mockGetPremium = vi.spyOn(insuranceController.insuranceService, "getPremium").mockReturnValue(100); mockGetPremium = vi.spyOn(insuranceController.insuranceService, "getPremium").mockReturnValue(100);
mockPayMoney = vi.spyOn(insuranceController.paymentService, "payMoney").mockReturnValue({ mockPayMoney = vi.spyOn(insuranceController.paymentService, "payMoney").mockReturnValue({
warnings: [], warnings: [],
otherProperty: "property-value" otherProperty: "property-value",
}); });
mockGetOutput = vi.spyOn(insuranceController.eventOutputHolder, "getOutput").mockReturnValue({ mockGetOutput = vi.spyOn(insuranceController.eventOutputHolder, "getOutput").mockReturnValue({
warnings: [], warnings: [],
otherProperty: "property-value" otherProperty: "property-value",
}); });
}); });
@ -1440,19 +1490,20 @@ describe("InsuranceController", () =>
{ {
scheme_items: [ scheme_items: [
{id: "item1", count: 100}, {id: "item1", count: 100},
{ id: "item2", count: 100 } {id: "item2", count: 100},
], ],
tid: "someTraderId", tid: "someTraderId",
Action: "", Action: "",
type: "", type: "",
item_id: "", item_id: "",
count: 0, count: 0,
scheme_id: 0 scheme_id: 0,
}, },
sessionId, { sessionId,
{
warnings: [], warnings: [],
otherProperty: "property-value" otherProperty: "property-value",
} },
); );
}); });
@ -1480,14 +1531,14 @@ describe("InsuranceController", () =>
const expectedPaymentOptions = { const expectedPaymentOptions = {
scheme_items: [ scheme_items: [
{id: "item1", count: 100}, {id: "item1", count: 100},
{ id: "item2", count: 100 } {id: "item2", count: 100},
], ],
tid: body.tid, tid: body.tid,
Action: "", Action: "",
type: "", type: "",
item_id: "", item_id: "",
count: 0, count: 0,
scheme_id: 0 scheme_id: 0,
}; };
// Verify that the paymentService's payMoney method was called once with the expected parameters. // Verify that the paymentService's payMoney method was called once with the expected parameters.
@ -1498,7 +1549,7 @@ describe("InsuranceController", () =>
pmcData, pmcData,
expectedPaymentOptions, expectedPaymentOptions,
sessionId, sessionId,
mockGetOutput.mock.results[0].value mockGetOutput.mock.results[0].value,
); );
}); });
@ -1508,7 +1559,7 @@ describe("InsuranceController", () =>
insuranceController.insure(pmcData, body, sessionId); insuranceController.insure(pmcData, body, sessionId);
// Verify that the InsuredItems array has been populated with the correct items. // Verify that the InsuredItems array has been populated with the correct items.
const insuredItemIds = pmcData.InsuredItems.map(insuredItem => insuredItem.itemId); const insuredItemIds = pmcData.InsuredItems.map((insuredItem) => insuredItem.itemId);
expect(insuredItemIds).toContain("item1"); expect(insuredItemIds).toContain("item1");
expect(insuredItemIds).toContain("item2"); expect(insuredItemIds).toContain("item2");
@ -1523,9 +1574,9 @@ describe("InsuranceController", () =>
warnings: [{ warnings: [{
index: 0, index: 0,
errmsg: "Not enough money to complete transaction", errmsg: "Not enough money to complete transaction",
code: 500 code: 500,
}], }],
otherProperty: "property-value" otherProperty: "property-value",
}; };
mockPayMoney.mockReturnValue(expectedPayMoneyReturn); mockPayMoney.mockReturnValue(expectedPayMoneyReturn);
@ -1546,9 +1597,9 @@ describe("InsuranceController", () =>
warnings: [{ warnings: [{
index: 0, index: 0,
errmsg: "Not enough money to complete transaction", errmsg: "Not enough money to complete transaction",
code: 500 code: 500,
}], }],
otherProperty: "property-value" otherProperty: "property-value",
}; };
mockPayMoney.mockReturnValue(expectedPayMoneyReturn); mockPayMoney.mockReturnValue(expectedPayMoneyReturn);
@ -1575,9 +1626,9 @@ describe("InsuranceController", () =>
items: [ items: [
{_id: "itemId1", _tpl: "itemTpl1", otherProperty: "property-value1"}, {_id: "itemId1", _tpl: "itemTpl1", otherProperty: "property-value1"},
{_id: "itemId2", _tpl: "itemTpl2", otherProperty: "property-value2"}, {_id: "itemId2", _tpl: "itemTpl2", otherProperty: "property-value2"},
{ _id: "itemId3", _tpl: "itemTpl3", otherProperty: "property-value3" } {_id: "itemId3", _tpl: "itemTpl3", otherProperty: "property-value3"},
] ],
} },
}); });
}); });
@ -1615,11 +1666,11 @@ describe("InsuranceController", () =>
{ {
const request = { const request = {
traders: ["prapor", "therapist"], traders: ["prapor", "therapist"],
items: ["itemId1", "itemId2", "itemId3"] items: ["itemId1", "itemId2", "itemId3"],
}; };
const expected = { const expected = {
prapor: {itemTpl1: 100, itemTpl2: 200, itemTpl3: 300}, prapor: {itemTpl1: 100, itemTpl2: 200, itemTpl3: 300},
therapist: { itemTpl1: 150, itemTpl2: 250, itemTpl3: 350 } therapist: {itemTpl1: 150, itemTpl2: 250, itemTpl3: 350},
}; };
// Mock the InsuranceService.getPremium method to return the expected values. // Mock the InsuranceService.getPremium method to return the expected values.
@ -1643,11 +1694,11 @@ describe("InsuranceController", () =>
items: [ items: [
"itemId1", "itemId1",
"itemId2", "itemId2",
"itemId4" // Doesn't exist in the player's inventory. "itemId4", // Doesn't exist in the player's inventory.
] ],
}; };
const expected = { const expected = {
prapor: { itemTpl1: 100, itemTpl2: 200 } prapor: {itemTpl1: 100, itemTpl2: 200},
}; };
// Mock the InsuranceService.getPremium method to return the expected values. // Mock the InsuranceService.getPremium method to return the expected values.

View File

@ -1,9 +1,9 @@
/* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable @typescript-eslint/naming-convention */
import "reflect-metadata"; import "reflect-metadata";
import { container } from "tsyringe";
import { vi, beforeEach, afterEach, describe, expect, it } from "vitest";
import { BotGenerator } from "@spt-aki/generators/BotGenerator"; import { BotGenerator } from "@spt-aki/generators/BotGenerator";
import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData";
import { container } from "tsyringe";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
describe("BotGenerator", () => describe("BotGenerator", () =>
{ {
@ -62,15 +62,15 @@ describe("BotGenerator", () =>
const mockPlayerProfile = { const mockPlayerProfile = {
Info: { Info: {
Nickname: "Player Nickname", Nickname: "Player Nickname",
Level: 1 Level: 1,
} },
}; };
vi.spyOn(botGenerator.profileHelper, "getPmcProfile").mockReturnValue(<IPmcData>mockPlayerProfile); vi.spyOn(botGenerator.profileHelper, "getPmcProfile").mockReturnValue(<IPmcData>mockPlayerProfile);
const botJsonTemplate = { const botJsonTemplate = {
firstName: ["test"], firstName: ["test"],
lastName: [] lastName: [],
}; };
const sessionId = "sessionId"; const sessionId = "sessionId";
@ -88,14 +88,14 @@ describe("BotGenerator", () =>
const mockPlayerProfile = { const mockPlayerProfile = {
Info: { Info: {
Nickname: "Player Nickname", Nickname: "Player Nickname",
Level: 1 Level: 1,
} },
}; };
vi.spyOn(botGenerator.profileHelper, "getPmcProfile").mockReturnValue(<IPmcData>mockPlayerProfile); vi.spyOn(botGenerator.profileHelper, "getPmcProfile").mockReturnValue(<IPmcData>mockPlayerProfile);
const botJsonTemplate = { const botJsonTemplate = {
firstName: ["test"], firstName: ["test"],
lastName: [] lastName: [],
}; };
const sessionId = "sessionId"; const sessionId = "sessionId";
@ -114,15 +114,15 @@ describe("BotGenerator", () =>
const mockPlayerProfile = { const mockPlayerProfile = {
Info: { Info: {
Nickname: "Player", Nickname: "Player",
Level: 1 Level: 1,
} },
}; };
vi.spyOn(botGenerator.profileHelper, "getPmcProfile").mockReturnValue(<IPmcData>mockPlayerProfile); vi.spyOn(botGenerator.profileHelper, "getPmcProfile").mockReturnValue(<IPmcData>mockPlayerProfile);
vi.spyOn(botGenerator.localisationService, "getRandomTextThatMatchesPartialKey").mockReturnValue("test"); vi.spyOn(botGenerator.localisationService, "getRandomTextThatMatchesPartialKey").mockReturnValue("test");
const botJsonTemplate = { const botJsonTemplate = {
firstName: ["Player"], firstName: ["Player"],
lastName: [] lastName: [],
}; };
const sessionId = "sessionId"; const sessionId = "sessionId";
@ -140,14 +140,14 @@ describe("BotGenerator", () =>
const mockPlayerProfile = { const mockPlayerProfile = {
Info: { Info: {
Nickname: "Player", Nickname: "Player",
Level: 1 Level: 1,
} },
}; };
vi.spyOn(botGenerator.profileHelper, "getPmcProfile").mockReturnValue(<IPmcData>mockPlayerProfile); vi.spyOn(botGenerator.profileHelper, "getPmcProfile").mockReturnValue(<IPmcData>mockPlayerProfile);
const botJsonTemplate = { const botJsonTemplate = {
firstName: ["test"], firstName: ["test"],
lastName: [] lastName: [],
}; };
const sessionId = "sessionId"; const sessionId = "sessionId";
@ -167,14 +167,14 @@ describe("BotGenerator", () =>
const mockPlayerProfile = { const mockPlayerProfile = {
Info: { Info: {
Nickname: "Player", Nickname: "Player",
Level: 1 Level: 1,
} },
}; };
vi.spyOn(botGenerator.profileHelper, "getPmcProfile").mockReturnValue(<IPmcData>mockPlayerProfile); vi.spyOn(botGenerator.profileHelper, "getPmcProfile").mockReturnValue(<IPmcData>mockPlayerProfile);
const botJsonTemplate = { const botJsonTemplate = {
firstName: ["test"], firstName: ["test"],
lastName: [] lastName: [],
}; };
const sessionId = "sessionId"; const sessionId = "sessionId";

View File

@ -1,6 +1,6 @@
import "reflect-metadata"; import "reflect-metadata";
import { container } from "tsyringe"; import { container } from "tsyringe";
import { vi, beforeEach, afterEach, describe, expect, it } from "vitest"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { BotLevelGenerator } from "@spt-aki/generators/BotLevelGenerator"; import { BotLevelGenerator } from "@spt-aki/generators/BotLevelGenerator";
import { MinMax } from "@spt-aki/models/common/MinMax"; import { MinMax } from "@spt-aki/models/common/MinMax";
@ -29,7 +29,7 @@ describe("BotLevelGenerator", () =>
{ {
const levelDetails: MinMax = { const levelDetails: MinMax = {
min: 5, min: 5,
max: 10 max: 10,
}; };
const botGenerationDetails: BotGenerationDetails = { const botGenerationDetails: BotGenerationDetails = {
@ -40,7 +40,7 @@ describe("BotLevelGenerator", () =>
botRelativeLevelDeltaMax: 0, botRelativeLevelDeltaMax: 0,
botCountToGenerate: 0, botCountToGenerate: 0,
botDifficulty: "", botDifficulty: "",
isPlayerScav: false isPlayerScav: false,
}; };
const result = botLevelGenerator.generateBotLevel(levelDetails, botGenerationDetails, null); const result = botLevelGenerator.generateBotLevel(levelDetails, botGenerationDetails, null);
@ -55,7 +55,7 @@ describe("BotLevelGenerator", () =>
{ {
const levelDetails: MinMax = { const levelDetails: MinMax = {
min: 5, min: 5,
max: 10 max: 10,
}; };
const expTable = databaseServer.getTables().globals.config.exp.level.exp_table; const expTable = databaseServer.getTables().globals.config.exp.level.exp_table;
@ -69,14 +69,19 @@ describe("BotLevelGenerator", () =>
{ {
const levelDetails: MinMax = { const levelDetails: MinMax = {
min: 100, min: 100,
max: 100 max: 100,
}; };
const expTable = databaseServer.getTables().globals.config.exp.level.exp_table; const expTable = databaseServer.getTables().globals.config.exp.level.exp_table;
const playerLevel = 100; const playerLevel = 100;
const relativeDeltaMax = 5; const relativeDeltaMax = 5;
const result = botLevelGenerator.getHighestRelativeBotLevel(playerLevel, relativeDeltaMax, levelDetails, expTable); const result = botLevelGenerator.getHighestRelativeBotLevel(
playerLevel,
relativeDeltaMax,
levelDetails,
expTable,
);
expect(result).toBe(79); expect(result).toBe(79);
}); });

View File

@ -1,6 +1,6 @@
import "reflect-metadata"; import "reflect-metadata";
import { container } from "tsyringe"; import { container } from "tsyringe";
import { vi, beforeEach, afterEach, describe, expect, it } from "vitest"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { BotHelper } from "@spt-aki/helpers/BotHelper"; import { BotHelper } from "@spt-aki/helpers/BotHelper";

View File

@ -1,6 +1,6 @@
import "reflect-metadata"; import "reflect-metadata";
import { container } from "tsyringe"; import { container } from "tsyringe";
import { vi, beforeEach, afterEach, describe, expect, it } from "vitest"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { HandbookHelper } from "@spt-aki/helpers/HandbookHelper"; import { HandbookHelper } from "@spt-aki/helpers/HandbookHelper";
import { Money } from "@spt-aki/models/enums/Money"; import { Money } from "@spt-aki/models/enums/Money";

View File

@ -1,6 +1,6 @@
import "reflect-metadata"; import "reflect-metadata";
import { container } from "tsyringe"; import { container } from "tsyringe";
import { vi, beforeEach, afterEach, describe, expect, it } from "vitest"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { InRaidHelper } from "@spt-aki/helpers/InRaidHelper"; import { InRaidHelper } from "@spt-aki/helpers/InRaidHelper";
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer"; import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
@ -27,12 +27,12 @@ describe("InRaidHelper", () =>
const postRaidPlayerVictims = [ const postRaidPlayerVictims = [
{ {
Side: "Savage", Side: "Savage",
Role: "assault" Role: "assault",
}, },
{ {
Side: "Savage", Side: "Savage",
Role: "assault" Role: "assault",
} },
]; // Kills ]; // Kills
const databaseServer = container.resolve<DatabaseServer>("DatabaseServer"); const databaseServer = container.resolve<DatabaseServer>("DatabaseServer");
@ -49,12 +49,12 @@ describe("InRaidHelper", () =>
const postRaidPlayerVictims = [ const postRaidPlayerVictims = [
{ {
Side: "Usec", Side: "Usec",
Role: "sptUsec" Role: "sptUsec",
}, },
{ {
Side: "Bear", Side: "Bear",
Role: "sptBear" Role: "sptBear",
} },
]; // Kills ]; // Kills
const databaseServer = container.resolve<DatabaseServer>("DatabaseServer"); const databaseServer = container.resolve<DatabaseServer>("DatabaseServer");
@ -72,29 +72,32 @@ describe("InRaidHelper", () =>
const postRaidPlayerVictims = [ const postRaidPlayerVictims = [
{ {
Side: "Usec", Side: "Usec",
Role: "sptUsec" Role: "sptUsec",
}, },
{ {
Side: "savage", Side: "savage",
Role: "assault" Role: "assault",
}, },
{ {
Side: "savage", Side: "savage",
Role: "bossBoar" Role: "bossBoar",
}, },
{ {
Side: "savage", Side: "savage",
Role: "assault" Role: "assault",
} },
]; // Kills ]; // Kills
const databaseServer = container.resolve<DatabaseServer>("DatabaseServer"); const databaseServer = container.resolve<DatabaseServer>("DatabaseServer");
const usecStandingChangeOnKill = databaseServer.getTables().bots.types.bear.experience.standingForKill; const usecStandingChangeOnKill = databaseServer.getTables().bots.types.bear.experience.standingForKill;
const scavStandingChangeOnKill = databaseServer.getTables().bots.types.assault.experience.standingForKill; const scavStandingChangeOnKill = databaseServer.getTables().bots.types.assault.experience.standingForKill;
const bossBoarStandingChangeOnKill = databaseServer.getTables().bots.types.bossboar.experience.standingForKill; const bossBoarStandingChangeOnKill =
databaseServer.getTables().bots.types.bossboar.experience.standingForKill;
const result = inraidHelper.calculateFenceStandingChangeFromKills(fenceStanding, postRaidPlayerVictims); const result = inraidHelper.calculateFenceStandingChangeFromKills(fenceStanding, postRaidPlayerVictims);
expect(result).toBe(usecStandingChangeOnKill + (scavStandingChangeOnKill * 2) + bossBoarStandingChangeOnKill); expect(result).toBe(
usecStandingChangeOnKill + (scavStandingChangeOnKill * 2) + bossBoarStandingChangeOnKill,
);
expect(result).lessThan(0); expect(result).lessThan(0);
}); });
@ -104,12 +107,14 @@ describe("InRaidHelper", () =>
const postRaidPlayerVictims = [ const postRaidPlayerVictims = [
{ {
Side: "savage", Side: "savage",
Role: "testRole" Role: "testRole",
} },
]; // Kills ]; // Kills
// Fake getFenceStandingChangeForKillAsScav() returning null // Fake getFenceStandingChangeForKillAsScav() returning null
vi.spyOn(inraidHelper, "getFenceStandingChangeForKillAsScav").mockReturnValueOnce(null).mockReturnValueOnce(null); vi.spyOn(inraidHelper, "getFenceStandingChangeForKillAsScav").mockReturnValueOnce(null).mockReturnValueOnce(
null,
);
const result = inraidHelper.calculateFenceStandingChangeFromKills(fenceStanding, postRaidPlayerVictims); const result = inraidHelper.calculateFenceStandingChangeFromKills(fenceStanding, postRaidPlayerVictims);
expect(result).toBe(0); expect(result).toBe(0);
}); });

View File

@ -1,12 +1,12 @@
import "reflect-metadata"; import "reflect-metadata";
import { container } from "tsyringe"; import { container } from "tsyringe";
import { vi, beforeEach, afterEach, describe, expect, it } from "vitest"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper";
import { Item, Repairable } from "@spt-aki/models/eft/common/tables/IItem"; import { Item, Repairable } from "@spt-aki/models/eft/common/tables/IItem";
import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem";
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer"; import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
import { HashUtil } from "@spt-aki/utils/HashUtil"; import { HashUtil } from "@spt-aki/utils/HashUtil";
import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem";
describe("ItemHelper", () => describe("ItemHelper", () =>
{ {
@ -251,7 +251,7 @@ describe("ItemHelper", () =>
{ {
const initialItem: Item = { const initialItem: Item = {
_id: "", _id: "",
_tpl: "" _tpl: "",
}; };
const fixedItem = itemHelper.fixItemStackCount(initialItem); const fixedItem = itemHelper.fixItemStackCount(initialItem);
@ -264,7 +264,7 @@ describe("ItemHelper", () =>
const initialItem: Item = { const initialItem: Item = {
_id: "", _id: "",
_tpl: "", _tpl: "",
upd: {} upd: {},
}; };
const fixedItem = itemHelper.fixItemStackCount(initialItem); const fixedItem = itemHelper.fixItemStackCount(initialItem);
@ -278,8 +278,8 @@ describe("ItemHelper", () =>
_id: "", _id: "",
_tpl: "", _tpl: "",
upd: { upd: {
StackObjectsCount: 5 StackObjectsCount: 5,
} },
}; };
const fixedItem = itemHelper.fixItemStackCount(initialItem); const fixedItem = itemHelper.fixItemStackCount(initialItem);
@ -324,7 +324,6 @@ describe("ItemHelper", () =>
// Restore the original behavior // Restore the original behavior
loggerWarningSpy.mockRestore(); loggerWarningSpy.mockRestore();
}); });
}); });
describe("getItems", () => describe("getItems", () =>
@ -420,7 +419,7 @@ describe("ItemHelper", () =>
const itemId = container.resolve<HashUtil>("HashUtil").generate(); const itemId = container.resolve<HashUtil>("HashUtil").generate();
const item: Item = { const item: Item = {
_id: itemId, _id: itemId,
_tpl: "590c657e86f77412b013051d" // "Grizzly medical kit" _tpl: "590c657e86f77412b013051d", // "Grizzly medical kit"
}; };
const result = itemHelper.getItemQualityModifier(item); const result = itemHelper.getItemQualityModifier(item);
@ -434,7 +433,7 @@ describe("ItemHelper", () =>
const item: Item = { const item: Item = {
_id: itemId, _id: itemId,
_tpl: "590c657e86f77412b013051d", // "Grizzly medical kit" _tpl: "590c657e86f77412b013051d", // "Grizzly medical kit"
upd: {} upd: {},
}; };
const result = itemHelper.getItemQualityModifier(item); const result = itemHelper.getItemQualityModifier(item);
@ -450,9 +449,9 @@ describe("ItemHelper", () =>
_tpl: "590c657e86f77412b013051d", // "Grizzly medical kit" _tpl: "590c657e86f77412b013051d", // "Grizzly medical kit"
upd: { upd: {
MedKit: { MedKit: {
HpResource: 900 // 1800 total HpResource: 900, // 1800 total
} },
} },
}; };
const result = itemHelper.getItemQualityModifier(item); const result = itemHelper.getItemQualityModifier(item);
@ -460,7 +459,7 @@ describe("ItemHelper", () =>
expect(result).toBe(0.5); expect(result).toBe(0.5);
}); });
it("should return correct value for a reparable helmet", () => it("should return correct value for a repairable helmet", () =>
{ {
const itemId = container.resolve<HashUtil>("HashUtil").generate(); const itemId = container.resolve<HashUtil>("HashUtil").generate();
const item: Item = { const item: Item = {
@ -469,9 +468,9 @@ describe("ItemHelper", () =>
upd: { upd: {
Repairable: { Repairable: {
Durability: 19, Durability: 19,
MaxDurability: 38 MaxDurability: 38,
} },
} },
}; };
const result = itemHelper.getItemQualityModifier(item); const result = itemHelper.getItemQualityModifier(item);
@ -488,9 +487,9 @@ describe("ItemHelper", () =>
upd: { upd: {
Repairable: { Repairable: {
Durability: 20, Durability: 20,
MaxDurability: 100 MaxDurability: 100,
} },
} },
}; };
const result = itemHelper.getItemQualityModifier(item); const result = itemHelper.getItemQualityModifier(item);
@ -506,9 +505,9 @@ describe("ItemHelper", () =>
_tpl: "5448fee04bdc2dbc018b4567", // "Bottle of water (0.6L)" _tpl: "5448fee04bdc2dbc018b4567", // "Bottle of water (0.6L)"
upd: { upd: {
FoodDrink: { FoodDrink: {
HpPercent: 30 // Not actually a percentage, but value of max 60. HpPercent: 30, // Not actually a percentage, but value of max 60.
} },
} },
}; };
const result = itemHelper.getItemQualityModifier(item); const result = itemHelper.getItemQualityModifier(item);
@ -524,9 +523,9 @@ describe("ItemHelper", () =>
_tpl: "5780cf7f2459777de4559322", // "Dorm room 314 marked key" _tpl: "5780cf7f2459777de4559322", // "Dorm room 314 marked key"
upd: { upd: {
Key: { Key: {
NumberOfUsages: 5 NumberOfUsages: 5,
} },
} },
}; };
const result = itemHelper.getItemQualityModifier(item); const result = itemHelper.getItemQualityModifier(item);
@ -543,9 +542,9 @@ describe("ItemHelper", () =>
upd: { upd: {
Resource: { Resource: {
Value: 50, // How much fuel is left in the tank. Value: 50, // How much fuel is left in the tank.
UnitsConsumed: 50 // How much fuel has been used in the generator. UnitsConsumed: 50, // How much fuel has been used in the generator.
} },
} },
}; };
const result = itemHelper.getItemQualityModifier(item); const result = itemHelper.getItemQualityModifier(item);
@ -561,9 +560,9 @@ describe("ItemHelper", () =>
_tpl: "591094e086f7747caa7bb2ef", // "Body armor repair kit" _tpl: "591094e086f7747caa7bb2ef", // "Body armor repair kit"
upd: { upd: {
RepairKit: { RepairKit: {
Resource: 600 Resource: 600,
} },
} },
}; };
const result = itemHelper.getItemQualityModifier(item); const result = itemHelper.getItemQualityModifier(item);
@ -579,9 +578,9 @@ describe("ItemHelper", () =>
_tpl: "591094e086f7747caa7bb2ef", // "Body armor repair kit" _tpl: "591094e086f7747caa7bb2ef", // "Body armor repair kit"
upd: { upd: {
RepairKit: { RepairKit: {
Resource: 0 Resource: 0,
} },
} },
}; };
const result = itemHelper.getItemQualityModifier(item); const result = itemHelper.getItemQualityModifier(item);
@ -597,11 +596,11 @@ describe("ItemHelper", () =>
const armor = itemHelper.getItem("5648a7494bdc2d9d488b4583")[1]; // "PACA Soft Armor" const armor = itemHelper.getItem("5648a7494bdc2d9d488b4583")[1]; // "PACA Soft Armor"
const repairable: Repairable = { const repairable: Repairable = {
Durability: 25, Durability: 25,
MaxDurability: 50 MaxDurability: 50,
}; };
const item: Item = { // Not used for armor, but required for the method. const item: Item = { // Not used for armor, but required for the method.
_id: "", _id: "",
_tpl: "" _tpl: "",
}; };
// Cast the method to any to allow access to private/protected method. // Cast the method to any to allow access to private/protected method.
@ -615,11 +614,11 @@ describe("ItemHelper", () =>
const armor = itemHelper.getItem("5648a7494bdc2d9d488b4583")[1]; // "PACA Soft Armor" const armor = itemHelper.getItem("5648a7494bdc2d9d488b4583")[1]; // "PACA Soft Armor"
const repairable: Repairable = { const repairable: Repairable = {
Durability: 25, Durability: 25,
MaxDurability: 1000 // This should be ignored. MaxDurability: 1000, // This should be ignored.
}; };
const item: Item = { // Not used for armor, but required for the method. const item: Item = { // Not used for armor, but required for the method.
_id: "", _id: "",
_tpl: "" _tpl: "",
}; };
// Cast the method to any to allow access to private/protected method. // Cast the method to any to allow access to private/protected method.
@ -633,11 +632,11 @@ describe("ItemHelper", () =>
const weapon = itemHelper.getItem("5a38e6bac4a2826c6e06d79b")[1]; // "TOZ-106 20ga bolt-action shotgun" const weapon = itemHelper.getItem("5a38e6bac4a2826c6e06d79b")[1]; // "TOZ-106 20ga bolt-action shotgun"
const repairable: Repairable = { const repairable: Repairable = {
Durability: 50, Durability: 50,
MaxDurability: 100 MaxDurability: 100,
}; };
const item: Item = { const item: Item = {
_id: "", _id: "",
_tpl: "" _tpl: "",
}; };
// Cast the method to any to allow access to private/protected method. // Cast the method to any to allow access to private/protected method.
@ -652,11 +651,11 @@ describe("ItemHelper", () =>
weapon._props.MaxDurability = undefined; // Remove the MaxDurability property. weapon._props.MaxDurability = undefined; // Remove the MaxDurability property.
const repairable: Repairable = { const repairable: Repairable = {
Durability: 50, Durability: 50,
MaxDurability: 200 // This should be used now. MaxDurability: 200, // This should be used now.
}; };
const item: Item = { const item: Item = {
_id: "", _id: "",
_tpl: "" _tpl: "",
}; };
// Cast the method to any to allow access to private/protected method. // Cast the method to any to allow access to private/protected method.
@ -671,11 +670,11 @@ describe("ItemHelper", () =>
weapon._props.MaxDurability = undefined; // Remove the MaxDurability property. weapon._props.MaxDurability = undefined; // Remove the MaxDurability property.
const repairable: Repairable = { const repairable: Repairable = {
Durability: 50, Durability: 50,
MaxDurability: undefined // Remove the MaxDurability property value... Technically an invalid Type. MaxDurability: undefined, // Remove the MaxDurability property value... Technically an invalid Type.
}; };
const item: Item = { const item: Item = {
_id: "", _id: "",
_tpl: "" _tpl: "",
}; };
// Mock the logger's error method to prevent it from being actually called. // Mock the logger's error method to prevent it from being actually called.
@ -695,11 +694,11 @@ describe("ItemHelper", () =>
weapon._props.MaxDurability = undefined; // Remove the MaxDurability property. weapon._props.MaxDurability = undefined; // Remove the MaxDurability property.
const repairable: Repairable = { const repairable: Repairable = {
Durability: 50, Durability: 50,
MaxDurability: 0 // This is a problem. MaxDurability: 0, // This is a problem.
}; };
const item: Item = { const item: Item = {
_id: "", _id: "",
_tpl: "" _tpl: "",
}; };
// Cast the method to any to allow access to private/protected method. // Cast the method to any to allow access to private/protected method.
@ -714,11 +713,11 @@ describe("ItemHelper", () =>
weapon._props.MaxDurability = undefined; // Remove the MaxDurability property. weapon._props.MaxDurability = undefined; // Remove the MaxDurability property.
const repairable: Repairable = { const repairable: Repairable = {
Durability: 50, Durability: 50,
MaxDurability: undefined // Remove the MaxDurability property value... Technically an invalid Type. MaxDurability: undefined, // Remove the MaxDurability property value... Technically an invalid Type.
}; };
const item: Item = { const item: Item = {
_id: "", _id: "",
_tpl: "" _tpl: "",
}; };
const loggerErrorSpy = vi.spyOn((itemHelper as any).logger, "error"); const loggerErrorSpy = vi.spyOn((itemHelper as any).logger, "error");
@ -737,7 +736,7 @@ describe("ItemHelper", () =>
const items: Item[] = [ const items: Item[] = [
{_id: "1", _tpl: "", parentId: null}, {_id: "1", _tpl: "", parentId: null},
{_id: "2", _tpl: "", parentId: null}, {_id: "2", _tpl: "", parentId: null},
{ _id: "3", _tpl: "", parentId: "2" } {_id: "3", _tpl: "", parentId: "2"},
]; ];
const result = itemHelper.findAndReturnChildrenByItems(items, "1"); const result = itemHelper.findAndReturnChildrenByItems(items, "1");
expect(result).toEqual(["1"]); expect(result).toEqual(["1"]);
@ -748,7 +747,7 @@ describe("ItemHelper", () =>
const items: Item[] = [ const items: Item[] = [
{_id: "1", _tpl: "", parentId: null}, {_id: "1", _tpl: "", parentId: null},
{_id: "2", _tpl: "", parentId: "1"}, {_id: "2", _tpl: "", parentId: "1"},
{ _id: "3", _tpl: "", parentId: "1" } {_id: "3", _tpl: "", parentId: "1"},
]; ];
const result = itemHelper.findAndReturnChildrenByItems(items, "1"); const result = itemHelper.findAndReturnChildrenByItems(items, "1");
expect(result).toEqual(["2", "3", "1"]); expect(result).toEqual(["2", "3", "1"]);
@ -760,7 +759,7 @@ describe("ItemHelper", () =>
{_id: "1", _tpl: "", parentId: null}, {_id: "1", _tpl: "", parentId: null},
{_id: "2", _tpl: "", parentId: "1"}, {_id: "2", _tpl: "", parentId: "1"},
{_id: "3", _tpl: "", parentId: "2"}, {_id: "3", _tpl: "", parentId: "2"},
{ _id: "4", _tpl: "", parentId: "3" } {_id: "4", _tpl: "", parentId: "3"},
]; ];
const result = itemHelper.findAndReturnChildrenByItems(items, "1"); const result = itemHelper.findAndReturnChildrenByItems(items, "1");
expect(result).toEqual(["4", "3", "2", "1"]); expect(result).toEqual(["4", "3", "2", "1"]);
@ -770,7 +769,7 @@ describe("ItemHelper", () =>
{ {
const items: Item[] = [ const items: Item[] = [
{_id: "1", _tpl: "", parentId: null}, {_id: "1", _tpl: "", parentId: null},
{ _id: "2", _tpl: "", parentId: "1" } {_id: "2", _tpl: "", parentId: "1"},
]; ];
const result = itemHelper.findAndReturnChildrenByItems(items, "3"); const result = itemHelper.findAndReturnChildrenByItems(items, "3");
expect(result).toEqual(["3"]); expect(result).toEqual(["3"]);
@ -785,7 +784,7 @@ describe("ItemHelper", () =>
const item: Item = { const item: Item = {
_id: itemId, _id: itemId,
_tpl: "591094e086f7747caa7bb2ef", // "Body armor repair kit" _tpl: "591094e086f7747caa7bb2ef", // "Body armor repair kit"
upd: {} upd: {},
}; };
const result = itemHelper.getItemStackSize(item); const result = itemHelper.getItemStackSize(item);
expect(result).toBe(1); expect(result).toBe(1);
@ -796,7 +795,7 @@ describe("ItemHelper", () =>
const itemId = container.resolve<HashUtil>("HashUtil").generate(); const itemId = container.resolve<HashUtil>("HashUtil").generate();
const item: Item = { const item: Item = {
_id: itemId, _id: itemId,
_tpl: "591094e086f7747caa7bb2ef" // "Body armor repair kit" _tpl: "591094e086f7747caa7bb2ef", // "Body armor repair kit"
}; };
const result = itemHelper.getItemStackSize(item); const result = itemHelper.getItemStackSize(item);
expect(result).toBe(1); expect(result).toBe(1);
@ -809,8 +808,8 @@ describe("ItemHelper", () =>
_id: itemId, _id: itemId,
_tpl: "591094e086f7747caa7bb2ef", // "Body armor repair kit" _tpl: "591094e086f7747caa7bb2ef", // "Body armor repair kit"
upd: { upd: {
StackObjectsCount: 5 StackObjectsCount: 5,
} },
}; };
const result = itemHelper.getItemStackSize(item); const result = itemHelper.getItemStackSize(item);
expect(result).toBe(5); expect(result).toBe(5);
@ -827,8 +826,8 @@ describe("ItemHelper", () =>
_tpl: "591094e086f7747caa7bb2ef", // "Body armor repair kit" _tpl: "591094e086f7747caa7bb2ef", // "Body armor repair kit"
upd: { upd: {
BuyRestrictionCurrent: 0, BuyRestrictionCurrent: 0,
BuyRestrictionMax: 1 BuyRestrictionMax: 1,
} },
}; };
const result = itemHelper.hasBuyRestrictions(item); const result = itemHelper.hasBuyRestrictions(item);
expect(result).toBe(true); expect(result).toBe(true);
@ -840,7 +839,7 @@ describe("ItemHelper", () =>
const item: Item = { const item: Item = {
_id: itemId, _id: itemId,
_tpl: "591094e086f7747caa7bb2ef", // "Body armor repair kit" _tpl: "591094e086f7747caa7bb2ef", // "Body armor repair kit"
upd: {} upd: {},
}; };
const result = itemHelper.hasBuyRestrictions(item); const result = itemHelper.hasBuyRestrictions(item);
expect(result).toBe(false); expect(result).toBe(false);
@ -851,7 +850,7 @@ describe("ItemHelper", () =>
const itemId = container.resolve<HashUtil>("HashUtil").generate(); const itemId = container.resolve<HashUtil>("HashUtil").generate();
const item: Item = { const item: Item = {
_id: itemId, _id: itemId,
_tpl: "591094e086f7747caa7bb2ef" // "Body armor repair kit" _tpl: "591094e086f7747caa7bb2ef", // "Body armor repair kit"
}; };
const result = itemHelper.hasBuyRestrictions(item); const result = itemHelper.hasBuyRestrictions(item);
expect(result).toBe(false); expect(result).toBe(false);
@ -886,7 +885,7 @@ describe("ItemHelper", () =>
const itemId = container.resolve<HashUtil>("HashUtil").generate(); const itemId = container.resolve<HashUtil>("HashUtil").generate();
const ammoBox: Item[] = [{ const ammoBox: Item[] = [{
_id: itemId, _id: itemId,
_tpl: "5c12619186f7743f871c8a32" // "9x39mm SPP gs ammo pack (8 pcs)" _tpl: "5c12619186f7743f871c8a32", // "9x39mm SPP gs ammo pack (8 pcs)"
}]; }];
const databaseServer = container.resolve<DatabaseServer>("DatabaseServer"); const databaseServer = container.resolve<DatabaseServer>("DatabaseServer");
@ -902,7 +901,7 @@ describe("ItemHelper", () =>
const itemId = container.resolve<HashUtil>("HashUtil").generate(); const itemId = container.resolve<HashUtil>("HashUtil").generate();
const ammoBox: Item[] = [{ const ammoBox: Item[] = [{
_id: itemId, _id: itemId,
_tpl: "5737292724597765e5728562" // "5.45x39mm BP gs ammo pack (120 pcs)"" _tpl: "5737292724597765e5728562", // "5.45x39mm BP gs ammo pack (120 pcs)""
}]; }];
const databaseServer = container.resolve<DatabaseServer>("DatabaseServer"); const databaseServer = container.resolve<DatabaseServer>("DatabaseServer");
@ -919,7 +918,7 @@ describe("ItemHelper", () =>
const itemId = container.resolve<HashUtil>("HashUtil").generate(); const itemId = container.resolve<HashUtil>("HashUtil").generate();
const ammoBox: Item[] = [{ const ammoBox: Item[] = [{
_id: itemId, _id: itemId,
_tpl: "5737292724597765e5728562" // "5.45x39mm BP gs ammo pack (120 pcs)"" _tpl: "5737292724597765e5728562", // "5.45x39mm BP gs ammo pack (120 pcs)""
}]; }];
const databaseServer = container.resolve<DatabaseServer>("DatabaseServer"); const databaseServer = container.resolve<DatabaseServer>("DatabaseServer");
@ -934,7 +933,7 @@ describe("ItemHelper", () =>
const itemId = container.resolve<HashUtil>("HashUtil").generate(); const itemId = container.resolve<HashUtil>("HashUtil").generate();
const ammoBox: Item[] = [{ const ammoBox: Item[] = [{
_id: itemId, _id: itemId,
_tpl: "5737292724597765e5728562" // "5.45x39mm BP gs ammo pack (120 pcs)"" _tpl: "5737292724597765e5728562", // "5.45x39mm BP gs ammo pack (120 pcs)""
}]; }];
const databaseServer = container.resolve<DatabaseServer>("DatabaseServer"); const databaseServer = container.resolve<DatabaseServer>("DatabaseServer");
@ -1015,8 +1014,8 @@ describe("ItemHelper", () =>
_id: container.resolve<HashUtil>("HashUtil").generate(), _id: container.resolve<HashUtil>("HashUtil").generate(),
_tpl: "59e690b686f7746c9f75e848", // m995 _tpl: "59e690b686f7746c9f75e848", // m995
upd: { upd: {
StackObjectsCount: 80 // Default is 60 StackObjectsCount: 80, // Default is 60
} },
}; };
const result = itemHelper.splitStack(stackableItem); // "Roubles" const result = itemHelper.splitStack(stackableItem); // "Roubles"
@ -1029,8 +1028,8 @@ describe("ItemHelper", () =>
_id: container.resolve<HashUtil>("HashUtil").generate(), _id: container.resolve<HashUtil>("HashUtil").generate(),
_tpl: "59e690b686f7746c9f75e848", // m995 _tpl: "59e690b686f7746c9f75e848", // m995
upd: { upd: {
StackObjectsCount: 80 // Default is 60 StackObjectsCount: 80, // Default is 60
} },
}; };
const result = itemHelper.splitStack(stackableItem); // "Roubles" const result = itemHelper.splitStack(stackableItem); // "Roubles"
const itemCount = result.reduce((sum, curr) => sum + curr.upd.StackObjectsCount, 0); const itemCount = result.reduce((sum, curr) => sum + curr.upd.StackObjectsCount, 0);
@ -1043,8 +1042,8 @@ describe("ItemHelper", () =>
_id: container.resolve<HashUtil>("HashUtil").generate(), _id: container.resolve<HashUtil>("HashUtil").generate(),
_tpl: "59e690b686f7746c9f75e848", // m995 _tpl: "59e690b686f7746c9f75e848", // m995
upd: { upd: {
StackObjectsCount: 60 // Default is 60 StackObjectsCount: 60, // Default is 60
} },
}; };
const result = itemHelper.splitStack(stackableItem); // "Roubles" const result = itemHelper.splitStack(stackableItem); // "Roubles"
const itemCount = result.reduce((sum, curr) => sum + curr.upd.StackObjectsCount, 0); const itemCount = result.reduce((sum, curr) => sum + curr.upd.StackObjectsCount, 0);
@ -1057,7 +1056,7 @@ describe("ItemHelper", () =>
const stackableItem: Item = { const stackableItem: Item = {
_id: container.resolve<HashUtil>("HashUtil").generate(), _id: container.resolve<HashUtil>("HashUtil").generate(),
_tpl: "59e690b686f7746c9f75e848", // m995 _tpl: "59e690b686f7746c9f75e848", // m995
upd: {} upd: {},
}; };
const result = itemHelper.splitStack(stackableItem); // "Roubles" const result = itemHelper.splitStack(stackableItem); // "Roubles"
expect(result.length).toBe(1); expect(result.length).toBe(1);
@ -1067,7 +1066,7 @@ describe("ItemHelper", () =>
{ {
const stackableItem: Item = { const stackableItem: Item = {
_id: container.resolve<HashUtil>("HashUtil").generate(), _id: container.resolve<HashUtil>("HashUtil").generate(),
_tpl: "59e690b686f7746c9f75e848" // m995 _tpl: "59e690b686f7746c9f75e848", // m995
}; };
const result = itemHelper.splitStack(stackableItem); // "Roubles" const result = itemHelper.splitStack(stackableItem); // "Roubles"
expect(result.length).toBe(1); expect(result.length).toBe(1);
@ -1085,7 +1084,7 @@ describe("ItemHelper", () =>
"5736026a245977644601dc61", "5736026a245977644601dc61",
"573603562459776430731618", "573603562459776430731618",
"573603c924597764442bd9cb", "573603c924597764442bd9cb",
"5735fdcd2459776445391d61" "5735fdcd2459776445391d61",
]; ];
const mockTemplateItem = { const mockTemplateItem = {
_id: "571a29dc2459771fb2755a6a", _id: "571a29dc2459771fb2755a6a",
@ -1094,11 +1093,11 @@ describe("ItemHelper", () =>
Cartridges: [{ Cartridges: [{
_props: { _props: {
filters: [{ filters: [{
Filter: validAmmoItems Filter: validAmmoItems,
}] }],
} },
}] }],
} },
}; };
vi.spyOn((itemHelper as any).randomUtil, "getArrayValue").mockReturnValue(validAmmoItems[0]); vi.spyOn((itemHelper as any).randomUtil, "getArrayValue").mockReturnValue(validAmmoItems[0]);
@ -1113,9 +1112,9 @@ describe("ItemHelper", () =>
const fakeTemplateItem = { const fakeTemplateItem = {
_props: { _props: {
Cartridges: [ Cartridges: [
{} {},
] ],
} },
}; };
const result = itemHelper.getRandomCompatibleCaliberTemplateId(fakeTemplateItem as ITemplateItem); const result = itemHelper.getRandomCompatibleCaliberTemplateId(fakeTemplateItem as ITemplateItem);

View File

@ -1,8 +1,8 @@
/* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable @typescript-eslint/naming-convention */
import "reflect-metadata"; import "reflect-metadata";
import { container } from "tsyringe";
import { vi, beforeEach, afterEach, describe, expect, it } from "vitest";
import { ItemBaseClassService } from "@spt-aki/services/ItemBaseClassService"; import { ItemBaseClassService } from "@spt-aki/services/ItemBaseClassService";
import { container } from "tsyringe";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
describe("ItemBaseClassService", () => describe("ItemBaseClassService", () =>
{ {
@ -64,7 +64,10 @@ describe("ItemBaseClassService", () =>
// Remove item from base cache // Remove item from base cache
delete itemBaseClassService.itemBaseClassesCache[salewaTpl]; delete itemBaseClassService.itemBaseClassesCache[salewaTpl];
const result = itemBaseClassService.itemHasBaseClass(salewaTpl, ["543be5664bdc2dd4348b4569", "54009119af1c881c07000029"]); // "Meds" and "Item" type const result = itemBaseClassService.itemHasBaseClass(salewaTpl, [
"543be5664bdc2dd4348b4569",
"54009119af1c881c07000029",
]); // "Meds" and "Item" type
expect(result).toBe(true); expect(result).toBe(true);
}); });

View File

@ -1,16 +1,16 @@
/* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable @typescript-eslint/naming-convention */
import "reflect-metadata"; import "reflect-metadata";
import { container } from "tsyringe"; import { container } from "tsyringe";
import { vi, beforeEach, afterEach, describe, expect, it } from "vitest"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { PaymentService } from "@spt-aki/services/PaymentService"; import { PaymentService } from "@spt-aki/services/PaymentService";
import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData";
import { IProcessBuyTradeRequestData } from "@spt-aki/models/eft/trade/IProcessBuyTradeRequestData";
import { IItemEventRouterResponse } from "@spt-aki/models/eft/itemEvent/IItemEventRouterResponse";
import { HashUtil } from "@spt-aki/utils/HashUtil";
import { ITraderBase } from "@spt-aki/models/eft/common/tables/ITrader";
import { Item } from "@spt-aki/models/eft/common/tables/IItem"; import { Item } from "@spt-aki/models/eft/common/tables/IItem";
import { ITraderBase } from "@spt-aki/models/eft/common/tables/ITrader";
import { IItemEventRouterResponse } from "@spt-aki/models/eft/itemEvent/IItemEventRouterResponse";
import { IProcessBuyTradeRequestData } from "@spt-aki/models/eft/trade/IProcessBuyTradeRequestData";
import { HashUtil } from "@spt-aki/utils/HashUtil";
describe("PaymentService", () => describe("PaymentService", () =>
{ {
@ -44,8 +44,8 @@ describe("PaymentService", () =>
_id: costItemId, _id: costItemId,
_tpl: costItemTpl, _tpl: costItemTpl,
upd: { upd: {
StackObjectsCount: costAmount * 4 // More than enough. StackObjectsCount: costAmount * 4, // More than enough.
} },
} as Item; } as Item;
// Object representing the player's PMC inventory. // Object representing the player's PMC inventory.
@ -54,12 +54,12 @@ describe("PaymentService", () =>
[traderId]: { [traderId]: {
salesSum: 0, salesSum: 0,
unlocked: true, unlocked: true,
disabled: false disabled: false,
} },
}, },
Inventory: { Inventory: {
items: [moneyItem] items: [moneyItem],
} },
} as unknown as IPmcData; } as unknown as IPmcData;
// Buy a factory map from Therapist... although it doesn't really matter what the item is as there's no // Buy a factory map from Therapist... although it doesn't really matter what the item is as there's no
@ -74,9 +74,9 @@ describe("PaymentService", () =>
scheme_items: [ scheme_items: [
{ {
id: costItemId, id: costItemId,
count: costAmount count: costAmount,
} },
] ],
} as IProcessBuyTradeRequestData; } as IProcessBuyTradeRequestData;
// Inconsequential profile ID // Inconsequential profile ID
@ -90,10 +90,10 @@ describe("PaymentService", () =>
items: { items: {
new: [], new: [],
change: [], change: [],
del: [] del: [],
} },
} },
} },
} as unknown as IItemEventRouterResponse; } as unknown as IItemEventRouterResponse;
// Mock the logger debug method to return void. // Mock the logger debug method to return void.
@ -101,13 +101,14 @@ describe("PaymentService", () =>
{}); {});
// Mock the trader helper to return a trader with the currency of Roubles. // Mock the trader helper to return a trader with the currency of Roubles.
const traderHelperGetTraderSpy = vi.spyOn((paymentService as any).traderHelper, "getTrader").mockReturnValue({ const traderHelperGetTraderSpy = vi.spyOn((paymentService as any).traderHelper, "getTrader")
.mockReturnValue({
tid: traderId, tid: traderId,
currency: "RUB" currency: "RUB",
} as unknown as ITraderBase); } as unknown as ITraderBase);
// Mock the addPaymentToOutput method to subtract the item cost from the money stack. // Mock the addPaymentToOutput method to subtract the item cost from the money stack.
const addPaymentToOutputSpy = vi.spyOn((paymentService as any), "addPaymentToOutput").mockImplementation(() => const addPaymentToOutputSpy = vi.spyOn(paymentService as any, "addPaymentToOutput").mockImplementation(() =>
{ {
moneyItem.upd.StackObjectsCount -= costAmount; moneyItem.upd.StackObjectsCount -= costAmount;
return { return {
@ -115,18 +116,25 @@ describe("PaymentService", () =>
profileChanges: { profileChanges: {
[sessionID]: { [sessionID]: {
items: { items: {
change: [moneyItem] change: [moneyItem],
} },
} },
} },
}; };
}); });
// Mock the traderHelper lvlUp method to return void. // Mock the traderHelper lvlUp method to return void.
const traderHelperLvlUpSpy = vi.spyOn((paymentService as any).traderHelper, "lvlUp").mockImplementation(() => const traderHelperLvlUpSpy = vi.spyOn((paymentService as any).traderHelper, "lvlUp").mockImplementation(
{}); () =>
{},
);
const output = paymentService.payMoney(pmcData, processBuyTradeRequestData, sessionID, itemEventRouterResponse); const output = paymentService.payMoney(
pmcData,
processBuyTradeRequestData,
sessionID,
itemEventRouterResponse,
);
// Check for absence of output warnings. // Check for absence of output warnings.
expect(output.warnings).toHaveLength(0); expect(output.warnings).toHaveLength(0);
@ -139,7 +147,13 @@ describe("PaymentService", () =>
// Check if mocked methods were called as expected. // Check if mocked methods were called as expected.
expect(traderHelperGetTraderSpy).toBeCalledTimes(1); expect(traderHelperGetTraderSpy).toBeCalledTimes(1);
expect(addPaymentToOutputSpy).toBeCalledWith(expect.anything(), costItemTpl, costAmount, sessionID, expect.anything()); expect(addPaymentToOutputSpy).toBeCalledWith(
expect.anything(),
costItemTpl,
costAmount,
sessionID,
expect.anything(),
);
expect(traderHelperLvlUpSpy).toBeCalledTimes(1); expect(traderHelperLvlUpSpy).toBeCalledTimes(1);
}); });
}); });
@ -151,14 +165,14 @@ describe("PaymentService", () =>
const hashUtil = container.resolve<HashUtil>("HashUtil"); const hashUtil = container.resolve<HashUtil>("HashUtil");
const stashItem: Item = { const stashItem: Item = {
_id: "stashid", _id: "stashid",
_tpl: "55d7217a4bdc2d86028b456d" // standard stash id _tpl: "55d7217a4bdc2d86028b456d", // standard stash id
}; };
const inventoryItemToFind: Item = { const inventoryItemToFind: Item = {
_id: hashUtil.generate(), _id: hashUtil.generate(),
_tpl: "544fb6cc4bdc2d34748b456e", // Slickers chocolate bar _tpl: "544fb6cc4bdc2d34748b456e", // Slickers chocolate bar
parentId: stashItem._id, parentId: stashItem._id,
slotId: "hideout" slotId: "hideout",
}; };
const playerInventory = [stashItem, inventoryItemToFind]; const playerInventory = [stashItem, inventoryItemToFind];
@ -172,20 +186,20 @@ describe("PaymentService", () =>
const hashUtil = container.resolve<HashUtil>("HashUtil"); const hashUtil = container.resolve<HashUtil>("HashUtil");
const stashItem: Item = { const stashItem: Item = {
_id: "stashId", _id: "stashId",
_tpl: "55d7217a4bdc2d86028b456d" // standard stash id _tpl: "55d7217a4bdc2d86028b456d", // standard stash id
}; };
const foodBagToHoldItemToFind: Item = { const foodBagToHoldItemToFind: Item = {
_id: hashUtil.generate(), _id: hashUtil.generate(),
_tpl: "5c093db286f7740a1b2617e3", _tpl: "5c093db286f7740a1b2617e3",
parentId: stashItem._id, parentId: stashItem._id,
slotId: "hideout" slotId: "hideout",
}; };
const inventoryItemToFind: Item = { const inventoryItemToFind: Item = {
_id: hashUtil.generate(), _id: hashUtil.generate(),
_tpl: "544fb6cc4bdc2d34748b456e", // Slickers chocolate bar _tpl: "544fb6cc4bdc2d34748b456e", // Slickers chocolate bar
parentId: foodBagToHoldItemToFind._id parentId: foodBagToHoldItemToFind._id,
}; };
const playerInventory = [stashItem, foodBagToHoldItemToFind, inventoryItemToFind]; const playerInventory = [stashItem, foodBagToHoldItemToFind, inventoryItemToFind];
@ -199,14 +213,14 @@ describe("PaymentService", () =>
const hashUtil = container.resolve<HashUtil>("HashUtil"); const hashUtil = container.resolve<HashUtil>("HashUtil");
const stashItem: Item = { const stashItem: Item = {
_id: "stashId", _id: "stashId",
_tpl: "55d7217a4bdc2d86028b456d" // standard stash id _tpl: "55d7217a4bdc2d86028b456d", // standard stash id
}; };
const inventoryItemToFind: Item = { const inventoryItemToFind: Item = {
_id: hashUtil.generate(), _id: hashUtil.generate(),
_tpl: "544fb6cc4bdc2d34748b456e", // Slickers chocolate bar _tpl: "544fb6cc4bdc2d34748b456e", // Slickers chocolate bar
parentId: stashItem._id, parentId: stashItem._id,
slotId: "hideout" slotId: "hideout",
}; };
const playerInventory = [stashItem, inventoryItemToFind]; const playerInventory = [stashItem, inventoryItemToFind];
@ -220,14 +234,14 @@ describe("PaymentService", () =>
const hashUtil = container.resolve<HashUtil>("HashUtil"); const hashUtil = container.resolve<HashUtil>("HashUtil");
const stashItem: Item = { const stashItem: Item = {
_id: "stashId", _id: "stashId",
_tpl: "55d7217a4bdc2d86028b456d" // standard stash id _tpl: "55d7217a4bdc2d86028b456d", // standard stash id
}; };
const inventoryItemToFind: Item = { const inventoryItemToFind: Item = {
_id: hashUtil.generate(), _id: hashUtil.generate(),
_tpl: "544fb6cc4bdc2d34748b456e", // Slickers chocolate bar _tpl: "544fb6cc4bdc2d34748b456e", // Slickers chocolate bar
parentId: stashItem._id, parentId: stashItem._id,
slotId: "hideout" slotId: "hideout",
}; };
const playerInventory = [inventoryItemToFind]; const playerInventory = [inventoryItemToFind];

View File

@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable @typescript-eslint/naming-convention */
import "reflect-metadata"; import "reflect-metadata";
import { container } from "tsyringe"; import { container } from "tsyringe";
import { vi, beforeEach, afterEach, describe, expect, it } from "vitest"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { IPmcData } from "@spt-aki/models/eft/common/IPmcData"; import { IPmcData } from "@spt-aki/models/eft/common/IPmcData";
import { PlayerService } from "@spt-aki/services/PlayerService"; import { PlayerService } from "@spt-aki/services/PlayerService";
@ -26,8 +26,8 @@ describe("PlayerService", () =>
{ {
const playerProfile = { const playerProfile = {
Info: { Info: {
Experience: 0 // Via wiki: https://escapefromtarkov.fandom.com/wiki/Character_skills#Levels Experience: 0, // Via wiki: https://escapefromtarkov.fandom.com/wiki/Character_skills#Levels
} },
}; };
const result = playerService.calculateLevel(playerProfile as IPmcData); const result = playerService.calculateLevel(playerProfile as IPmcData);
@ -39,8 +39,8 @@ describe("PlayerService", () =>
{ {
const playerProfile = { const playerProfile = {
Info: { Info: {
Experience: 999 // Via wiki: https://escapefromtarkov.fandom.com/wiki/Character_skills#Levels Experience: 999, // Via wiki: https://escapefromtarkov.fandom.com/wiki/Character_skills#Levels
} },
}; };
const result = playerService.calculateLevel(playerProfile as IPmcData); const result = playerService.calculateLevel(playerProfile as IPmcData);
@ -52,8 +52,8 @@ describe("PlayerService", () =>
{ {
const playerProfile = { const playerProfile = {
Info: { Info: {
Experience: 609066 // Via wiki: https://escapefromtarkov.fandom.com/wiki/Character_skills#Levels Experience: 609066, // Via wiki: https://escapefromtarkov.fandom.com/wiki/Character_skills#Levels
} },
}; };
const result = playerService.calculateLevel(playerProfile as IPmcData); const result = playerService.calculateLevel(playerProfile as IPmcData);
@ -65,8 +65,8 @@ describe("PlayerService", () =>
{ {
const playerProfile = { const playerProfile = {
Info: { Info: {
Experience: 68206066 // Via wiki: https://escapefromtarkov.fandom.com/wiki/Character_skills#Levels Experience: 68206066, // Via wiki: https://escapefromtarkov.fandom.com/wiki/Character_skills#Levels
} },
}; };
const result = playerService.calculateLevel(playerProfile as IPmcData); const result = playerService.calculateLevel(playerProfile as IPmcData);

View File

@ -1,6 +1,6 @@
import "reflect-metadata"; import "reflect-metadata";
import { container } from "tsyringe"; import { container } from "tsyringe";
import { vi, afterEach, describe, expect, it, beforeEach } from "vitest"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { TimeUtil } from "@spt-aki/utils/TimeUtil"; import { TimeUtil } from "@spt-aki/utils/TimeUtil";