Formatting Change - When a statement can be moved into a single line and still be under the maximum line length, it is.

This commit is contained in:
Refringe 2023-11-13 12:31:52 -05:00
parent 7533d33358
commit 32b47bdc18
No known key found for this signature in database
GPG Key ID: 64E03E5F892C6F9E
173 changed files with 2320 additions and 4501 deletions

View File

@ -15,7 +15,7 @@
"trailingCommas": "onlyMultiLine", "trailingCommas": "onlyMultiLine",
"operatorPosition": "nextLine", "operatorPosition": "nextLine",
"preferHanging": false, "preferHanging": false,
"preferSingleLine": false, "preferSingleLine": true,
"arrowFunction.useParentheses": "force", "arrowFunction.useParentheses": "force",
"binaryExpression.linePerExpression": false, "binaryExpression.linePerExpression": false,
"memberExpression.linePerExpression": false, "memberExpression.linePerExpression": false,

View File

@ -74,15 +74,12 @@ const updateBuildProperties = async () =>
const vi = ResEdit.Resource.VersionInfo.fromEntries(res.entries)[0]; const vi = ResEdit.Resource.VersionInfo.fromEntries(res.entries)[0];
vi.setStringValues( vi.setStringValues({lang: 1033, codepage: 1200}, {
{lang: 1033, codepage: 1200}, ProductName: manifest.author,
{ FileDescription: manifest.description,
ProductName: manifest.author, CompanyName: manifest.name,
FileDescription: manifest.description, LegalCopyright: manifest.license,
CompanyName: manifest.name, });
LegalCopyright: manifest.license,
},
);
vi.removeStringValue({lang: 1033, codepage: 1200}, "OriginalFilename"); vi.removeStringValue({lang: 1033, codepage: 1200}, "OriginalFilename");
vi.removeStringValue({lang: 1033, codepage: 1200}, "InternalName"); vi.removeStringValue({lang: 1033, codepage: 1200}, "InternalName");
vi.setFileVersion(...manifest.version.split(".").map(Number)); vi.setFileVersion(...manifest.version.split(".").map(Number));

View File

@ -12,10 +12,7 @@ export class ErrorHandler
constructor() constructor()
{ {
this.logger = new WinstonMainLogger(new AsyncQueue()); this.logger = new WinstonMainLogger(new AsyncQueue());
this.readLine = readline.createInterface({ this.readLine = readline.createInterface({input: process.stdin, output: process.stdout});
input: process.stdin,
output: process.stdout,
});
} }
public handleCriticalError(err: Error): void public handleCriticalError(err: Error): void

View File

@ -28,10 +28,7 @@ export class CustomizationCallbacks
*/ */
public getSuits(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData<IGetSuitsResponse> public getSuits(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData<IGetSuitsResponse>
{ {
const result: IGetSuitsResponse = { const result: IGetSuitsResponse = {_id: `pmc${sessionID}`, suites: this.saveServer.getProfile(sessionID).suits};
_id: `pmc${sessionID}`,
suites: this.saveServer.getProfile(sessionID).suits,
};
return this.httpResponse.getBody(result); return this.httpResponse.getBody(result);
} }

View File

@ -75,12 +75,7 @@ export class DialogueCallbacks implements OnUpdate
VersionId: "bgkidft87ddd", // TODO: Is this... correct? VersionId: "bgkidft87ddd", // TODO: Is this... correct?
Ip: "", Ip: "",
Port: 0, Port: 0,
Chats: [ Chats: [{_id: "0", Members: 0}],
{
_id: "0",
Members: 0,
},
],
}; };
return this.httpResponse.getBody([chatServer]); return this.httpResponse.getBody([chatServer]);

View File

@ -58,9 +58,7 @@ export class GameCallbacks implements OnLoad
const today = new Date().toUTCString(); const today = new Date().toUTCString();
const startTimeStampMS = Date.parse(today); const startTimeStampMS = Date.parse(today);
this.gameController.gameStart(url, info, sessionID, startTimeStampMS); this.gameController.gameStart(url, info, sessionID, startTimeStampMS);
return this.httpResponse.getBody({ return this.httpResponse.getBody({utc_time: startTimeStampMS / 1000});
utc_time: startTimeStampMS / 1000,
});
} }
/** /**
@ -75,9 +73,7 @@ export class GameCallbacks implements OnLoad
): IGetBodyResponseData<IGameLogoutResponseData> ): IGetBodyResponseData<IGameLogoutResponseData>
{ {
this.saveServer.save(); this.saveServer.save();
return this.httpResponse.getBody({ return this.httpResponse.getBody({status: "ok"});
status: "ok",
});
} }
/** /**
@ -144,9 +140,7 @@ export class GameCallbacks implements OnLoad
*/ */
public getVersion(url: string, info: IEmptyRequestData, sessionID: string): string public getVersion(url: string, info: IEmptyRequestData, sessionID: string): string
{ {
return this.httpResponse.noBody({ return this.httpResponse.noBody({Version: this.watermark.getInGameVersionLabel()});
Version: this.watermark.getInGameVersionLabel(),
});
} }
public reportNickname(url: string, info: IReportNicknameRequestData, sessionID: string): INullResponseData public reportNickname(url: string, info: IReportNicknameRequestData, sessionID: string): INullResponseData

View File

@ -6,9 +6,7 @@ import { OnLoad } from "@spt-aki/di/OnLoad";
@injectable() @injectable()
export class HandbookCallbacks implements OnLoad export class HandbookCallbacks implements OnLoad
{ {
constructor( constructor(@inject("HandbookController") protected handbookController: HandbookController)
@inject("HandbookController") protected handbookController: HandbookController,
)
{} {}
public async onLoad(): Promise<void> public async onLoad(): Promise<void>

View File

@ -44,11 +44,7 @@ export class HealthCallbacks
*/ */
public handleWorkoutEffects(url: string, info: IWorkoutData, sessionID: string): IGetBodyResponseData<string> public handleWorkoutEffects(url: string, info: IWorkoutData, sessionID: string): IGetBodyResponseData<string>
{ {
this.healthController.applyWorkoutChanges( this.healthController.applyWorkoutChanges(this.profileHelper.getPmcProfile(sessionID), info, sessionID);
this.profileHelper.getPmcProfile(sessionID),
info,
sessionID,
);
return this.httpResponse.emptyResponse(); return this.httpResponse.emptyResponse();
} }

View File

@ -6,9 +6,7 @@ import { HttpServer } from "@spt-aki/servers/HttpServer";
@injectable() @injectable()
export class HttpCallbacks implements OnLoad export class HttpCallbacks implements OnLoad
{ {
constructor( constructor(@inject("HttpServer") protected httpServer: HttpServer)
@inject("HttpServer") protected httpServer: HttpServer,
)
{} {}
public async onLoad(): Promise<void> public async onLoad(): Promise<void>

View File

@ -24,9 +24,7 @@ import { IItemEventRouterResponse } from "@spt-aki/models/eft/itemEvent/IItemEve
@injectable() @injectable()
export class InventoryCallbacks export class InventoryCallbacks
{ {
constructor( constructor(@inject("InventoryController") protected inventoryController: InventoryController)
@inject("InventoryController") protected inventoryController: InventoryController,
)
{} {}
/** Handle Move event */ /** Handle Move event */

View File

@ -8,9 +8,7 @@ import { INoteActionData } from "@spt-aki/models/eft/notes/INoteActionData";
@injectable() @injectable()
export class NoteCallbacks export class NoteCallbacks
{ {
constructor( constructor(@inject("NoteController") protected noteController: NoteController)
@inject("NoteController") protected noteController: NoteController,
)
{} {}
/** Handle AddNote event */ /** Handle AddNote event */

View File

@ -36,9 +36,9 @@ export class NotifierCallbacks
* Take our array of JSON message objects and cast them to JSON strings, so that they can then * Take our array of JSON message objects and cast them to JSON strings, so that they can then
* be sent to client as NEWLINE separated strings... yup. * be sent to client as NEWLINE separated strings... yup.
*/ */
this.notifierController.notifyAsync(tmpSessionID) this.notifierController.notifyAsync(tmpSessionID).then((messages: any) =>
.then((messages: any) => messages.map((message: any) => this.jsonUtil.serialize(message)).join("\n")) messages.map((message: any) => this.jsonUtil.serialize(message)).join("\n")
.then((text) => this.httpServerHelper.sendTextJson(resp, text)); ).then((text) => this.httpServerHelper.sendTextJson(resp, text));
} }
/** Handle push/notifier/get */ /** Handle push/notifier/get */
@ -68,9 +68,7 @@ export class NotifierCallbacks
sessionID: string, sessionID: string,
): IGetBodyResponseData<ISelectProfileResponse> ): IGetBodyResponseData<ISelectProfileResponse>
{ {
return this.httpResponse.getBody({ return this.httpResponse.getBody({status: "ok"});
status: "ok",
});
} }
public notify(url: string, info: any, sessionID: string): string public notify(url: string, info: any, sessionID: string): string

View File

@ -6,9 +6,7 @@ import { OnLoad } from "@spt-aki/di/OnLoad";
@injectable() @injectable()
export class PresetCallbacks implements OnLoad export class PresetCallbacks implements OnLoad
{ {
constructor( constructor(@inject("PresetController") protected presetController: PresetController)
@inject("PresetController") protected presetController: PresetController,
)
{} {}
public async onLoad(): Promise<void> public async onLoad(): Promise<void>

View File

@ -91,10 +91,7 @@ export class ProfileCallbacks
return this.httpResponse.getBody(null, 1, "The nickname is too short"); return this.httpResponse.getBody(null, 1, "The nickname is too short");
} }
return this.httpResponse.getBody({ return this.httpResponse.getBody({status: 0, nicknamechangedate: this.timeUtil.getTimestamp()});
status: 0,
nicknamechangedate: this.timeUtil.getTimestamp(),
});
} }
/** /**
@ -141,29 +138,19 @@ export class ProfileCallbacks
{ {
const response: GetProfileStatusResponseData = { const response: GetProfileStatusResponseData = {
maxPveCountExceeded: false, maxPveCountExceeded: false,
profiles: [ profiles: [{
{ profileid: `scav${sessionID}`,
profileid: `scav${sessionID}`, profileToken: null,
profileToken: null, status: "Free",
status: "Free", sid: "",
sid: "", ip: "",
ip: "", port: 0,
port: 0, version: "live",
version: "live", location: "bigmap",
location: "bigmap", raidMode: "Online",
raidMode: "Online", mode: "deathmatch",
mode: "deathmatch", shortId: "xxx1x1",
shortId: "xxx1x1", }, {profileid: `pmc${sessionID}`, profileToken: null, status: "Free", sid: "", ip: "", port: 0}],
},
{
profileid: `pmc${sessionID}`,
profileToken: null,
status: "Free",
sid: "",
ip: "",
port: 0,
},
],
}; };
return this.httpResponse.getBody(response); return this.httpResponse.getBody(response);

View File

@ -9,9 +9,7 @@ import { ITraderRepairActionDataRequest } from "@spt-aki/models/eft/repair/ITrad
@injectable() @injectable()
export class RepairCallbacks export class RepairCallbacks
{ {
constructor( constructor(@inject("RepairController") protected repairController: RepairController)
@inject("RepairController") protected repairController: RepairController,
)
{} {}
/** /**

View File

@ -10,9 +10,7 @@ import { ISellScavItemsToFenceRequestData } from "@spt-aki/models/eft/trade/ISel
@injectable() @injectable()
export class TradeCallbacks export class TradeCallbacks
{ {
constructor( constructor(@inject("TradeController") protected tradeController: TradeController)
@inject("TradeController") protected tradeController: TradeController,
)
{} {}
/** /**

View File

@ -8,9 +8,7 @@ import { IWishlistActionData } from "@spt-aki/models/eft/wishlist/IWishlistActio
@injectable() @injectable()
export class WishlistCallbacks export class WishlistCallbacks
{ {
constructor( constructor(@inject("WishlistController") protected wishlistController: WishlistController)
@inject("WishlistController") protected wishlistController: WishlistController,
)
{} {}
/** Handle AddToWishList event */ /** Handle AddToWishList event */

View File

@ -57,11 +57,7 @@ export class BotController
*/ */
public getBotPresetGenerationLimit(type: string): number public getBotPresetGenerationLimit(type: string): number
{ {
const value = this.botConfig.presetBatch[ const value = this.botConfig.presetBatch[(type === "assaultGroup") ? "assault" : type];
(type === "assaultGroup")
? "assault"
: type
];
if (!value) if (!value)
{ {
@ -275,9 +271,7 @@ export class BotController
this.logger.warning(this.localisationService.getText("bot-missing_saved_match_info")); this.logger.warning(this.localisationService.getText("bot-missing_saved_match_info"));
} }
const mapName = raidConfig const mapName = raidConfig ? raidConfig.location : defaultMapCapId;
? raidConfig.location
: defaultMapCapId;
let botCap = this.botConfig.maxBotCap[mapName.toLowerCase()]; let botCap = this.botConfig.maxBotCap[mapName.toLowerCase()];
if (!botCap) if (!botCap)
@ -296,9 +290,6 @@ export class BotController
public getAiBotBrainTypes(): any public getAiBotBrainTypes(): any
{ {
return { return {pmc: this.pmcConfig.pmcType, assault: this.botConfig.assaultBrainType};
pmc: this.pmcConfig.pmcType,
assault: this.botConfig.assaultBrainType,
};
} }
} }

View File

@ -8,9 +8,7 @@ import { inject, injectable } from "tsyringe";
@injectable() @injectable()
export class ClientLogController export class ClientLogController
{ {
constructor( constructor(@inject("WinstonLogger") protected logger: ILogger)
@inject("WinstonLogger") protected logger: ILogger,
)
{} {}
/** /**

View File

@ -60,11 +60,7 @@ export class DialogueController
public getFriendList(sessionID: string): IGetFriendListDataResponse public getFriendList(sessionID: string): IGetFriendListDataResponse
{ {
// Force a fake friend called SPT into friend list // Force a fake friend called SPT into friend list
return { return {Friends: [this.getSptFriendData()], Ignore: [], InIgnoreList: []};
Friends: [this.getSptFriendData()],
Ignore: [],
InIgnoreList: [],
};
} }
/** /**

View File

@ -435,10 +435,7 @@ export class GameController
*/ */
public getServer(sessionId: string): IServerDetails[] public getServer(sessionId: string): IServerDetails[]
{ {
return [{ return [{ip: this.httpConfig.ip, port: this.httpConfig.port}];
ip: this.httpConfig.ip,
port: this.httpConfig.port,
}];
} }
/** /**
@ -446,9 +443,7 @@ export class GameController
*/ */
public getCurrentGroup(sessionId: string): ICurrentGroupResponse public getCurrentGroup(sessionId: string): ICurrentGroupResponse
{ {
return { return {squad: []};
squad: [],
};
} }
/** /**
@ -456,10 +451,7 @@ export class GameController
*/ */
public getValidGameVersion(sessionId: string): ICheckVersionResponse public getValidGameVersion(sessionId: string): ICheckVersionResponse
{ {
return { return {isvalid: true, latestVersion: this.coreConfig.compatibleTarkovVersion};
isvalid: true,
latestVersion: this.coreConfig.compatibleTarkovVersion,
};
} }
/** /**
@ -467,10 +459,7 @@ export class GameController
*/ */
public getKeepAlive(sessionId: string): IGameKeepAliveResponse public getKeepAlive(sessionId: string): IGameKeepAliveResponse
{ {
return { return {msg: "OK", utc_time: new Date().getTime() / 1000};
msg: "OK",
utc_time: new Date().getTime() / 1000,
};
} }
/** /**
@ -777,9 +766,7 @@ export class GameController
const modDetails = activeMods[modKey]; const modDetails = activeMods[modKey];
if ( if (
fullProfile.aki.mods.some((x) => fullProfile.aki.mods.some((x) =>
x.author === modDetails.author x.author === modDetails.author && x.name === modDetails.name && x.version === modDetails.version
&& x.name === modDetails.name
&& x.version === modDetails.version
) )
) )
{ {

View File

@ -93,10 +93,7 @@ export class HideoutController
const items = request.items.map((reqItem) => const items = request.items.map((reqItem) =>
{ {
const item = pmcData.Inventory.items.find((invItem) => invItem._id === reqItem.id); const item = pmcData.Inventory.items.find((invItem) => invItem._id === reqItem.id);
return { return {inventoryItem: item, requestedItem: reqItem};
inventoryItem: item,
requestedItem: reqItem,
};
}); });
// If it's not money, its construction / barter items // If it's not money, its construction / barter items
@ -375,11 +372,7 @@ export class HideoutController
const itemsToAdd = Object.entries(addItemToHideoutRequest.items).map((kvp) => const itemsToAdd = Object.entries(addItemToHideoutRequest.items).map((kvp) =>
{ {
const item = pmcData.Inventory.items.find((invItem) => invItem._id === kvp[1].id); const item = pmcData.Inventory.items.find((invItem) => invItem._id === kvp[1].id);
return { return {inventoryItem: item, requestedItem: kvp[1], slot: kvp[0]};
inventoryItem: item,
requestedItem: kvp[1],
slot: kvp[0],
};
}); });
const hideoutArea = pmcData.Hideout.Areas.find((area) => area.type === addItemToHideoutRequest.areaType); const hideoutArea = pmcData.Hideout.Areas.find((area) => area.type === addItemToHideoutRequest.areaType);
@ -631,10 +624,7 @@ export class HideoutController
return this.httpResponse.appendErrorToOutput(output); return this.httpResponse.appendErrorToOutput(output);
} }
if ( if (inventoryItem.upd?.StackObjectsCount && inventoryItem.upd.StackObjectsCount > requestedItem.count)
inventoryItem.upd?.StackObjectsCount
&& inventoryItem.upd.StackObjectsCount > requestedItem.count
)
{ {
inventoryItem.upd.StackObjectsCount -= requestedItem.count; inventoryItem.upd.StackObjectsCount -= requestedItem.count;
} }
@ -693,9 +683,7 @@ export class HideoutController
*/ */
protected addScavCaseRewardsToProfile(pmcData: IPmcData, rewards: Product[], recipeId: string): void protected addScavCaseRewardsToProfile(pmcData: IPmcData, rewards: Product[], recipeId: string): void
{ {
pmcData.Hideout.Production[`ScavCase${recipeId}`] = { pmcData.Hideout.Production[`ScavCase${recipeId}`] = {Products: rewards};
Products: rewards,
};
} }
/** /**
@ -799,13 +787,7 @@ export class HideoutController
id = this.presetHelper.getDefaultPreset(id)._id; id = this.presetHelper.getDefaultPreset(id)._id;
} }
const newReq = { const newReq = {items: [{item_id: id, count: recipe.count}], tid: "ragfair"};
items: [{
item_id: id,
count: recipe.count,
}],
tid: "ragfair",
};
const entries = Object.entries(pmcData.Hideout.Production); const entries = Object.entries(pmcData.Hideout.Production);
let prodId: string; let prodId: string;
@ -889,9 +871,7 @@ export class HideoutController
// Handle the isEncoded flag from recipe // Handle the isEncoded flag from recipe
if (recipe.isEncoded) if (recipe.isEncoded)
{ {
const upd: Upd = { const upd: Upd = {RecodableComponent: {IsEncoded: true}};
RecodableComponent: {IsEncoded: true},
};
return this.inventoryHelper.addItem(pmcData, newReq, output, sessionID, callback, true, upd); return this.inventoryHelper.addItem(pmcData, newReq, output, sessionID, callback, true, upd);
} }
@ -957,18 +937,13 @@ export class HideoutController
{ {
id = this.presetHelper.getDefaultPreset(id)._id; id = this.presetHelper.getDefaultPreset(id)._id;
} }
const numOfItems = !x.upd?.StackObjectsCount const numOfItems = !x.upd?.StackObjectsCount ? 1 : x.upd.StackObjectsCount;
? 1
: x.upd.StackObjectsCount;
return {item_id: id, count: numOfItems}; return {item_id: id, count: numOfItems};
}, },
); );
const newReq = { const newReq = {items: itemsToAdd, tid: "ragfair"};
items: itemsToAdd,
tid: "ragfair",
};
const callback = () => const callback = () =>
{ {
@ -1060,10 +1035,7 @@ export class HideoutController
// Check if counter exists, add placeholder if it doesn't // Check if counter exists, add placeholder if it doesn't
if (!pmcData.Stats.Eft.OverallCounters.Items.find((x) => x.Key.includes("ShootingRangePoints"))) if (!pmcData.Stats.Eft.OverallCounters.Items.find((x) => x.Key.includes("ShootingRangePoints")))
{ {
pmcData.Stats.Eft.OverallCounters.Items.push({ pmcData.Stats.Eft.OverallCounters.Items.push({Key: ["ShootingRangePoints"], Value: 0});
Key: ["ShootingRangePoints"],
Value: 0,
});
} }
// Find counter by key and update value // Find counter by key and update value
@ -1094,10 +1066,7 @@ export class HideoutController
const items = request.items.map((reqItem) => const items = request.items.map((reqItem) =>
{ {
const item = pmcData.Inventory.items.find((invItem) => invItem._id === reqItem.id); const item = pmcData.Inventory.items.find((invItem) => invItem._id === reqItem.id);
return { return {inventoryItem: item, requestedItem: reqItem};
inventoryItem: item,
requestedItem: reqItem,
};
}); });
// If it's not money, its construction / barter items // If it's not money, its construction / barter items

View File

@ -625,10 +625,7 @@ export class InsuranceController
// add items to InsuredItems list once money has been paid // add items to InsuredItems list once money has been paid
for (const key of body.items) for (const key of body.items)
{ {
pmcData.InsuredItems.push({ pmcData.InsuredItems.push({tid: body.tid, itemId: inventoryItemsHash[key]._id});
tid: body.tid,
itemId: inventoryItemsHash[key]._id,
});
} }
this.profileHelper.addSkillPointsToPlayer(pmcData, SkillTypes.CHARISMA, itemsToInsureCount * 0.01); this.profileHelper.addSkillPointsToPlayer(pmcData, SkillTypes.CHARISMA, itemsToInsureCount * 0.01);

View File

@ -287,9 +287,7 @@ export class InventoryController
if (!sourceItem.upd) if (!sourceItem.upd)
{ {
sourceItem.upd = { sourceItem.upd = {StackObjectsCount: 1};
StackObjectsCount: 1,
};
} }
else if (!sourceItem.upd.StackObjectsCount) else if (!sourceItem.upd.StackObjectsCount)
{ {
@ -458,11 +456,7 @@ export class InventoryController
public foldItem(pmcData: IPmcData, body: IInventoryFoldRequestData, sessionID: string): IItemEventRouterResponse public foldItem(pmcData: IPmcData, body: IInventoryFoldRequestData, sessionID: string): IItemEventRouterResponse
{ {
// Fix for folding weapons while on they're in the Scav inventory // Fix for folding weapons while on they're in the Scav inventory
if ( if (body.fromOwner && body.fromOwner.type === "Profile" && body.fromOwner.id !== pmcData._id)
body.fromOwner
&& body.fromOwner.type === "Profile"
&& body.fromOwner.id !== pmcData._id
)
{ {
pmcData = this.profileHelper.getScavProfile(sessionID); pmcData = this.profileHelper.getScavProfile(sessionID);
} }
@ -476,10 +470,7 @@ export class InventoryController
} }
} }
return { return {warnings: [], profileChanges: {}};
warnings: [],
profileChanges: {},
};
} }
/** /**
@ -519,10 +510,7 @@ export class InventoryController
); );
} }
return { return {warnings: [], profileChanges: {}};
warnings: [],
profileChanges: {},
};
} }
/** /**
@ -551,10 +539,7 @@ export class InventoryController
} }
} }
return { return {warnings: [], profileChanges: {}};
warnings: [],
profileChanges: {},
};
} }
/** /**
@ -872,10 +857,7 @@ export class InventoryController
const containerDetails = this.itemHelper.getItem(openedItem._tpl); const containerDetails = this.itemHelper.getItem(openedItem._tpl);
const isSealedWeaponBox = containerDetails[1]._name.includes("event_container_airdrop"); const isSealedWeaponBox = containerDetails[1]._name.includes("event_container_airdrop");
const newItemRequest: IAddItemRequestData = { const newItemRequest: IAddItemRequestData = {tid: "RandomLootContainer", items: []};
tid: "RandomLootContainer",
items: [],
};
let foundInRaid = false; let foundInRaid = false;
if (isSealedWeaponBox) if (isSealedWeaponBox)

View File

@ -135,10 +135,7 @@ export class LocationController
locations[mapBase._Id] = mapBase; locations[mapBase._Id] = mapBase;
} }
return { return {locations: locations, paths: locationsFromDb.base.paths};
locations: locations,
paths: locationsFromDb.base.paths,
};
} }
/** /**

View File

@ -101,10 +101,7 @@ export class MatchController
/** Handle match/group/start_game */ /** Handle match/group/start_game */
public joinMatch(info: IJoinMatchRequestData, sessionId: string): IJoinMatchResult public joinMatch(info: IJoinMatchRequestData, sessionId: string): IJoinMatchResult
{ {
const output: IJoinMatchResult = { const output: IJoinMatchResult = {maxPveCountExceeded: false, profiles: []};
maxPveCountExceeded: false,
profiles: [],
};
// get list of players joining into the match // get list of players joining into the match
output.profiles.push({ output.profiles.push({
@ -128,10 +125,7 @@ export class MatchController
/** Handle client/match/group/status */ /** Handle client/match/group/status */
public getGroupStatus(info: IGetGroupStatusRequestData): any public getGroupStatus(info: IGetGroupStatusRequestData): any
{ {
return { return {players: [], maxPveCountExceeded: false};
players: [],
maxPveCountExceeded: false,
};
} }
/** /**
@ -226,18 +220,13 @@ export class MatchController
const parentId = this.hashUtil.generate(); const parentId = this.hashUtil.generate();
for (const item of loot) for (const item of loot)
{ {
mailableLoot.push( mailableLoot.push({
{ _id: item.id,
_id: item.id, _tpl: item.tpl,
_tpl: item.tpl, slotId: "main",
slotId: "main", parentId: parentId,
parentId: parentId, upd: {StackObjectsCount: item.stackCount, SpawnedInSession: true},
upd: { });
StackObjectsCount: item.stackCount,
SpawnedInSession: true,
},
},
);
} }
// Send message from fence giving player reward generated above // Send message from fence giving player reward generated above

View File

@ -9,17 +9,12 @@ import { EventOutputHolder } from "@spt-aki/routers/EventOutputHolder";
@injectable() @injectable()
export class NoteController export class NoteController
{ {
constructor( constructor(@inject("EventOutputHolder") protected eventOutputHolder: EventOutputHolder)
@inject("EventOutputHolder") protected eventOutputHolder: EventOutputHolder,
)
{} {}
public addNote(pmcData: IPmcData, body: INoteActionData, sessionID: string): IItemEventRouterResponse public addNote(pmcData: IPmcData, body: INoteActionData, sessionID: string): IItemEventRouterResponse
{ {
const newNote: Note = { const newNote: Note = {Time: body.note.Time, Text: body.note.Text};
Time: body.note.Time,
Text: body.note.Text,
};
pmcData.Notes.Notes.push(newNote); pmcData.Notes.Notes.push(newNote);
return this.eventOutputHolder.getOutput(sessionID); return this.eventOutputHolder.getOutput(sessionID);

View File

@ -33,10 +33,7 @@ export class PresetBuildController
const profile = this.saveServer.getProfile(sessionID); const profile = this.saveServer.getProfile(sessionID);
if (!profile.userbuilds) if (!profile.userbuilds)
{ {
profile.userbuilds = { profile.userbuilds = {equipmentBuilds: [], weaponBuilds: []};
equipmentBuilds: [],
weaponBuilds: [],
};
} }
// Ensure the secure container in the default presets match what the player has equipped // Ensure the secure container in the default presets match what the player has equipped
@ -87,13 +84,7 @@ export class PresetBuildController
// Create new object ready to save into profile userbuilds.weaponBuilds // Create new object ready to save into profile userbuilds.weaponBuilds
const newId = this.hashUtil.generate(); // Id is empty, generate it const newId = this.hashUtil.generate(); // Id is empty, generate it
const newBuild: IWeaponBuild = { const newBuild: IWeaponBuild = {id: newId, name: body.name, root: body.root, items: body.items, type: "weapon"};
id: newId,
name: body.name,
root: body.root,
items: body.items,
type: "weapon",
};
const savedWeaponBuilds = this.saveServer.getProfile(sessionId).userbuilds.weaponBuilds; const savedWeaponBuilds = this.saveServer.getProfile(sessionId).userbuilds.weaponBuilds;
const existingBuild = savedWeaponBuilds.find((x) => x.id === body.id); const existingBuild = savedWeaponBuilds.find((x) => x.id === body.id);

View File

@ -164,10 +164,7 @@ export class ProfileController
// Create profile // Create profile
const profileDetails: IAkiProfile = { const profileDetails: IAkiProfile = {
info: account, info: account,
characters: { characters: {pmc: pmcData, scav: {} as IPmcData},
pmc: pmcData,
scav: {} as IPmcData,
},
suits: profile.suits, suits: profile.suits,
userbuilds: profile.userbuilds, userbuilds: profile.userbuilds,
dialogues: profile.dialogues, dialogues: profile.dialogues,
@ -351,13 +348,6 @@ export class ProfileController
*/ */
public getFriends(info: ISearchFriendRequestData, sessionID: string): ISearchFriendResponse[] public getFriends(info: ISearchFriendRequestData, sessionID: string): ISearchFriendResponse[]
{ {
return [{ return [{_id: this.hashUtil.generate(), Info: {Level: 1, Side: "Bear", Nickname: info.nickname}}];
_id: this.hashUtil.generate(),
Info: {
Level: 1,
Side: "Bear",
Nickname: info.nickname,
},
}];
} }
} }

View File

@ -448,11 +448,9 @@ export class QuestController
const change = {}; const change = {};
change[repeatableQuestProfile._id] = repeatableSettings.changeRequirement[repeatableQuestProfile._id]; change[repeatableQuestProfile._id] = repeatableSettings.changeRequirement[repeatableQuestProfile._id];
const responseData: IPmcDataRepeatableQuest = { const responseData: IPmcDataRepeatableQuest = {
id: repeatableSettings.id id: repeatableSettings.id ?? this.questConfig.repeatableQuests.find((x) =>
?? this.questConfig.repeatableQuests.find((x) => x.name === repeatableQuestProfile.sptRepatableGroupName
x.name === repeatableQuestProfile.sptRepatableGroupName ).id,
)
.id,
name: repeatableSettings.name, name: repeatableSettings.name,
endTime: repeatableSettings.endTime, endTime: repeatableSettings.endTime,
changeRequirement: change, changeRequirement: change,
@ -957,10 +955,6 @@ export class QuestController
return; return;
} }
pmcData.BackendCounters[conditionId] = { pmcData.BackendCounters[conditionId] = {id: conditionId, qid: questId, value: counterValue};
id: conditionId,
qid: questId,
value: counterValue,
};
} }
} }

View File

@ -326,11 +326,7 @@ export class RagfairController
const min = offers[0].requirementsCost; // Get first item from array as its pre-sorted const min = offers[0].requirementsCost; // Get first item from array as its pre-sorted
const max = offers.at(-1).requirementsCost; // Get last item from array as its pre-sorted const max = offers.at(-1).requirementsCost; // Get last item from array as its pre-sorted
return { return {avg: (min + max) / 2, min: min, max: max};
avg: (min + max) / 2,
min: min,
max: max,
};
} }
// No offers listed, get price from live ragfair price list prices.json // No offers listed, get price from live ragfair price list prices.json
else else
@ -344,11 +340,7 @@ export class RagfairController
tplPrice = this.handbookHelper.getTemplatePrice(getPriceRequest.templateId); tplPrice = this.handbookHelper.getTemplatePrice(getPriceRequest.templateId);
} }
return { return {avg: tplPrice, min: tplPrice, max: tplPrice};
avg: tplPrice,
min: tplPrice,
max: tplPrice,
};
} }
} }
@ -399,9 +391,7 @@ export class RagfairController
const qualityMultiplier = this.itemHelper.getItemQualityModifier(rootItem); const qualityMultiplier = this.itemHelper.getItemQualityModifier(rootItem);
const averageOfferPrice = this.ragfairPriceService.getFleaPriceForItem(rootItem._tpl) const averageOfferPrice = this.ragfairPriceService.getFleaPriceForItem(rootItem._tpl)
* rootItem.upd.StackObjectsCount * qualityMultiplier; * rootItem.upd.StackObjectsCount * qualityMultiplier;
const itemStackCount = (offerRequest.sellInOnePiece) const itemStackCount = (offerRequest.sellInOnePiece) ? 1 : rootItem.upd.StackObjectsCount;
? 1
: rootItem.upd.StackObjectsCount;
// Get averaged price of a single item being listed // Get averaged price of a single item being listed
const averageSingleItemPrice = (offerRequest.sellInOnePiece) const averageSingleItemPrice = (offerRequest.sellInOnePiece)
@ -623,11 +613,7 @@ export class RagfairController
const formattedRequirements: IBarterScheme[] = requirements.map((item) => const formattedRequirements: IBarterScheme[] = requirements.map((item) =>
{ {
return { return {_tpl: item._tpl, count: item.count, onlyFunctional: item.onlyFunctional};
_tpl: item._tpl,
count: item.count,
onlyFunctional: item.onlyFunctional,
};
}); });
return this.ragfairOfferGenerator.createFleaOffer( return this.ragfairOfferGenerator.createFleaOffer(
@ -756,12 +742,7 @@ export class RagfairController
return { return {
tid: "ragfair", tid: "ragfair",
Action: "TradingConfirm", Action: "TradingConfirm",
scheme_items: [ scheme_items: [{id: this.paymentHelper.getCurrency(currency), count: Math.round(value)}],
{
id: this.paymentHelper.getCurrency(currency),
count: Math.round(value),
},
],
type: "", type: "",
item_id: "", item_id: "",
count: 0, count: 0,

View File

@ -99,8 +99,7 @@ export class RepeatableQuestController
const currentRepeatableQuestType = this.getRepeatableQuestSubTypeFromProfile(repeatableConfig, pmcData); const currentRepeatableQuestType = this.getRepeatableQuestSubTypeFromProfile(repeatableConfig, pmcData);
if ( if (
repeatableConfig.side === "Pmc" repeatableConfig.side === "Pmc" && pmcData.Info.Level >= repeatableConfig.minPlayerLevel
&& pmcData.Info.Level >= repeatableConfig.minPlayerLevel
|| repeatableConfig.side === "Scav" && scavQuestUnlocked || repeatableConfig.side === "Scav" && scavQuestUnlocked
) )
{ {
@ -216,8 +215,7 @@ export class RepeatableQuestController
// Elite charisma skill gives extra daily quest(s) // Elite charisma skill gives extra daily quest(s)
return repeatableConfig.numQuests return repeatableConfig.numQuests
+ this.databaseServer.getTables().globals.config.SkillsSettings.Charisma.BonusSettings + this.databaseServer.getTables().globals.config.SkillsSettings.Charisma.BonusSettings
.EliteBonusSettings .EliteBonusSettings.RepeatableQuestExtraCount;
.RepeatableQuestExtraCount;
} }
return repeatableConfig.numQuests; return repeatableConfig.numQuests;
@ -335,17 +333,7 @@ export class RepeatableQuestController
{ {
return { return {
types: repeatableConfig.types.slice(), types: repeatableConfig.types.slice(),
pool: { pool: {Exploration: {locations: {}}, Elimination: {targets: {}}, Pickup: {locations: {}}},
Exploration: {
locations: {},
},
Elimination: {
targets: {},
},
Pickup: {
locations: {},
},
},
}; };
} }

View File

@ -24,12 +24,7 @@ export class WeatherController
/** Handle client/weather */ /** Handle client/weather */
public generate(): IWeatherData public generate(): IWeatherData
{ {
let result: IWeatherData = { let result: IWeatherData = {acceleration: 0, time: "", date: "", weather: null};
acceleration: 0,
time: "",
date: "",
weather: null,
};
result = this.weatherGenerator.calculateGameTime(result); result = this.weatherGenerator.calculateGameTime(result);
result.weather = this.weatherGenerator.generateWeather(); result.weather = this.weatherGenerator.generateWeather();

View File

@ -8,9 +8,7 @@ import { EventOutputHolder } from "@spt-aki/routers/EventOutputHolder";
@injectable() @injectable()
export class WishlistController export class WishlistController
{ {
constructor( constructor(@inject("EventOutputHolder") protected eventOutputHolder: EventOutputHolder)
@inject("EventOutputHolder") protected eventOutputHolder: EventOutputHolder,
)
{} {}
/** Handle AddToWishList */ /** Handle AddToWishList */

View File

@ -608,9 +608,7 @@ export class Container
con.register<BotGenerationCacheService>("BotGenerationCacheService", BotGenerationCacheService, { con.register<BotGenerationCacheService>("BotGenerationCacheService", BotGenerationCacheService, {
lifecycle: Lifecycle.Singleton, lifecycle: Lifecycle.Singleton,
}); });
con.register<LocalisationService>("LocalisationService", LocalisationService, { con.register<LocalisationService>("LocalisationService", LocalisationService, {lifecycle: Lifecycle.Singleton});
lifecycle: Lifecycle.Singleton,
});
con.register<CustomLocationWaveService>("CustomLocationWaveService", CustomLocationWaveService, { con.register<CustomLocationWaveService>("CustomLocationWaveService", CustomLocationWaveService, {
lifecycle: Lifecycle.Singleton, lifecycle: Lifecycle.Singleton,
}); });

View File

@ -94,18 +94,12 @@ export class SaveLoadRouter extends Router
export class HandledRoute export class HandledRoute
{ {
constructor( constructor(public route: string, public dynamic: boolean)
public route: string,
public dynamic: boolean,
)
{} {}
} }
export class RouteAction export class RouteAction
{ {
constructor( constructor(public url: string, public action: (url: string, info: any, sessionID: string, output: string) => any)
public url: string,
public action: (url: string, info: any, sessionID: string, output: string) => any,
)
{} {}
} }

View File

@ -97,9 +97,7 @@ export class BotEquipmentModGenerator
} }
// Ensure submods for nvgs all spawn together // Ensure submods for nvgs all spawn together
forceSpawn = (modSlot === "mod_nvg") forceSpawn = (modSlot === "mod_nvg") ? true : false;
? true
: false;
let modTpl: string; let modTpl: string;
let found = false; let found = false;
@ -290,13 +288,7 @@ export class BotEquipmentModGenerator
if (this.modSlotCanHoldScope(modSlot, modToAddTemplate._parent)) if (this.modSlotCanHoldScope(modSlot, modToAddTemplate._parent))
{ {
// mod_mount was picked to be added to weapon, force scope chance to ensure its filled // mod_mount was picked to be added to weapon, force scope chance to ensure its filled
const scopeSlots = [ const scopeSlots = ["mod_scope", "mod_scope_000", "mod_scope_001", "mod_scope_002", "mod_scope_003"];
"mod_scope",
"mod_scope_000",
"mod_scope_001",
"mod_scope_002",
"mod_scope_003",
];
this.adjustSlotSpawnChances(modSpawnChances, scopeSlots, 100); this.adjustSlotSpawnChances(modSpawnChances, scopeSlots, 100);
// Hydrate pool of mods that fit into mount as its a randomisable slot // Hydrate pool of mods that fit into mount as its a randomisable slot
@ -310,11 +302,7 @@ export class BotEquipmentModGenerator
// If picked item is muzzle adapter that can hold a child, adjust spawn chance // If picked item is muzzle adapter that can hold a child, adjust spawn chance
if (this.modSlotCanHoldMuzzleDevices(modSlot, modToAddTemplate._parent)) if (this.modSlotCanHoldMuzzleDevices(modSlot, modToAddTemplate._parent))
{ {
const muzzleSlots = [ const muzzleSlots = ["mod_muzzle", "mod_muzzle_000", "mod_muzzle_001"];
"mod_muzzle",
"mod_muzzle_000",
"mod_muzzle_001",
];
// Make chance of muzzle devices 95%, nearly certain but not guaranteed // Make chance of muzzle devices 95%, nearly certain but not guaranteed
this.adjustSlotSpawnChances(modSpawnChances, muzzleSlots, 95); this.adjustSlotSpawnChances(modSpawnChances, muzzleSlots, 95);
} }
@ -340,8 +328,7 @@ export class BotEquipmentModGenerator
// If stock mod can take a sub stock mod, force spawn chance to be 100% to ensure sub-stock gets added // If stock mod can take a sub stock mod, force spawn chance to be 100% to ensure sub-stock gets added
// Or if mod_stock is configured to be forced on // Or if mod_stock is configured to be forced on
if ( if (
modSlot === "mod_stock" modSlot === "mod_stock" && (modToAddTemplate._props.Slots.find((x) =>
&& (modToAddTemplate._props.Slots.find((x) =>
x._name.includes("mod_stock") || botEquipConfig.forceStock x._name.includes("mod_stock") || botEquipConfig.forceStock
)) ))
) )
@ -435,8 +422,7 @@ export class BotEquipmentModGenerator
"mod_scope_001", "mod_scope_001",
"mod_scope_002", "mod_scope_002",
"mod_scope_003", "mod_scope_003",
].includes(modSlot.toLowerCase()) ].includes(modSlot.toLowerCase()) && modsParentId === BaseClasses.MOUNT;
&& modsParentId === BaseClasses.MOUNT;
} }
/** /**
@ -1025,12 +1011,7 @@ export class BotEquipmentModGenerator
{ {
const modSlotId = slot._name; const modSlotId = slot._name;
const modId = this.hashUtil.generate(); const modId = this.hashUtil.generate();
items.push({ items.push({_id: modId, _tpl: modTpl, parentId: parentId, slotId: modSlotId});
_id: modId,
_tpl: modTpl,
parentId: parentId,
slotId: modSlotId,
});
} }
} }

View File

@ -99,10 +99,7 @@ export class BotGenerator
* @param botGenerationDetails details on how to generate bots * @param botGenerationDetails details on how to generate bots
* @returns array of bots * @returns array of bots
*/ */
public prepareAndGenerateBots( public prepareAndGenerateBots(sessionId: string, botGenerationDetails: BotGenerationDetails): IBotBase[]
sessionId: string,
botGenerationDetails: BotGenerationDetails,
): IBotBase[]
{ {
const output: IBotBase[] = []; const output: IBotBase[] = [];
for (let i = 0; i < botGenerationDetails.botCountToGenerate; i++) for (let i = 0; i < botGenerationDetails.botCountToGenerate; i++)
@ -114,11 +111,9 @@ export class BotGenerator
bot.Info.Settings.BotDifficulty = botGenerationDetails.botDifficulty; bot.Info.Settings.BotDifficulty = botGenerationDetails.botDifficulty;
// Get raw json data for bot (Cloned) // Get raw json data for bot (Cloned)
const botJsonTemplate = this.jsonUtil.clone(this.botHelper.getBotTemplate( const botJsonTemplate = this.jsonUtil.clone(
(botGenerationDetails.isPmc) this.botHelper.getBotTemplate((botGenerationDetails.isPmc) ? bot.Info.Side : botGenerationDetails.role),
? bot.Info.Side );
: botGenerationDetails.role,
));
bot = this.generateBot(sessionId, bot, botJsonTemplate, botGenerationDetails); bot = this.generateBot(sessionId, bot, botJsonTemplate, botGenerationDetails);
@ -328,9 +323,7 @@ export class BotGenerator
*/ */
protected generateHealth(healthObj: Health, playerScav = false): PmcHealth protected generateHealth(healthObj: Health, playerScav = false): PmcHealth
{ {
const bodyParts = playerScav const bodyParts = playerScav ? healthObj.BodyParts[0] : this.randomUtil.getArrayValue(healthObj.BodyParts);
? healthObj.BodyParts[0]
: this.randomUtil.getArrayValue(healthObj.BodyParts);
const newHealth: PmcHealth = { const newHealth: PmcHealth = {
Hydration: { Hydration: {
@ -437,10 +430,7 @@ export class BotGenerator
} }
// All skills have id and progress props // All skills have id and progress props
const skillToAdd: IBaseSkill = { const skillToAdd: IBaseSkill = {Id: skillKey, Progress: this.randomUtil.getInt(skill.min, skill.max)};
Id: skillKey,
Progress: this.randomUtil.getInt(skill.min, skill.max),
};
// Common skills have additional props // Common skills have additional props
if (isCommonSkills) if (isCommonSkills)

View File

@ -112,26 +112,11 @@ export class BotInventoryGenerator
return { return {
items: [ items: [
{ {_id: equipmentId, _tpl: equipmentTpl},
_id: equipmentId, {_id: stashId, _tpl: stashTpl},
_tpl: equipmentTpl, {_id: questRaidItemsId, _tpl: questRaidItemsTpl},
}, {_id: questStashItemsId, _tpl: questStashItemsTpl},
{ {_id: sortingTableId, _tpl: sortingTableTpl},
_id: stashId,
_tpl: stashTpl,
},
{
_id: questRaidItemsId,
_tpl: questRaidItemsTpl,
},
{
_id: questStashItemsId,
_tpl: questStashItemsTpl,
},
{
_id: sortingTableId,
_tpl: sortingTableTpl,
},
], ],
equipment: equipmentId, equipment: equipmentId,
stash: stashId, stash: stashId,
@ -421,24 +406,17 @@ export class BotInventoryGenerator
protected getDesiredWeaponsForBot(equipmentChances: Chances): {slot: EquipmentSlots; shouldSpawn: boolean;}[] protected getDesiredWeaponsForBot(equipmentChances: Chances): {slot: EquipmentSlots; shouldSpawn: boolean;}[]
{ {
const shouldSpawnPrimary = this.randomUtil.getChance100(equipmentChances.equipment.FirstPrimaryWeapon); const shouldSpawnPrimary = this.randomUtil.getChance100(equipmentChances.equipment.FirstPrimaryWeapon);
return [ return [{slot: EquipmentSlots.FIRST_PRIMARY_WEAPON, shouldSpawn: shouldSpawnPrimary}, {
{ slot: EquipmentSlots.SECOND_PRIMARY_WEAPON,
slot: EquipmentSlots.FIRST_PRIMARY_WEAPON, shouldSpawn: shouldSpawnPrimary
shouldSpawn: shouldSpawnPrimary, ? this.randomUtil.getChance100(equipmentChances.equipment.SecondPrimaryWeapon)
}, : false,
{ }, {
slot: EquipmentSlots.SECOND_PRIMARY_WEAPON, slot: EquipmentSlots.HOLSTER,
shouldSpawn: shouldSpawnPrimary shouldSpawn: shouldSpawnPrimary
? this.randomUtil.getChance100(equipmentChances.equipment.SecondPrimaryWeapon) ? this.randomUtil.getChance100(equipmentChances.equipment.Holster) // Primary weapon = roll for chance at pistol
: false, : true, // No primary = force pistol
}, }];
{
slot: EquipmentSlots.HOLSTER,
shouldSpawn: shouldSpawnPrimary
? this.randomUtil.getChance100(equipmentChances.equipment.Holster) // Primary weapon = roll for chance at pistol
: true, // No primary = force pistol
},
];
} }
/** /**

View File

@ -237,52 +237,16 @@ export class BotLootGenerator
protected addForcedMedicalItemsToPmcSecure(botInventory: PmcInventory, botRole: string): void protected addForcedMedicalItemsToPmcSecure(botInventory: PmcInventory, botRole: string): void
{ {
const grizzly = this.itemHelper.getItem("590c657e86f77412b013051d")[1]; const grizzly = this.itemHelper.getItem("590c657e86f77412b013051d")[1];
this.addLootFromPool( this.addLootFromPool([grizzly], [EquipmentSlots.SECURED_CONTAINER], 2, botInventory, botRole, false, 0, true);
[grizzly],
[EquipmentSlots.SECURED_CONTAINER],
2,
botInventory,
botRole,
false,
0,
true,
);
const surv12 = this.itemHelper.getItem("5d02797c86f774203f38e30a")[1]; const surv12 = this.itemHelper.getItem("5d02797c86f774203f38e30a")[1];
this.addLootFromPool( this.addLootFromPool([surv12], [EquipmentSlots.SECURED_CONTAINER], 1, botInventory, botRole, false, 0, true);
[surv12],
[EquipmentSlots.SECURED_CONTAINER],
1,
botInventory,
botRole,
false,
0,
true,
);
const morphine = this.itemHelper.getItem("544fb3f34bdc2d03748b456a")[1]; const morphine = this.itemHelper.getItem("544fb3f34bdc2d03748b456a")[1];
this.addLootFromPool( this.addLootFromPool([morphine], [EquipmentSlots.SECURED_CONTAINER], 3, botInventory, botRole, false, 0, true);
[morphine],
[EquipmentSlots.SECURED_CONTAINER],
3,
botInventory,
botRole,
false,
0,
true,
);
const afak = this.itemHelper.getItem("60098ad7c2240c0fe85c570a")[1]; const afak = this.itemHelper.getItem("60098ad7c2240c0fe85c570a")[1];
this.addLootFromPool( this.addLootFromPool([afak], [EquipmentSlots.SECURED_CONTAINER], 2, botInventory, botRole, false, 0, true);
[afak],
[EquipmentSlots.SECURED_CONTAINER],
2,
botInventory,
botRole,
false,
0,
true,
);
} }
/** /**

View File

@ -258,9 +258,7 @@ export class BotWeaponGenerator
else else
{ {
// Already exists, update values // Already exists, update values
existingItemWithSlot.upd = { existingItemWithSlot.upd = {StackObjectsCount: 1};
StackObjectsCount: 1,
};
existingItemWithSlot._tpl = ammoTpl; existingItemWithSlot._tpl = ammoTpl;
} }
} }
@ -532,11 +530,7 @@ export class BotWeaponGenerator
[EquipmentSlots.SECURED_CONTAINER], [EquipmentSlots.SECURED_CONTAINER],
id, id,
ammoTpl, ammoTpl,
[{ [{_id: id, _tpl: ammoTpl, upd: {StackObjectsCount: stackSize}}],
_id: id,
_tpl: ammoTpl,
upd: {StackObjectsCount: stackSize},
}],
inventory, inventory,
); );
} }
@ -705,17 +699,13 @@ export class BotWeaponGenerator
*/ */
protected fillUbgl(weaponMods: Item[], ubglMod: Item, ubglAmmoTpl: string): void protected fillUbgl(weaponMods: Item[], ubglMod: Item, ubglAmmoTpl: string): void
{ {
weaponMods.push( weaponMods.push({
{ _id: this.hashUtil.generate(),
_id: this.hashUtil.generate(), _tpl: ubglAmmoTpl,
_tpl: ubglAmmoTpl, parentId: ubglMod._id,
parentId: ubglMod._id, slotId: "patron_in_weapon",
slotId: "patron_in_weapon", upd: {StackObjectsCount: 1},
upd: { });
StackObjectsCount: 1,
},
},
);
} }
/** /**

View File

@ -97,10 +97,7 @@ export class FenceBaseAssortGenerator
_tpl: item._id, _tpl: item._id,
parentId: "hideout", parentId: "hideout",
slotId: "hideout", slotId: "hideout",
upd: { upd: {StackObjectsCount: 9999999, UnlimitedCount: true},
StackObjectsCount: 9999999,
UnlimitedCount: true,
},
}; };
// Add item to base // Add item to base

View File

@ -247,13 +247,12 @@ export class LocationGenerator
*/ */
protected getRandomisableContainersOnMap(staticContainers: IStaticContainerData[]): IStaticContainerData[] protected getRandomisableContainersOnMap(staticContainers: IStaticContainerData[]): IStaticContainerData[]
{ {
return staticContainers return staticContainers.filter((x) =>
.filter((x) => x.probability !== 1 && !x.template.IsAlwaysSpawn
x.probability !== 1 && !x.template.IsAlwaysSpawn && !this.locationConfig.containerRandomisationSettings.containerTypesToNotRandomise.includes(
&& !this.locationConfig.containerRandomisationSettings.containerTypesToNotRandomise.includes( x.template.Items[0]._tpl,
x.template.Items[0]._tpl, )
) );
);
} }
/** /**
@ -530,9 +529,7 @@ export class LocationGenerator
continue; continue;
} }
itemDistribution.push( itemDistribution.push(new ProbabilityObject(icd.tpl, icd.relativeProbability));
new ProbabilityObject(icd.tpl, icd.relativeProbability),
);
} }
return itemDistribution; return itemDistribution;
@ -571,10 +568,7 @@ export class LocationGenerator
// Draw from random distribution // Draw from random distribution
const desiredSpawnpointCount = Math.round( const desiredSpawnpointCount = Math.round(
this.getLooseLootMultiplerForLocation(locationName) this.getLooseLootMultiplerForLocation(locationName)
* this.randomUtil.randn( * this.randomUtil.randn(dynamicLootDist.spawnpointCount.mean, dynamicLootDist.spawnpointCount.std),
dynamicLootDist.spawnpointCount.mean,
dynamicLootDist.spawnpointCount.std,
),
); );
// Positions not in forced but have 100% chance to spawn // Positions not in forced but have 100% chance to spawn
@ -598,9 +592,7 @@ export class LocationGenerator
continue; continue;
} }
spawnpointArray.push( spawnpointArray.push(new ProbabilityObject(spawnpoint.template.Id, spawnpoint.probability, spawnpoint));
new ProbabilityObject(spawnpoint.template.Id, spawnpoint.probability, spawnpoint),
);
} }
// Select a number of spawn points to add loot to // Select a number of spawn points to add loot to
@ -665,9 +657,7 @@ export class LocationGenerator
continue; continue;
} }
itemArray.push( itemArray.push(new ProbabilityObject(itemDist.composedKey.key, itemDist.relativeProbability));
new ProbabilityObject(itemDist.composedKey.key, itemDist.relativeProbability),
);
} }
// Draw a random item from spawn points possible items // Draw a random item from spawn points possible items
@ -720,9 +710,7 @@ export class LocationGenerator
for (const si of items) for (const si of items)
{ {
// use locationId as template.Id is the same across all items // use locationId as template.Id is the same across all items
spawnpointArray.push( spawnpointArray.push(new ProbabilityObject(si.locationId, si.probability, si));
new ProbabilityObject(si.locationId, si.probability, si),
);
} }
// Choose 1 out of all found spawn positions for spawn id and add to loot array // Choose 1 out of all found spawn positions for spawn id and add to loot array
@ -792,22 +780,13 @@ export class LocationGenerator
? 1 ? 1
: this.randomUtil.getInt(itemTemplate._props.StackMinRandom, itemTemplate._props.StackMaxRandom); : this.randomUtil.getInt(itemTemplate._props.StackMinRandom, itemTemplate._props.StackMaxRandom);
itemWithMods.push( itemWithMods.push({_id: this.objectId.generate(), _tpl: chosenTpl, upd: {StackObjectsCount: stackCount}});
{
_id: this.objectId.generate(),
_tpl: chosenTpl,
upd: {StackObjectsCount: stackCount},
},
);
} }
else if (this.itemHelper.isOfBaseclass(chosenTpl, BaseClasses.AMMO_BOX)) else if (this.itemHelper.isOfBaseclass(chosenTpl, BaseClasses.AMMO_BOX))
{ {
// Fill with cartrdiges // Fill with cartrdiges
const ammoBoxTemplate = this.itemHelper.getItem(chosenTpl)[1]; const ammoBoxTemplate = this.itemHelper.getItem(chosenTpl)[1];
const ammoBoxItem: Item[] = [{ const ammoBoxItem: Item[] = [{_id: this.objectId.generate(), _tpl: chosenTpl}];
_id: this.objectId.generate(),
_tpl: chosenTpl,
}];
this.itemHelper.addCartridgesToAmmoBox(ammoBoxItem, ammoBoxTemplate); this.itemHelper.addCartridgesToAmmoBox(ammoBoxItem, ammoBoxTemplate);
itemWithMods.push(...ammoBoxItem); itemWithMods.push(...ammoBoxItem);
} }
@ -815,10 +794,7 @@ export class LocationGenerator
{ {
// Create array with just magazine + randomised amount of cartridges // Create array with just magazine + randomised amount of cartridges
const magazineTemplate = this.itemHelper.getItem(chosenTpl)[1]; const magazineTemplate = this.itemHelper.getItem(chosenTpl)[1];
const magazineItem: Item[] = [{ const magazineItem: Item[] = [{_id: this.objectId.generate(), _tpl: chosenTpl}];
_id: this.objectId.generate(),
_tpl: chosenTpl,
}];
this.itemHelper.fillMagazineWithRandomCartridge( this.itemHelper.fillMagazineWithRandomCartridge(
magazineItem, magazineItem,
magazineTemplate, magazineTemplate,
@ -845,11 +821,7 @@ export class LocationGenerator
// Get inventory size of item // Get inventory size of item
const size = this.itemHelper.getItemSize(itemWithMods, itemWithMods[0]._id); const size = this.itemHelper.getItemSize(itemWithMods, itemWithMods[0]._id);
return { return {items: itemWithMods, width: size.width, height: size.height};
items: itemWithMods,
width: size.width,
height: size.height,
};
} }
/** /**
@ -901,12 +873,7 @@ export class LocationGenerator
const itemTemplate = this.itemHelper.getItem(tpl)[1]; const itemTemplate = this.itemHelper.getItem(tpl)[1];
let width = itemTemplate._props.Width; let width = itemTemplate._props.Width;
let height = itemTemplate._props.Height; let height = itemTemplate._props.Height;
let items: Item[] = [ let items: Item[] = [{_id: this.objectId.generate(), _tpl: tpl}];
{
_id: this.objectId.generate(),
_tpl: tpl,
},
];
// Use passed in parentId as override for new item // Use passed in parentId as override for new item
if (parentId) if (parentId)
@ -1037,10 +1004,6 @@ export class LocationGenerator
items.splice(items.indexOf(items[0]), 1, ...magazineWithCartridges); items.splice(items.indexOf(items[0]), 1, ...magazineWithCartridges);
} }
return { return {items: items, width: width, height: height};
items: items,
width: width,
height: height,
};
} }
} }

View File

@ -19,10 +19,7 @@ import { RagfairLinkedItemService } from "@spt-aki/services/RagfairLinkedItemSer
import { HashUtil } from "@spt-aki/utils/HashUtil"; import { HashUtil } from "@spt-aki/utils/HashUtil";
import { RandomUtil } from "@spt-aki/utils/RandomUtil"; import { RandomUtil } from "@spt-aki/utils/RandomUtil";
type ItemLimit = { type ItemLimit = {current: number; max: number;};
current: number;
max: number;
};
@injectable() @injectable()
export class LootGenerator export class LootGenerator
@ -134,10 +131,7 @@ export class LootGenerator
const itemTypeCounts: Record<string, ItemLimit> = {}; const itemTypeCounts: Record<string, ItemLimit> = {};
for (const itemTypeId in limits) for (const itemTypeId in limits)
{ {
itemTypeCounts[itemTypeId] = { itemTypeCounts[itemTypeId] = {current: 0, max: limits[itemTypeId]};
current: 0,
max: limits[itemTypeId],
};
} }
return itemTypeCounts; return itemTypeCounts;
@ -174,10 +168,7 @@ export class LootGenerator
}; };
// Check if armor has level in allowed whitelist // Check if armor has level in allowed whitelist
if ( if (randomItem._parent === BaseClasses.ARMOR || randomItem._parent === BaseClasses.VEST)
randomItem._parent === BaseClasses.ARMOR
|| randomItem._parent === BaseClasses.VEST
)
{ {
if (!options.armorLevelWhitelist.includes(Number(randomItem._props.armorClass))) if (!options.armorLevelWhitelist.includes(Number(randomItem._props.armorClass)))
{ {
@ -277,11 +268,7 @@ export class LootGenerator
return false; return false;
} }
const newLootItem: LootItem = { const newLootItem: LootItem = {tpl: randomPreset._items[0]._tpl, isPreset: true, stackCount: 1};
tpl: randomPreset._items[0]._tpl,
isPreset: true,
stackCount: 1,
};
result.push(newLootItem); result.push(newLootItem);
@ -405,14 +392,13 @@ export class LootGenerator
} }
// Get all items of the desired type + not quest items + not globally blacklisted // Get all items of the desired type + not quest items + not globally blacklisted
const rewardItemPool = Object.values(this.databaseServer.getTables().templates.items) const rewardItemPool = Object.values(this.databaseServer.getTables().templates.items).filter((x) =>
.filter((x) => x._parent === rewardTypeId
x._parent === rewardTypeId && x._type.toLowerCase() === "item"
&& x._type.toLowerCase() === "item" && !this.itemFilterService.isItemBlacklisted(x._id)
&& !this.itemFilterService.isItemBlacklisted(x._id) && (!(containerSettings.allowBossItems || this.itemFilterService.isBossItem(x._id)))
&& (!(containerSettings.allowBossItems || this.itemFilterService.isBossItem(x._id))) && !x._props.QuestItem
&& !x._props.QuestItem );
);
if (rewardItemPool.length === 0) if (rewardItemPool.length === 0)
{ {

View File

@ -66,9 +66,7 @@ export class PlayerScavGenerator
const existingScavData = this.jsonUtil.clone(profile.characters.scav); const existingScavData = this.jsonUtil.clone(profile.characters.scav);
// scav profile can be empty on first profile creation // scav profile can be empty on first profile creation
const scavKarmaLevel = (Object.keys(existingScavData).length === 0) const scavKarmaLevel = (Object.keys(existingScavData).length === 0) ? 0 : this.getScavKarmaLevel(pmcData);
? 0
: this.getScavKarmaLevel(pmcData);
// use karma level to get correct karmaSettings // use karma level to get correct karmaSettings
const playerScavKarmaSettings = this.playerScavConfig.karmaLevel[scavKarmaLevel]; const playerScavKarmaSettings = this.playerScavConfig.karmaLevel[scavKarmaLevel];
@ -258,11 +256,7 @@ export class PlayerScavGenerator
protected getDefaultScavSkills(): Skills protected getDefaultScavSkills(): Skills
{ {
return { return {Common: [], Mastering: [], Points: 0};
Common: [],
Mastering: [],
Points: 0,
};
} }
protected getScavStats(scavProfile: IPmcData): Stats protected getScavStats(scavProfile: IPmcData): Stats

View File

@ -135,10 +135,7 @@ export class RagfairAssortGenerator
_tpl: tplId, _tpl: tplId,
parentId: "hideout", parentId: "hideout",
slotId: "hideout", slotId: "hideout",
upd: { upd: {StackObjectsCount: 99999999, UnlimitedCount: true},
StackObjectsCount: 99999999,
UnlimitedCount: true,
},
}; };
} }
} }

View File

@ -636,10 +636,7 @@ export class RagfairOfferGenerator
{ {
const totalCapacity = itemDetails._props.MaxResource; const totalCapacity = itemDetails._props.MaxResource;
const remainingFuel = Math.round(totalCapacity * multiplier); const remainingFuel = Math.round(totalCapacity * multiplier);
item.upd.Resource = { item.upd.Resource = {UnitsConsumed: totalCapacity - remainingFuel, Value: remainingFuel};
UnitsConsumed: totalCapacity - remainingFuel,
Value: remainingFuel,
};
} }
} }
@ -653,9 +650,10 @@ export class RagfairOfferGenerator
item.upd.Repairable.Durability = Math.round(item.upd.Repairable.Durability * multiplier) || 1; item.upd.Repairable.Durability = Math.round(item.upd.Repairable.Durability * multiplier) || 1;
// randomize max durability, store to a temporary value so we can still compare the max durability // randomize max durability, store to a temporary value so we can still compare the max durability
let tempMaxDurability = Math.round( let tempMaxDurability =
this.randomUtil.getFloat(item.upd.Repairable.Durability - 5, item.upd.Repairable.MaxDurability + 5), Math.round(
) || item.upd.Repairable.Durability; this.randomUtil.getFloat(item.upd.Repairable.Durability - 5, item.upd.Repairable.MaxDurability + 5),
) || item.upd.Repairable.Durability;
// clamp values to max/current // clamp values to max/current
if (tempMaxDurability >= item.upd.Repairable.MaxDurability) if (tempMaxDurability >= item.upd.Repairable.MaxDurability)
@ -689,38 +687,27 @@ export class RagfairOfferGenerator
if (isRepairable && props.Durability > 0) if (isRepairable && props.Durability > 0)
{ {
item.upd.Repairable = { item.upd.Repairable = {Durability: props.Durability, MaxDurability: props.Durability};
Durability: props.Durability,
MaxDurability: props.Durability,
};
} }
if (isMedkit && props.MaxHpResource > 0) if (isMedkit && props.MaxHpResource > 0)
{ {
item.upd.MedKit = { item.upd.MedKit = {HpResource: props.MaxHpResource};
HpResource: props.MaxHpResource,
};
} }
if (isKey) if (isKey)
{ {
item.upd.Key = { item.upd.Key = {NumberOfUsages: 0};
NumberOfUsages: 0,
};
} }
if (isConsumable) if (isConsumable)
{ {
item.upd.FoodDrink = { item.upd.FoodDrink = {HpPercent: props.MaxResource};
HpPercent: props.MaxResource,
};
} }
if (isRepairKit) if (isRepairKit)
{ {
item.upd.RepairKit = { item.upd.RepairKit = {Resource: props.MaxRepairResource};
Resource: props.MaxRepairResource,
};
} }
return item; return item;
@ -775,12 +762,7 @@ export class RagfairOfferGenerator
// Choose random item from price-filtered flea items // Choose random item from price-filtered flea items
const randomItem = this.randomUtil.getArrayValue(filtered); const randomItem = this.randomUtil.getArrayValue(filtered);
return [ return [{count: barterItemCount, _tpl: randomItem.tpl}];
{
count: barterItemCount,
_tpl: randomItem.tpl,
},
];
} }
/** /**
@ -819,11 +801,6 @@ export class RagfairOfferGenerator
const price = this.ragfairPriceService.getDynamicOfferPriceForOffer(offerItems, currency, isPackOffer) const price = this.ragfairPriceService.getDynamicOfferPriceForOffer(offerItems, currency, isPackOffer)
* multipler; * multipler;
return [ return [{count: price, _tpl: currency}];
{
count: price,
_tpl: currency,
},
];
} }
} }

View File

@ -273,13 +273,12 @@ export class RepeatableQuestGenerator
// get all boss spawn information // get all boss spawn information
const bossSpawns = Object.values(this.databaseServer.getTables().locations).filter((x) => const bossSpawns = Object.values(this.databaseServer.getTables().locations).filter((x) =>
"base" in x && "Id" in x.base "base" in x && "Id" in x.base
).map( ).map((x) => ({Id: x.base.Id, BossSpawn: x.base.BossLocationSpawn}));
(x) => ({Id: x.base.Id, BossSpawn: x.base.BossLocationSpawn}),
);
// filter for the current boss to spawn on map // filter for the current boss to spawn on map
const thisBossSpawns = bossSpawns.map( const thisBossSpawns = bossSpawns.map((x) => ({
(x) => ({Id: x.Id, BossSpawn: x.BossSpawn.filter((e) => e.BossName === targetKey)}), Id: x.Id,
).filter((x) => x.BossSpawn.length > 0); BossSpawn: x.BossSpawn.filter((e) => e.BossName === targetKey),
})).filter((x) => x.BossSpawn.length > 0);
// remove blacklisted locations // remove blacklisted locations
const allowedSpawns = thisBossSpawns.filter((x) => !eliminationConfig.distLocationBlacklist.includes(x.Id)); const allowedSpawns = thisBossSpawns.filter((x) => !eliminationConfig.distLocationBlacklist.includes(x.Id));
// if the boss spawns on nom-blacklisted locations and the current location is allowed we can generate a distance kill requirement // if the boss spawns on nom-blacklisted locations and the current location is allowed we can generate a distance kill requirement
@ -416,11 +415,7 @@ export class RepeatableQuestGenerator
protected generateEliminationLocation(location: string[]): IEliminationCondition protected generateEliminationLocation(location: string[]): IEliminationCondition
{ {
const propsObject: IEliminationCondition = { const propsObject: IEliminationCondition = {
_props: { _props: {target: location, id: this.objectId.generate(), dynamicLocale: true},
target: location,
id: this.objectId.generate(),
dynamicLocale: true,
},
_parent: "Location", _parent: "Location",
}; };
@ -466,10 +461,7 @@ export class RepeatableQuestGenerator
// Dont allow distance + melee requirement // Dont allow distance + melee requirement
if (distance && allowedWeaponCategory !== "5b5f7a0886f77409407a7f96") if (distance && allowedWeaponCategory !== "5b5f7a0886f77409407a7f96")
{ {
killConditionProps.distance = { killConditionProps.distance = {compareMethod: ">=", value: distance};
compareMethod: ">=",
value: distance,
};
} }
// Has specific weapon requirement // Has specific weapon requirement
@ -484,10 +476,7 @@ export class RepeatableQuestGenerator
killConditionProps.weaponCategories = [allowedWeaponCategory]; killConditionProps.weaponCategories = [allowedWeaponCategory];
} }
return { return {_props: killConditionProps, _parent: "Kills"};
_props: killConditionProps,
_parent: "Kills",
};
} }
/** /**
@ -710,28 +699,15 @@ export class RepeatableQuestGenerator
const exitStatusCondition: IExplorationCondition = { const exitStatusCondition: IExplorationCondition = {
_parent: "ExitStatus", _parent: "ExitStatus",
_props: { _props: {id: this.objectId.generate(), dynamicLocale: true, status: ["Survived"]},
id: this.objectId.generate(),
dynamicLocale: true,
status: [
"Survived",
],
},
}; };
const locationCondition: IExplorationCondition = { const locationCondition: IExplorationCondition = {
_parent: "Location", _parent: "Location",
_props: { _props: {id: this.objectId.generate(), dynamicLocale: true, target: locationTarget},
id: this.objectId.generate(),
dynamicLocale: true,
target: locationTarget,
},
}; };
quest.conditions.AvailableForFinish[0]._props.counter.id = this.objectId.generate(); quest.conditions.AvailableForFinish[0]._props.counter.id = this.objectId.generate();
quest.conditions.AvailableForFinish[0]._props.counter.conditions = [ quest.conditions.AvailableForFinish[0]._props.counter.conditions = [exitStatusCondition, locationCondition];
exitStatusCondition,
locationCondition,
];
quest.conditions.AvailableForFinish[0]._props.value = numExtracts; quest.conditions.AvailableForFinish[0]._props.value = numExtracts;
quest.conditions.AvailableForFinish[0]._props.id = this.objectId.generate(); quest.conditions.AvailableForFinish[0]._props.id = this.objectId.generate();
quest.location = this.getQuestLocationByMapId(locationKey); quest.location = this.getQuestLocationByMapId(locationKey);
@ -742,13 +718,11 @@ export class RepeatableQuestGenerator
// Scav exits are not listed at all in locations.base currently. If that changes at some point, additional filtering will be required // Scav exits are not listed at all in locations.base currently. If that changes at some point, additional filtering will be required
const mapExits = const mapExits =
(this.databaseServer.getTables().locations[locationKey.toLowerCase()].base as ILocationBase).exits; (this.databaseServer.getTables().locations[locationKey.toLowerCase()].base as ILocationBase).exits;
const possibleExists = mapExits.filter( const possibleExists = mapExits.filter((x) =>
(x) => (!("PassageRequirement" in x)
(!("PassageRequirement" in x) || repeatableConfig.questConfig.Exploration.specificExits.passageRequirementWhitelist.includes(
|| repeatableConfig.questConfig.Exploration.specificExits.passageRequirementWhitelist.includes( x.PassageRequirement,
x.PassageRequirement, )) && x.Chance > 0
))
&& x.Chance > 0,
); );
const exit = this.randomUtil.drawRandomFromList(possibleExists, 1)[0]; const exit = this.randomUtil.drawRandomFromList(possibleExists, 1)[0];
const exitCondition = this.generateExplorationExitCondition(exit); const exitCondition = this.generateExplorationExitCondition(exit);
@ -823,14 +797,7 @@ export class RepeatableQuestGenerator
*/ */
protected generateExplorationExitCondition(exit: Exit): IExplorationCondition protected generateExplorationExitCondition(exit: Exit): IExplorationCondition
{ {
return { return {_parent: "ExitName", _props: {exitName: exit.Name, id: this.objectId.generate(), dynamicLocale: true}};
_parent: "ExitName",
_props: {
exitName: exit.Name,
id: this.objectId.generate(),
dynamicLocale: true,
},
};
} }
/** /**
@ -890,10 +857,11 @@ export class RepeatableQuestGenerator
1, 1,
Math.round(this.mathUtil.interp1(pmcLevel, levelsConfig, itemsConfig)) + 1, Math.round(this.mathUtil.interp1(pmcLevel, levelsConfig, itemsConfig)) + 1,
); );
const rewardReputation = Math.round( const rewardReputation =
100 * difficulty * this.mathUtil.interp1(pmcLevel, levelsConfig, reputationConfig) Math.round(
* this.randomUtil.getFloat(1 - rewardSpreadConfig, 1 + rewardSpreadConfig), 100 * difficulty * this.mathUtil.interp1(pmcLevel, levelsConfig, reputationConfig)
) / 100; * this.randomUtil.getFloat(1 - rewardSpreadConfig, 1 + rewardSpreadConfig),
) / 100;
const skillRewardChance = this.mathUtil.interp1(pmcLevel, levelsConfig, skillRewardChanceConfig); const skillRewardChance = this.mathUtil.interp1(pmcLevel, levelsConfig, skillRewardChanceConfig);
const skillPointReward = this.mathUtil.interp1(pmcLevel, levelsConfig, skillPointRewardConfig); const skillPointReward = this.mathUtil.interp1(pmcLevel, levelsConfig, skillPointRewardConfig);
@ -901,17 +869,7 @@ export class RepeatableQuestGenerator
let roublesBudget = rewardRoubles; let roublesBudget = rewardRoubles;
let chosenRewardItems = this.chooseRewardItemsWithinBudget(repeatableConfig, roublesBudget); let chosenRewardItems = this.chooseRewardItemsWithinBudget(repeatableConfig, roublesBudget);
const rewards: IRewards = { const rewards: IRewards = {Started: [], Success: [{value: rewardXP, type: "Experience", index: 0}], Fail: []};
Started: [],
Success: [
{
value: rewardXP,
type: "Experience",
index: 0,
},
],
Fail: [],
};
if (traderId === Traders.PEACEKEEPER) if (traderId === Traders.PEACEKEEPER)
{ {
@ -988,12 +946,7 @@ export class RepeatableQuestGenerator
// Add rep reward to rewards array // Add rep reward to rewards array
if (rewardReputation > 0) if (rewardReputation > 0)
{ {
const reward: IReward = { const reward: IReward = {target: traderId, value: rewardReputation, type: "TraderStanding", index: index};
target: traderId,
value: rewardReputation,
type: "TraderStanding",
index: index,
};
rewards.Success.push(reward); rewards.Success.push(reward);
} }
@ -1057,21 +1010,9 @@ export class RepeatableQuestGenerator
protected generateRewardItem(tpl: string, value: number, index: number, preset = null): IReward protected generateRewardItem(tpl: string, value: number, index: number, preset = null): IReward
{ {
const id = this.objectId.generate(); const id = this.objectId.generate();
const rewardItem: IReward = { const rewardItem: IReward = {target: id, value: value, type: "Item", index: index};
target: id,
value: value,
type: "Item",
index: index,
};
const rootItem = { const rootItem = {_id: id, _tpl: tpl, upd: {StackObjectsCount: value, SpawnedInSession: true}};
_id: id,
_tpl: tpl,
upd: {
StackObjectsCount: value,
SpawnedInSession: true,
},
};
if (preset) if (preset)
{ {
@ -1094,18 +1035,16 @@ export class RepeatableQuestGenerator
// check for specific baseclasses which don't make sense as reward item // check for specific baseclasses which don't make sense as reward item
// also check if the price is greater than 0; there are some items whose price can not be found // also check if the price is greater than 0; there are some items whose price can not be found
// those are not in the game yet (e.g. AGS grenade launcher) // those are not in the game yet (e.g. AGS grenade launcher)
return Object.entries(this.databaseServer.getTables().templates.items).filter( return Object.entries(this.databaseServer.getTables().templates.items).filter(([tpl, itemTemplate]) =>
([tpl, itemTemplate]) => {
// Base "Item" item has no parent, ignore it
if (itemTemplate._parent === "")
{ {
// Base "Item" item has no parent, ignore it return false;
if (itemTemplate._parent === "") }
{
return false;
}
return this.isValidRewardItem(tpl, repeatableQuestConfig); return this.isValidRewardItem(tpl, repeatableQuestConfig);
}, });
);
} }
/** /**
@ -1123,10 +1062,7 @@ export class RepeatableQuestGenerator
} }
// Item is on repeatable or global blacklist // Item is on repeatable or global blacklist
if ( if (repeatableQuestConfig.rewardBlacklist.includes(tpl) || this.itemFilterService.isItemBlacklisted(tpl))
repeatableQuestConfig.rewardBlacklist.includes(tpl)
|| this.itemFilterService.isItemBlacklisted(tpl)
)
{ {
return false; return false;
} }
@ -1152,8 +1088,7 @@ export class RepeatableQuestGenerator
// Skip globally blacklisted items + boss items // Skip globally blacklisted items + boss items
// biome-ignore lint/complexity/useSimplifiedLogicExpression: <explanation> // biome-ignore lint/complexity/useSimplifiedLogicExpression: <explanation>
valid = !this.itemFilterService.isItemBlacklisted(tpl) valid = !this.itemFilterService.isItemBlacklisted(tpl) && !this.itemFilterService.isBossItem(tpl);
&& !this.itemFilterService.isBossItem(tpl);
return valid; return valid;
} }

View File

@ -279,11 +279,7 @@ export class ScavCaseRewardGenerator
const result: Product[] = []; const result: Product[] = [];
for (const item of rewardItems) for (const item of rewardItems)
{ {
const resultItem = { const resultItem = {_id: this.hashUtil.generate(), _tpl: item._id, upd: undefined};
_id: this.hashUtil.generate(),
_tpl: item._id,
upd: undefined,
};
this.addStackCountToAmmoAndMoney(item, resultItem, rarity); this.addStackCountToAmmoAndMoney(item, resultItem, rarity);
@ -312,9 +308,7 @@ export class ScavCaseRewardGenerator
{ {
if (item._parent === BaseClasses.AMMO || item._parent === BaseClasses.MONEY) if (item._parent === BaseClasses.AMMO || item._parent === BaseClasses.MONEY)
{ {
resultItem.upd = { resultItem.upd = {StackObjectsCount: this.getRandomAmountRewardForScavCase(item, rarity)};
StackObjectsCount: this.getRandomAmountRewardForScavCase(item, rarity),
};
} }
} }
@ -331,10 +325,7 @@ export class ScavCaseRewardGenerator
return dbItems.filter((item) => return dbItems.filter((item) =>
{ {
const handbookPrice = this.ragfairPriceService.getStaticPriceForItem(item._id); const handbookPrice = this.ragfairPriceService.getStaticPriceForItem(item._id);
if ( if (handbookPrice >= itemFilters.minPriceRub && handbookPrice <= itemFilters.maxPriceRub)
handbookPrice >= itemFilters.minPriceRub
&& handbookPrice <= itemFilters.maxPriceRub
)
{ {
return true; return true;
} }

View File

@ -106,9 +106,7 @@ export class WeatherGenerator
wind_gustiness: this.getRandomFloat("windGustiness"), wind_gustiness: this.getRandomFloat("windGustiness"),
rain: rain, rain: rain,
// eslint-disable-next-line @typescript-eslint/naming-convention // eslint-disable-next-line @typescript-eslint/naming-convention
rain_intensity: (rain > 1) rain_intensity: (rain > 1) ? this.getRandomFloat("rainIntensity") : 0,
? this.getRandomFloat("rainIntensity")
: 0,
fog: this.getWeightedFog(), fog: this.getWeightedFog(),
temp: this.getRandomFloat("temp"), temp: this.getRandomFloat("temp"),
pressure: this.getRandomFloat("pressure"), pressure: this.getRandomFloat("pressure"),

View File

@ -7,9 +7,7 @@ import { BotWeaponGeneratorHelper } from "@spt-aki/helpers/BotWeaponGeneratorHel
@injectable() @injectable()
export class InternalMagazineInventoryMagGen implements IInventoryMagGen export class InternalMagazineInventoryMagGen implements IInventoryMagGen
{ {
constructor( constructor(@inject("BotWeaponGeneratorHelper") protected botWeaponGeneratorHelper: BotWeaponGeneratorHelper)
@inject("BotWeaponGeneratorHelper") protected botWeaponGeneratorHelper: BotWeaponGeneratorHelper,
)
{} {}
public getPriority(): number public getPriority(): number

View File

@ -9,9 +9,7 @@ import { EquipmentSlots } from "@spt-aki/models/enums/EquipmentSlots";
@injectable() @injectable()
export class UbglExternalMagGen implements IInventoryMagGen export class UbglExternalMagGen implements IInventoryMagGen
{ {
constructor( constructor(@inject("BotWeaponGeneratorHelper") protected botWeaponGeneratorHelper: BotWeaponGeneratorHelper)
@inject("BotWeaponGeneratorHelper") protected botWeaponGeneratorHelper: BotWeaponGeneratorHelper,
)
{} {}
public getPriority(): number public getPriority(): number

View File

@ -38,12 +38,8 @@ export class BotDifficultyHelper
{ {
const difficultySettings = this.getDifficultySettings(pmcType, difficulty); const difficultySettings = this.getDifficultySettings(pmcType, difficulty);
const friendlyType = pmcType === "bear" const friendlyType = pmcType === "bear" ? bearType : usecType;
? bearType const enemyType = pmcType === "bear" ? usecType : bearType;
: usecType;
const enemyType = pmcType === "bear"
? usecType
: bearType;
this.botHelper.addBotToEnemyList(difficultySettings, this.pmcConfig.enemyTypes, friendlyType); // Add generic bot types to enemy list this.botHelper.addBotToEnemyList(difficultySettings, this.pmcConfig.enemyTypes, friendlyType); // Add generic bot types to enemy list
this.botHelper.addBotToEnemyList(difficultySettings, [enemyType, friendlyType], ""); // add same/opposite side to enemy list this.botHelper.addBotToEnemyList(difficultySettings, [enemyType, friendlyType], ""); // add same/opposite side to enemy list

View File

@ -150,9 +150,7 @@ export class BotGeneratorHelper
itemProperties.Togglable = {On: (this.randomUtil.getChance100(faceShieldActiveChance))}; itemProperties.Togglable = {On: (this.randomUtil.getChance100(faceShieldActiveChance))};
} }
return Object.keys(itemProperties).length return Object.keys(itemProperties).length ? {upd: itemProperties} : {};
? {upd: itemProperties}
: {};
} }
/** /**
@ -240,10 +238,7 @@ export class BotGeneratorHelper
maxDurability, maxDurability,
); );
return { return {Durability: currentDurability, MaxDurability: maxDurability};
Durability: currentDurability,
MaxDurability: maxDurability,
};
} }
/** /**
@ -271,10 +266,7 @@ export class BotGeneratorHelper
); );
} }
return { return {Durability: currentDurability, MaxDurability: maxDurability};
Durability: currentDurability,
MaxDurability: maxDurability,
};
} }
/** /**
@ -381,11 +373,7 @@ export class ExhaustableArray<T>
{ {
private pool: T[]; private pool: T[];
constructor( constructor(private itemPool: T[], private randomUtil: RandomUtil, private jsonUtil: JsonUtil)
private itemPool: T[],
private randomUtil: RandomUtil,
private jsonUtil: JsonUtil,
)
{ {
this.pool = this.jsonUtil.clone(itemPool); this.pool = this.jsonUtil.clone(itemPool);
} }

View File

@ -248,8 +248,6 @@ export class BotHelper
*/ */
protected getRandomizedPmcSide(): string protected getRandomizedPmcSide(): string
{ {
return (this.randomUtil.getChance100(this.pmcConfig.isUsec)) return (this.randomUtil.getChance100(this.pmcConfig.isUsec)) ? "Usec" : "Bear";
? "Usec"
: "Bear";
} }
} }

View File

@ -96,10 +96,7 @@ export class BotWeaponGeneratorHelper
*/ */
public createMagazineWithAmmo(magazineTpl: string, ammoTpl: string, magTemplate: ITemplateItem): Item[] public createMagazineWithAmmo(magazineTpl: string, ammoTpl: string, magTemplate: ITemplateItem): Item[]
{ {
const magazine: Item[] = [{ const magazine: Item[] = [{_id: this.hashUtil.generate(), _tpl: magazineTpl}];
_id: this.hashUtil.generate(),
_tpl: magazineTpl,
}];
this.itemHelper.fillMagazineWithCartridge(magazine, magTemplate, ammoTpl, 1); this.itemHelper.fillMagazineWithCartridge(magazine, magTemplate, ammoTpl, 1);
@ -128,13 +125,9 @@ export class BotWeaponGeneratorHelper
for (const ammoItem of ammoItems) for (const ammoItem of ammoItems)
{ {
const result = this.addItemWithChildrenToEquipmentSlot( const result = this.addItemWithChildrenToEquipmentSlot(equipmentSlotsToAddTo, ammoItem._id, ammoItem._tpl, [
equipmentSlotsToAddTo, ammoItem,
ammoItem._id, ], inventory);
ammoItem._tpl,
[ammoItem],
inventory,
);
if (result === ItemAddedResult.NO_SPACE) if (result === ItemAddedResult.NO_SPACE)
{ {

View File

@ -39,10 +39,7 @@ export class DialogueHelper
*/ */
public createMessageContext(templateId: string, messageType: MessageType, maxStoreTime = null): MessageContent public createMessageContext(templateId: string, messageType: MessageType, maxStoreTime = null): MessageContent
{ {
const result: MessageContent = { const result: MessageContent = {templateId: templateId, type: messageType};
templateId: templateId,
type: messageType,
};
if (maxStoreTime) if (maxStoreTime)
{ {
@ -69,14 +66,7 @@ export class DialogueHelper
if (isNewDialogue) if (isNewDialogue)
{ {
dialogue = { dialogue = {_id: dialogueID, type: messageType, messages: [], pinned: false, new: 0, attachmentsNew: 0};
_id: dialogueID,
type: messageType,
messages: [],
pinned: false,
new: 0,
attachmentsNew: 0,
};
dialogueData[dialogueID] = dialogue; dialogueData[dialogueID] = dialogue;
} }
@ -89,10 +79,7 @@ export class DialogueHelper
if (rewards.length > 0) if (rewards.length > 0)
{ {
const stashId = this.hashUtil.generate(); const stashId = this.hashUtil.generate();
items = { items = {stash: stashId, data: []};
stash: stashId,
data: [],
};
rewards = this.itemHelper.replaceIDs(null, rewards); rewards = this.itemHelper.replaceIDs(null, rewards);
for (const reward of rewards) for (const reward of rewards)

View File

@ -177,9 +177,7 @@ export class DurabilityLimitsHelper
); );
// Dont let weapon dura go below the percent defined in config // Dont let weapon dura go below the percent defined in config
return (result >= durabilityValueMinLimit) return (result >= durabilityValueMinLimit) ? result : durabilityValueMinLimit;
? result
: durabilityValueMinLimit;
} }
protected generateArmorDurability(botRole: string, maxDurability: number): number protected generateArmorDurability(botRole: string, maxDurability: number): number
@ -193,9 +191,7 @@ export class DurabilityLimitsHelper
); );
// Dont let armor dura go below the percent defined in config // Dont let armor dura go below the percent defined in config
return (result >= durabilityValueMinLimit) return (result >= durabilityValueMinLimit) ? result : durabilityValueMinLimit;
? result
: durabilityValueMinLimit;
} }
protected getMinWeaponDeltaFromConfig(botRole: string): number protected getMinWeaponDeltaFromConfig(botRole: string): number

View File

@ -49,9 +49,7 @@ export class HandbookHelper
{ {
this.handbookPriceCache.items.byParent.set(handbookItem.ParentId, []); this.handbookPriceCache.items.byParent.set(handbookItem.ParentId, []);
} }
this.handbookPriceCache.items.byParent this.handbookPriceCache.items.byParent.get(handbookItem.ParentId).push(handbookItem.Id);
.get(handbookItem.ParentId)
.push(handbookItem.Id);
} }
for (const handbookCategory of handbookDb.Categories) for (const handbookCategory of handbookDb.Categories)
@ -63,9 +61,7 @@ export class HandbookHelper
{ {
this.handbookPriceCache.categories.byParent.set(handbookCategory.ParentId, []); this.handbookPriceCache.categories.byParent.set(handbookCategory.ParentId, []);
} }
this.handbookPriceCache.categories.byParent this.handbookPriceCache.categories.byParent.get(handbookCategory.ParentId).push(handbookCategory.Id);
.get(handbookCategory.ParentId)
.push(handbookCategory.Id);
} }
} }
} }

View File

@ -38,10 +38,7 @@ export class HealthHelper
if (!profile.vitality) if (!profile.vitality)
{ // Occurs on newly created profiles { // Occurs on newly created profiles
profile.vitality = { profile.vitality = {health: null, effects: null};
health: null,
effects: null,
};
} }
profile.vitality.health = { profile.vitality.health = {
Hydration: 0, Hydration: 0,

View File

@ -651,13 +651,7 @@ export class HideoutHelper
*/ */
protected getAreaUpdObject(stackCount: number, resourceValue: number, resourceUnitsConsumed: number): Upd protected getAreaUpdObject(stackCount: number, resourceValue: number, resourceUnitsConsumed: number): Upd
{ {
return { return {StackObjectsCount: stackCount, Resource: {Value: resourceValue, UnitsConsumed: resourceUnitsConsumed}};
StackObjectsCount: stackCount,
Resource: {
Value: resourceValue,
UnitsConsumed: resourceUnitsConsumed,
},
};
} }
protected updateAirFilters(airFilterArea: HideoutArea, pmcData: IPmcData): void protected updateAirFilters(airFilterArea: HideoutArea, pmcData: IPmcData): void
@ -705,10 +699,7 @@ export class HideoutHelper
{ {
airFilterArea.slots[i].item[0].upd = { airFilterArea.slots[i].item[0].upd = {
StackObjectsCount: 1, StackObjectsCount: 1,
Resource: { Resource: {Value: resourceValue, UnitsConsumed: pointsConsumed},
Value: resourceValue,
UnitsConsumed: pointsConsumed,
},
}; };
this.logger.debug(`Air filter: ${resourceValue} filter left on slot ${i + 1}`); this.logger.debug(`Air filter: ${resourceValue} filter left on slot ${i + 1}`);
break; // Break here to avoid updating all filters break; // Break here to avoid updating all filters
@ -815,9 +806,7 @@ export class HideoutHelper
btcProd.Products.push({ btcProd.Products.push({
_id: this.hashUtil.generate(), _id: this.hashUtil.generate(),
_tpl: "59faff1d86f7746c51718c9c", _tpl: "59faff1d86f7746c51718c9c",
upd: { upd: {StackObjectsCount: 1},
StackObjectsCount: 1,
},
}); });
btcProd.Progress -= coinCraftTimeSeconds; btcProd.Progress -= coinCraftTimeSeconds;
@ -896,9 +885,7 @@ export class HideoutHelper
// at level 1 you already get 0.5%, so it goes up until level 50. For some reason the wiki // at level 1 you already get 0.5%, so it goes up until level 50. For some reason the wiki
// says that it caps at level 51 with 25% but as per dump data that is incorrect apparently // says that it caps at level 51 with 25% but as per dump data that is incorrect apparently
let roundedLevel = Math.floor(hideoutManagementSkill.Progress / 100); let roundedLevel = Math.floor(hideoutManagementSkill.Progress / 100);
roundedLevel = (roundedLevel === 51) roundedLevel = (roundedLevel === 51) ? roundedLevel - 1 : roundedLevel;
? roundedLevel - 1
: roundedLevel;
return (roundedLevel return (roundedLevel
* this.databaseServer.getTables().globals.config.SkillsSettings.HideoutManagement * this.databaseServer.getTables().globals.config.SkillsSettings.HideoutManagement
@ -1023,9 +1010,7 @@ export class HideoutHelper
*/ */
protected hideoutImprovementIsComplete(improvement: IHideoutImprovement): boolean protected hideoutImprovementIsComplete(improvement: IHideoutImprovement): boolean
{ {
return improvement?.completed return improvement?.completed ? true : false;
? true
: false;
} }
/** /**

View File

@ -21,9 +21,7 @@ export class HttpServerHelper
txt: "text/plain", txt: "text/plain",
}; };
constructor( constructor(@inject("ConfigServer") protected configServer: ConfigServer)
@inject("ConfigServer") protected configServer: ConfigServer,
)
{ {
this.httpConfig = this.configServer.getConfig(ConfigTypes.HTTP); this.httpConfig = this.configServer.getConfig(ConfigTypes.HTTP);
} }

View File

@ -593,10 +593,7 @@ export class InRaidHelper
} }
// Add these new found items to our list of inventory items // Add these new found items to our list of inventory items
inventoryItems = [ inventoryItems = [...inventoryItems, ...foundItems];
...inventoryItems,
...foundItems,
];
// Now find the children of these items // Now find the children of these items
newItems = foundItems; newItems = foundItems;

View File

@ -175,9 +175,7 @@ export class InventoryHelper
catch (err) catch (err)
{ {
// Callback failed // Callback failed
const message = typeof err === "string" const message = typeof err === "string" ? err : this.localisationService.getText("http-unknown_error");
? err
: this.localisationService.getText("http-unknown_error");
return this.httpResponse.appendErrorToOutput(output, message); return this.httpResponse.appendErrorToOutput(output, message);
} }
@ -299,11 +297,7 @@ export class InventoryHelper
_tpl: itemLib[tmpKey]._tpl, _tpl: itemLib[tmpKey]._tpl,
parentId: toDo[0][1], parentId: toDo[0][1],
slotId: slotID, slotId: slotID,
location: { location: {x: itemToAdd.location.x, y: itemToAdd.location.y, r: "Horizontal"},
x: itemToAdd.location.x,
y: itemToAdd.location.y,
r: "Horizontal",
},
upd: this.jsonUtil.clone(upd), upd: this.jsonUtil.clone(upd),
}); });
@ -312,11 +306,7 @@ export class InventoryHelper
_tpl: itemLib[tmpKey]._tpl, _tpl: itemLib[tmpKey]._tpl,
parentId: toDo[0][1], parentId: toDo[0][1],
slotId: itemLib[tmpKey].slotId, slotId: itemLib[tmpKey].slotId,
location: { location: {x: itemToAdd.location.x, y: itemToAdd.location.y, r: "Horizontal"},
x: itemToAdd.location.x,
y: itemToAdd.location.y,
r: "Horizontal",
},
upd: this.jsonUtil.clone(upd), upd: this.jsonUtil.clone(upd),
}); });
} }
@ -405,9 +395,7 @@ export class InventoryHelper
} }
catch (err) catch (err)
{ {
const errorText = typeof err === "string" const errorText = typeof err === "string" ? ` -> ${err}` : "";
? ` -> ${err}`
: "";
this.logger.error(this.localisationService.getText("inventory-fill_container_failed", errorText)); this.logger.error(this.localisationService.getText("inventory-fill_container_failed", errorText));
return this.httpResponse.appendErrorToOutput( return this.httpResponse.appendErrorToOutput(
@ -897,10 +885,7 @@ export class InventoryHelper
protected getInventoryItemHash(inventoryItem: Item[]): InventoryHelper.InventoryItemHash protected getInventoryItemHash(inventoryItem: Item[]): InventoryHelper.InventoryItemHash
{ {
const inventoryItemHash: InventoryHelper.InventoryItemHash = { const inventoryItemHash: InventoryHelper.InventoryItemHash = {byItemId: {}, byParentId: {}};
byItemId: {},
byParentId: {},
};
for (const item of inventoryItem) for (const item of inventoryItem)
{ {
@ -942,14 +927,16 @@ export class InventoryHelper
const tmpSize = this.getSizeByInventoryItemHash(item._tpl, item._id, inventoryItemHash); const tmpSize = this.getSizeByInventoryItemHash(item._tpl, item._id, inventoryItemHash);
const iW = tmpSize[0]; // x const iW = tmpSize[0]; // x
const iH = tmpSize[1]; // y const iH = tmpSize[1]; // y
const fH = ((item.location as Location).r === 1 || (item.location as Location).r === "Vertical" const fH =
|| (item.location as Location).rotation === "Vertical") ((item.location as Location).r === 1 || (item.location as Location).r === "Vertical"
? iW || (item.location as Location).rotation === "Vertical")
: iH; ? iW
const fW = ((item.location as Location).r === 1 || (item.location as Location).r === "Vertical" : iH;
|| (item.location as Location).rotation === "Vertical") const fW =
? iH ((item.location as Location).r === 1 || (item.location as Location).r === "Vertical"
: iW; || (item.location as Location).rotation === "Vertical")
? iH
: iW;
const fillTo = (item.location as Location).x + fW; const fillTo = (item.location as Location).x + fW;
for (let y = 0; y < fH; y++) for (let y = 0; y < fH; y++)
@ -1002,9 +989,7 @@ export class InventoryHelper
else if (request.fromOwner.type.toLocaleLowerCase() === "mail") else if (request.fromOwner.type.toLocaleLowerCase() === "mail")
{ {
// Split requests dont use 'use' but 'splitItem' property // Split requests dont use 'use' but 'splitItem' property
const item = "splitItem" in request const item = "splitItem" in request ? request.splitItem : request.item;
? request.splitItem
: request.item;
fromInventoryItems = this.dialogueHelper.getMessageItemContents(request.fromOwner.id, sessionId, item); fromInventoryItems = this.dialogueHelper.getMessageItemContents(request.fromOwner.id, sessionId, item);
fromType = "mail"; fromType = "mail";
} }

View File

@ -176,9 +176,7 @@ class ItemHelper
{ {
if (item.upd === undefined) if (item.upd === undefined)
{ {
item.upd = { item.upd = {StackObjectsCount: 1};
StackObjectsCount: 1,
};
} }
if (item.upd.StackObjectsCount === undefined) if (item.upd.StackObjectsCount === undefined)
@ -243,9 +241,7 @@ class ItemHelper
parentId: parentId, parentId: parentId,
slotId: slotId, slotId: slotId,
location: 0, location: 0,
upd: { upd: {StackObjectsCount: count},
StackObjectsCount: count,
},
}; };
stackSlotItems.push(stackSlotItem); stackSlotItems.push(stackSlotItem);
} }
@ -473,10 +469,7 @@ class ItemHelper
*/ */
public hasBuyRestrictions(itemToCheck: Item): boolean public hasBuyRestrictions(itemToCheck: Item): boolean
{ {
if ( if (itemToCheck.upd?.BuyRestrictionCurrent !== undefined && itemToCheck.upd?.BuyRestrictionMax !== undefined)
itemToCheck.upd?.BuyRestrictionCurrent !== undefined
&& itemToCheck.upd?.BuyRestrictionMax !== undefined
)
{ {
return true; return true;
} }
@ -574,18 +567,14 @@ class ItemHelper
public findBarterItems(by: "tpl" | "id", items: Item[], barterItemId: string): Item[] public findBarterItems(by: "tpl" | "id", items: Item[], barterItemId: string): Item[]
{ {
// find required items to take after buying (handles multiple items) // find required items to take after buying (handles multiple items)
const barterIDs = typeof barterItemId === "string" const barterIDs = typeof barterItemId === "string" ? [barterItemId] : barterItemId;
? [barterItemId]
: barterItemId;
let barterItems: Item[] = []; let barterItems: Item[] = [];
for (const barterID of barterIDs) for (const barterID of barterIDs)
{ {
const filterResult = items.filter((item) => const filterResult = items.filter((item) =>
{ {
return by === "tpl" return by === "tpl" ? (item._tpl === barterID) : (item._id === barterID);
? (item._tpl === barterID)
: (item._id === barterID);
}); });
barterItems = Object.assign(barterItems, filterResult); barterItems = Object.assign(barterItems, filterResult);
@ -954,9 +943,7 @@ class ItemHelper
while (currentStoredCartridgeCount < ammoBoxMaxCartridgeCount) while (currentStoredCartridgeCount < ammoBoxMaxCartridgeCount)
{ {
const remainingSpace = ammoBoxMaxCartridgeCount - currentStoredCartridgeCount; const remainingSpace = ammoBoxMaxCartridgeCount - currentStoredCartridgeCount;
const cartridgeCountToAdd = (remainingSpace < maxPerStack) const cartridgeCountToAdd = (remainingSpace < maxPerStack) ? remainingSpace : maxPerStack;
? remainingSpace
: maxPerStack;
// Add cartridge item into items array // Add cartridge item into items array
ammoBox.push(this.createCartridges(ammoBox[0]._id, cartridgeTpl, cartridgeCountToAdd, location)); ammoBox.push(this.createCartridges(ammoBox[0]._id, cartridgeTpl, cartridgeCountToAdd, location));
@ -1086,10 +1073,8 @@ class ItemHelper
const ammoTpls = magTemplate._props.Cartridges[0]._props.filters[0].Filter; const ammoTpls = magTemplate._props.Cartridges[0]._props.filters[0].Filter;
const calibers = [ const calibers = [
...new Set( ...new Set(
ammoTpls.filter( ammoTpls.filter((x: string) => this.getItem(x)[0]).map((x: string) =>
(x: string) => this.getItem(x)[0], this.getItem(x)[1]._props.Caliber
).map(
(x: string) => this.getItem(x)[1]._props.Caliber,
), ),
), ),
]; ];
@ -1107,9 +1092,7 @@ class ItemHelper
const ammoArray = new ProbabilityObjectArray<string>(this.mathUtil, this.jsonUtil); const ammoArray = new ProbabilityObjectArray<string>(this.mathUtil, this.jsonUtil);
for (const icd of staticAmmoDist[caliber]) for (const icd of staticAmmoDist[caliber])
{ {
ammoArray.push( ammoArray.push(new ProbabilityObject(icd.tpl, icd.relativeProbability));
new ProbabilityObject(icd.tpl, icd.relativeProbability),
);
} }
return ammoArray.draw(1)[0]; return ammoArray.draw(1)[0];
} }

View File

@ -10,14 +10,9 @@ export class NotifierHelper
/** /**
* The default notification sent when waiting times out. * The default notification sent when waiting times out.
*/ */
protected defaultNotification: INotification = { protected defaultNotification: INotification = {type: NotificationType.PING, eventId: "ping"};
type: NotificationType.PING,
eventId: "ping",
};
constructor( constructor(@inject("HttpServerHelper") protected httpServerHelper: HttpServerHelper)
@inject("HttpServerHelper") protected httpServerHelper: HttpServerHelper,
)
{} {}
public getDefaultNotification(): INotification public getDefaultNotification(): INotification

View File

@ -10,9 +10,7 @@ export class PaymentHelper
{ {
protected inventoryConfig: IInventoryConfig; protected inventoryConfig: IInventoryConfig;
constructor( constructor(@inject("ConfigServer") protected configServer: ConfigServer)
@inject("ConfigServer") protected configServer: ConfigServer,
)
{ {
this.inventoryConfig = this.configServer.getConfig(ConfigTypes.INVENTORY); this.inventoryConfig = this.configServer.getConfig(ConfigTypes.INVENTORY);
} }

View File

@ -25,13 +25,13 @@ export class PresetHelper
{ {
if (!this.defaultPresets) if (!this.defaultPresets)
{ {
this.defaultPresets = Object.values(this.databaseServer.getTables().globals.ItemPresets) this.defaultPresets = Object.values(this.databaseServer.getTables().globals.ItemPresets).filter((x) =>
.filter((x) => x._encyclopedia !== undefined) x._encyclopedia !== undefined
.reduce((acc, cur) => ).reduce((acc, cur) =>
{ {
acc[cur._id] = cur; acc[cur._id] = cur;
return acc; return acc;
}, {}); }, {});
} }
return this.defaultPresets; return this.defaultPresets;

View File

@ -217,9 +217,7 @@ export class ProfileHelper
public getDefaultAkiDataObject(): any public getDefaultAkiDataObject(): any
{ {
return { return {version: this.getServerVersion()};
version: this.getServerVersion(),
};
} }
public getFullProfile(sessionID: string): IAkiProfile public getFullProfile(sessionID: string): IAkiProfile
@ -257,11 +255,7 @@ export class ProfileHelper
return { return {
Eft: { Eft: {
CarriedQuestItems: [], CarriedQuestItems: [],
DamageHistory: { DamageHistory: {LethalDamagePart: "Head", LethalDamage: undefined, BodyParts: <any>[]},
LethalDamagePart: "Head",
LethalDamage: undefined,
BodyParts: <any>[],
},
DroppedItems: [], DroppedItems: [],
ExperienceBonusMult: 0, ExperienceBonusMult: 0,
FoundInRaidItems: [], FoundInRaidItems: [],

View File

@ -69,9 +69,7 @@ export class QuestHelper
{ {
const quest = pmcData.Quests?.find((q) => q.qid === questId); const quest = pmcData.Quests?.find((q) => q.qid === questId);
return quest return quest ? quest.status : QuestStatus.Locked;
? quest.status
: QuestStatus.Locked;
} }
/** /**
@ -328,12 +326,9 @@ export class QuestHelper
public getQuestRewardItems(quest: IQuest, status: QuestStatus): Reward[] public getQuestRewardItems(quest: IQuest, status: QuestStatus): Reward[]
{ {
// Iterate over all rewards with the desired status, flatten out items that have a type of Item // Iterate over all rewards with the desired status, flatten out items that have a type of Item
const questRewards = quest.rewards[QuestStatus[status]] const questRewards = quest.rewards[QuestStatus[status]].flatMap((reward: Reward) =>
.flatMap((reward: Reward) => reward.type === "Item" ? this.processReward(reward) : []
reward.type === "Item" );
? this.processReward(reward)
: []
);
return questRewards; return questRewards;
} }
@ -467,14 +462,12 @@ export class QuestHelper
const quests = this.getQuestsFromDb().filter((q) => const quests = this.getQuestsFromDb().filter((q) =>
{ {
const acceptedQuestCondition = q.conditions.AvailableForStart.find( const acceptedQuestCondition = q.conditions.AvailableForStart.find((c) =>
(c) => {
{ return c._parent === "Quest"
return c._parent === "Quest" && c._props.target === failedQuestId
&& c._props.target === failedQuestId && c._props.status[0] === QuestStatus.Fail;
&& c._props.status[0] === QuestStatus.Fail; });
},
);
if (!acceptedQuestCondition) if (!acceptedQuestCondition)
{ {
@ -581,9 +574,7 @@ export class QuestHelper
parentId: item.parentId, parentId: item.parentId,
slotId: item.slotId, slotId: item.slotId,
location: item.location, location: item.location,
upd: { upd: {StackObjectsCount: item.upd.StackObjectsCount},
StackObjectsCount: item.upd.StackObjectsCount,
},
}); });
} }

View File

@ -73,9 +73,7 @@ export class RagfairHelper
if (info.linkedSearchId) if (info.linkedSearchId)
{ {
const data = this.ragfairLinkedItemService.getLinkedItems(info.linkedSearchId); const data = this.ragfairLinkedItemService.getLinkedItems(info.linkedSearchId);
result = !data result = !data ? [] : [...data];
? []
: [...data];
} }
// Case: category // Case: category

View File

@ -61,9 +61,7 @@ export class RagfairSellHelper
playerListedPriceRub: number, playerListedPriceRub: number,
): number ): number
{ {
return (playerListedPriceRub < averageOfferPriceRub) return (playerListedPriceRub < averageOfferPriceRub) ? this.ragfairConfig.sell.chance.underpriced : 1;
? this.ragfairConfig.sell.chance.underpriced
: 1;
} }
/** /**
@ -114,10 +112,7 @@ export class RagfairSellHelper
this.ragfairConfig.sell.time.min * 60, this.ragfairConfig.sell.time.min * 60,
); );
result.push({ result.push({sellTime: sellTime, amount: boughtAmount});
sellTime: sellTime,
amount: boughtAmount,
});
this.logger.debug(`Offer will sell at: ${new Date(sellTime * 1000).toLocaleTimeString("en-US")}`); this.logger.debug(`Offer will sell at: ${new Date(sellTime * 1000).toLocaleTimeString("en-US")}`);
} }

View File

@ -75,11 +75,7 @@ export class RagfairSortHelper
const nameA = locale[`${tplA} Name`] || tplA; const nameA = locale[`${tplA} Name`] || tplA;
const nameB = locale[`${tplB} Name`] || tplB; const nameB = locale[`${tplB} Name`] || tplB;
return (nameA < nameB) return (nameA < nameB) ? -1 : (nameA > nameB) ? 1 : 0;
? -1
: (nameA > nameB)
? 1
: 0;
} }
/** /**

View File

@ -68,10 +68,7 @@ export class RepairHelper
} }
// Construct object to return // Construct object to return
itemToRepair.upd.Repairable = { itemToRepair.upd.Repairable = {Durability: newCurrentDurability, MaxDurability: newCurrentMaxDurability};
Durability: newCurrentDurability,
MaxDurability: newCurrentMaxDurability,
};
// when modders set the repair coefficient to 0 it means that they dont want to lose durability on items // when modders set the repair coefficient to 0 it means that they dont want to lose durability on items
// the code below generates a random degradation on the weapon durability // the code below generates a random degradation on the weapon durability
@ -138,12 +135,8 @@ export class RepairHelper
traderQualityMultipler: number, traderQualityMultipler: number,
): number ): number
{ {
const minRepairDeg = isRepairKit const minRepairDeg = isRepairKit ? itemProps.MinRepairKitDegradation : itemProps.MinRepairDegradation;
? itemProps.MinRepairKitDegradation let maxRepairDeg = isRepairKit ? itemProps.MaxRepairKitDegradation : itemProps.MaxRepairDegradation;
: itemProps.MinRepairDegradation;
let maxRepairDeg = isRepairKit
? itemProps.MaxRepairKitDegradation
: itemProps.MaxRepairDegradation;
// WORKAROUND: Some items are always 0 when repairkit is true // WORKAROUND: Some items are always 0 when repairkit is true
if (maxRepairDeg === 0) if (maxRepairDeg === 0)

View File

@ -14,9 +14,7 @@ export interface OwnerInventoryItems
@injectable() @injectable()
export class SecureContainerHelper export class SecureContainerHelper
{ {
constructor( constructor(@inject("ItemHelper") protected itemHelper: ItemHelper)
@inject("ItemHelper") protected itemHelper: ItemHelper,
)
{} {}
public getSecureContainerItems(items: Item[]): string[] public getSecureContainerItems(items: Item[]): string[]

View File

@ -60,13 +60,11 @@ export class TradeHelper
let output = this.eventOutputHolder.getOutput(sessionID); let output = this.eventOutputHolder.getOutput(sessionID);
const newReq = { const newReq = {
items: [ items: [{
{ // eslint-disable-next-line @typescript-eslint/naming-convention
// eslint-disable-next-line @typescript-eslint/naming-convention item_id: buyRequestData.item_id,
item_id: buyRequestData.item_id, count: buyRequestData.count,
count: buyRequestData.count, }],
},
],
tid: buyRequestData.tid, tid: buyRequestData.tid,
}; };

View File

@ -26,11 +26,7 @@ import { TimeUtil } from "@spt-aki/utils/TimeUtil";
export class TraderAssortHelper export class TraderAssortHelper
{ {
protected traderConfig: ITraderConfig; protected traderConfig: ITraderConfig;
protected mergedQuestAssorts: Record<string, Record<string, string>> = { protected mergedQuestAssorts: Record<string, Record<string, string>> = {started: {}, success: {}, fail: {}};
started: {},
success: {},
fail: {},
};
protected createdMergedQuestAssorts = false; protected createdMergedQuestAssorts = false;
constructor( constructor(

View File

@ -199,9 +199,7 @@ export class TraderHelper
{ {
const newStanding = currentStanding + standingToAdd; const newStanding = currentStanding + standingToAdd;
return newStanding < 0 return newStanding < 0 ? 0 : newStanding;
? 0
: newStanding;
} }
/** /**
@ -229,8 +227,7 @@ export class TraderHelper
if ( if (
(loyalty.minLevel <= pmcData.Info.Level (loyalty.minLevel <= pmcData.Info.Level
&& loyalty.minSalesSum <= pmcData.TradersInfo[traderID].salesSum && loyalty.minSalesSum <= pmcData.TradersInfo[traderID].salesSum
&& loyalty.minStanding <= pmcData.TradersInfo[traderID].standing) && loyalty.minStanding <= pmcData.TradersInfo[traderID].standing) && targetLevel < 4
&& targetLevel < 4
) )
{ {
// level reached // level reached
@ -271,10 +268,7 @@ export class TraderHelper
}), }),
); );
this.traderConfig.updateTime.push( // create temporary entry to prevent logger spam this.traderConfig.updateTime.push( // create temporary entry to prevent logger spam
{ {traderId: traderId, seconds: this.traderConfig.updateTimeDefault},
traderId: traderId,
seconds: this.traderConfig.updateTimeDefault,
},
); );
} }
else else

View File

@ -77,10 +77,7 @@ export class WeightedRandomHelper
{ {
if (cumulativeWeights[itemIndex] >= randomNumber) if (cumulativeWeights[itemIndex] >= randomNumber)
{ {
return { return {item: items[itemIndex], index: itemIndex};
item: items[itemIndex],
index: itemIndex,
};
} }
} }
} }

View File

@ -111,11 +111,7 @@ const createHttpDecorator = (httpMethod: HttpMethods) =>
} }
// Flag the method as a HTTP handler // Flag the method as a HTTP handler
target.handlers.push({ target.handlers.push({handlerName: propertyKey, path, httpMethod});
handlerName: propertyKey,
path,
httpMethod,
});
}; };
}; };
}; };

View File

@ -24,11 +24,7 @@ import { ISettingsBase } from "@spt-aki/models/spt/server/ISettingsBase";
export interface IDatabaseTables export interface IDatabaseTables
{ {
bots?: { bots?: {types: Record<string, IBotType>; base: IBotBase; core: IBotCore;};
types: Record<string, IBotType>;
base: IBotBase;
core: IBotCore;
};
hideout?: { hideout?: {
areas: IHideoutArea[]; areas: IHideoutArea[];
production: IHideoutProduction[]; production: IHideoutProduction[];

View File

@ -22,10 +22,7 @@ export class EventOutputHolder
{} {}
// TODO REMEMBER TO CHANGE OUTPUT // TODO REMEMBER TO CHANGE OUTPUT
protected output: IItemEventRouterResponse = { protected output: IItemEventRouterResponse = {warnings: [], profileChanges: {}};
warnings: [],
profileChanges: {},
};
public getOutput(sessionID: string): IItemEventRouterResponse public getOutput(sessionID: string): IItemEventRouterResponse
{ {
@ -54,18 +51,10 @@ export class EventOutputHolder
ragFairOffers: [], ragFairOffers: [],
weaponBuilds: [], weaponBuilds: [],
equipmentBuilds: [], equipmentBuilds: [],
items: { items: {new: [], change: [], del: []},
new: [],
change: [],
del: [],
},
production: {}, production: {},
improvements: {}, improvements: {},
skills: { skills: {Common: [], Mastering: [], Points: 0},
Common: [],
Mastering: [],
Points: 0,
},
health: this.jsonUtil.clone(pmcData.Health), health: this.jsonUtil.clone(pmcData.Health),
traderRelations: {}, traderRelations: {},
// changedHideoutStashes: {}, // changedHideoutStashes: {},

View File

@ -87,8 +87,6 @@ export class HttpRouter
class ResponseWrapper class ResponseWrapper
{ {
constructor( constructor(public output: string)
public output: string,
)
{} {}
} }

View File

@ -6,41 +6,37 @@ import { DynamicRouter, RouteAction } from "@spt-aki/di/Router";
@injectable() @injectable()
export class BotDynamicRouter extends DynamicRouter export class BotDynamicRouter extends DynamicRouter
{ {
constructor( constructor(@inject("BotCallbacks") protected botCallbacks: BotCallbacks)
@inject("BotCallbacks") protected botCallbacks: BotCallbacks,
)
{ {
super( super([
[ new RouteAction(
new RouteAction( "/singleplayer/settings/bot/limit/",
"/singleplayer/settings/bot/limit/", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.botCallbacks.getBotLimit(url, info, sessionID);
return this.botCallbacks.getBotLimit(url, info, sessionID); },
}, ),
), new RouteAction(
new RouteAction( "/singleplayer/settings/bot/difficulty/",
"/singleplayer/settings/bot/difficulty/", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.botCallbacks.getBotDifficulty(url, info, sessionID);
return this.botCallbacks.getBotDifficulty(url, info, sessionID); },
}, ),
), new RouteAction(
new RouteAction( "/singleplayer/settings/bot/maxCap",
"/singleplayer/settings/bot/maxCap", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.botCallbacks.getBotCap();
return this.botCallbacks.getBotCap(); },
}, ),
), new RouteAction(
new RouteAction( "/singleplayer/settings/bot/getBotBehaviours/",
"/singleplayer/settings/bot/getBotBehaviours/", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.botCallbacks.getBotBehaviours();
return this.botCallbacks.getBotBehaviours(); },
}, ),
), ]);
],
);
} }
} }

View File

@ -6,20 +6,13 @@ import { DynamicRouter, RouteAction } from "@spt-aki/di/Router";
@injectable() @injectable()
export class BundleDynamicRouter extends DynamicRouter export class BundleDynamicRouter extends DynamicRouter
{ {
constructor( constructor(@inject("BundleCallbacks") protected bundleCallbacks: BundleCallbacks)
@inject("BundleCallbacks") protected bundleCallbacks: BundleCallbacks,
)
{ {
super( super([
[ new RouteAction(".bundle", (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
".bundle", return this.bundleCallbacks.getBundle(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => }),
{ ]);
return this.bundleCallbacks.getBundle(url, info, sessionID);
},
),
],
);
} }
} }

View File

@ -6,20 +6,16 @@ import { DynamicRouter, RouteAction } from "@spt-aki/di/Router";
@injectable() @injectable()
export class CustomizationDynamicRouter extends DynamicRouter export class CustomizationDynamicRouter extends DynamicRouter
{ {
constructor( constructor(@inject("CustomizationCallbacks") protected customizationCallbacks: CustomizationCallbacks)
@inject("CustomizationCallbacks") protected customizationCallbacks: CustomizationCallbacks,
)
{ {
super( super([
[ new RouteAction(
new RouteAction( "/client/trading/customization/",
"/client/trading/customization/", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.customizationCallbacks.getTraderSuits(url, info, sessionID);
return this.customizationCallbacks.getTraderSuits(url, info, sessionID); },
}, ),
), ]);
],
);
} }
} }

View File

@ -6,34 +6,21 @@ import { DynamicRouter, RouteAction } from "@spt-aki/di/Router";
@injectable() @injectable()
export class DataDynamicRouter extends DynamicRouter export class DataDynamicRouter extends DynamicRouter
{ {
constructor( constructor(@inject("DataCallbacks") protected dataCallbacks: DataCallbacks)
@inject("DataCallbacks") protected dataCallbacks: DataCallbacks,
)
{ {
super( super([
[ new RouteAction("/client/menu/locale/", (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/client/menu/locale/", return this.dataCallbacks.getLocalesMenu(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => }),
{ new RouteAction("/client/locale/", (url: string, info: any, sessionID: string, output: string): any =>
return this.dataCallbacks.getLocalesMenu(url, info, sessionID); {
}, return this.dataCallbacks.getLocalesGlobal(url, info, sessionID);
), }),
new RouteAction( new RouteAction("/client/items/prices/", (url: string, info: any, sessionID: string, output: string): any =>
"/client/locale/", {
(url: string, info: any, sessionID: string, output: string): any => return this.dataCallbacks.getItemPrices(url, info, sessionID);
{ }),
return this.dataCallbacks.getLocalesGlobal(url, info, sessionID); ]);
},
),
new RouteAction(
"/client/items/prices/",
(url: string, info: any, sessionID: string, output: string): any =>
{
return this.dataCallbacks.getItemPrices(url, info, sessionID);
},
),
],
);
} }
} }

View File

@ -6,34 +6,21 @@ import { ImageRouter } from "@spt-aki/routers/ImageRouter";
@injectable() @injectable()
export class HttpDynamicRouter extends DynamicRouter export class HttpDynamicRouter extends DynamicRouter
{ {
constructor( constructor(@inject("ImageRouter") protected imageRouter: ImageRouter)
@inject("ImageRouter") protected imageRouter: ImageRouter,
)
{ {
super( super([
[ new RouteAction(".jpg", (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
".jpg", return this.imageRouter.getImage();
(url: string, info: any, sessionID: string, output: string): any => }),
{ new RouteAction(".png", (url: string, info: any, sessionID: string, output: string): any =>
return this.imageRouter.getImage(); {
}, return this.imageRouter.getImage();
), }),
new RouteAction( new RouteAction(".ico", (url: string, info: any, sessionID: string, output: string): any =>
".png", {
(url: string, info: any, sessionID: string, output: string): any => return this.imageRouter.getImage();
{ }),
return this.imageRouter.getImage(); ]);
},
),
new RouteAction(
".ico",
(url: string, info: any, sessionID: string, output: string): any =>
{
return this.imageRouter.getImage();
},
),
],
);
} }
} }

View File

@ -6,21 +6,17 @@ import { DynamicRouter, RouteAction } from "@spt-aki/di/Router";
@injectable() @injectable()
export class InraidDynamicRouter extends DynamicRouter export class InraidDynamicRouter extends DynamicRouter
{ {
constructor( constructor(@inject("InraidCallbacks") protected inraidCallbacks: InraidCallbacks)
@inject("InraidCallbacks") protected inraidCallbacks: InraidCallbacks,
)
{ {
super( super([
[ new RouteAction(
new RouteAction( "/client/location/getLocalloot",
"/client/location/getLocalloot", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.inraidCallbacks.registerPlayer(url, info, sessionID);
return this.inraidCallbacks.registerPlayer(url, info, sessionID); },
}, ),
), ]);
],
);
} }
public override getTopLevelRoute(): string public override getTopLevelRoute(): string

View File

@ -6,21 +6,17 @@ import { DynamicRouter, RouteAction } from "@spt-aki/di/Router";
@injectable() @injectable()
export class LocationDynamicRouter extends DynamicRouter export class LocationDynamicRouter extends DynamicRouter
{ {
constructor( constructor(@inject("LocationCallbacks") protected locationCallbacks: LocationCallbacks)
@inject("LocationCallbacks") protected locationCallbacks: LocationCallbacks,
)
{ {
super( super([
[ new RouteAction(
new RouteAction( "/client/location/getLocalloot",
"/client/location/getLocalloot", (url: string, info: any, sessionID: string, _output: string): any =>
(url: string, info: any, sessionID: string, _output: string): any => {
{ return this.locationCallbacks.getLocation(url, info, sessionID);
return this.locationCallbacks.getLocation(url, info, sessionID); },
}, ),
), ]);
],
);
} }
public override getTopLevelRoute(): string public override getTopLevelRoute(): string

View File

@ -6,41 +6,28 @@ import { DynamicRouter, RouteAction } from "@spt-aki/di/Router";
@injectable() @injectable()
export class NotifierDynamicRouter extends DynamicRouter export class NotifierDynamicRouter extends DynamicRouter
{ {
constructor( constructor(@inject("NotifierCallbacks") protected notifierCallbacks: NotifierCallbacks)
@inject("NotifierCallbacks") protected notifierCallbacks: NotifierCallbacks,
)
{ {
super( super([
[ new RouteAction("/?last_id", (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/?last_id", return this.notifierCallbacks.notify(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => }),
{ new RouteAction("/notifierServer", (url: string, info: any, sessionID: string, output: string): any =>
return this.notifierCallbacks.notify(url, info, sessionID); {
}, return this.notifierCallbacks.notify(url, info, sessionID);
), }),
new RouteAction( new RouteAction("/push/notifier/get/", (url: string, info: any, sessionID: string, output: string): any =>
"/notifierServer", {
(url: string, info: any, sessionID: string, output: string): any => return this.notifierCallbacks.getNotifier(url, info, sessionID);
{ }),
return this.notifierCallbacks.notify(url, info, sessionID); new RouteAction(
}, "/push/notifier/getwebsocket/",
), (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/push/notifier/get/", return this.notifierCallbacks.getNotifier(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => },
{ ),
return this.notifierCallbacks.getNotifier(url, info, sessionID); ]);
},
),
new RouteAction(
"/push/notifier/getwebsocket/",
(url: string, info: any, sessionID: string, output: string): any =>
{
return this.notifierCallbacks.getNotifier(url, info, sessionID);
},
),
],
);
} }
} }

View File

@ -6,27 +6,23 @@ import { DynamicRouter, RouteAction } from "@spt-aki/di/Router";
@injectable() @injectable()
export class TraderDynamicRouter extends DynamicRouter export class TraderDynamicRouter extends DynamicRouter
{ {
constructor( constructor(@inject("TraderCallbacks") protected traderCallbacks: TraderCallbacks)
@inject("TraderCallbacks") protected traderCallbacks: TraderCallbacks,
)
{ {
super( super([
[ new RouteAction(
new RouteAction( "/client/trading/api/getTrader/",
"/client/trading/api/getTrader/", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.traderCallbacks.getTrader(url, info, sessionID);
return this.traderCallbacks.getTrader(url, info, sessionID); },
}, ),
), new RouteAction(
new RouteAction( "/client/trading/api/getTraderAssort/",
"/client/trading/api/getTraderAssort/", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.traderCallbacks.getAssort(url, info, sessionID);
return this.traderCallbacks.getAssort(url, info, sessionID); },
}, ),
), ]);
],
);
} }
} }

View File

@ -17,10 +17,7 @@ export class CustomizationItemEventRouter extends ItemEventRouterDefinition
public override getHandledRoutes(): HandledRoute[] public override getHandledRoutes(): HandledRoute[]
{ {
return [ return [new HandledRoute("CustomizationWear", false), new HandledRoute("CustomizationBuy", false)];
new HandledRoute("CustomizationWear", false),
new HandledRoute("CustomizationBuy", false),
];
} }
public override handleItemEvent( public override handleItemEvent(

View File

@ -9,9 +9,7 @@ import { HideoutEventActions } from "@spt-aki/models/enums/HideoutEventActions";
@injectable() @injectable()
export class HideoutItemEventRouter extends ItemEventRouterDefinition export class HideoutItemEventRouter extends ItemEventRouterDefinition
{ {
constructor( constructor(@inject("HideoutCallbacks") protected hideoutCallbacks: HideoutCallbacks)
@inject("HideoutCallbacks") protected hideoutCallbacks: HideoutCallbacks,
)
{ {
super(); super();
} }

View File

@ -17,9 +17,7 @@ export class InsuranceItemEventRouter extends ItemEventRouterDefinition
public override getHandledRoutes(): HandledRoute[] public override getHandledRoutes(): HandledRoute[]
{ {
return [ return [new HandledRoute("Insure", false)];
new HandledRoute("Insure", false),
];
} }
public override handleItemEvent( public override handleItemEvent(

View File

@ -9,9 +9,7 @@ import { ItemEventActions } from "@spt-aki/models/enums/ItemEventActions";
@injectable() @injectable()
export class PresetBuildItemEventRouter extends ItemEventRouterDefinition export class PresetBuildItemEventRouter extends ItemEventRouterDefinition
{ {
constructor( constructor(@inject("PresetBuildCallbacks") protected presetBuildCallbacks: PresetBuildCallbacks)
@inject("PresetBuildCallbacks") protected presetBuildCallbacks: PresetBuildCallbacks,
)
{ {
super(); super();
} }

View File

@ -8,9 +8,7 @@ import { IItemEventRouterResponse } from "@spt-aki/models/eft/itemEvent/IItemEve
@injectable() @injectable()
export class RagfairItemEventRouter extends ItemEventRouterDefinition export class RagfairItemEventRouter extends ItemEventRouterDefinition
{ {
constructor( constructor(@inject("RagfairCallbacks") protected ragfairCallbacks: RagfairCallbacks)
@inject("RagfairCallbacks") protected ragfairCallbacks: RagfairCallbacks,
)
{ {
super(); super();
} }

View File

@ -8,19 +8,14 @@ import { IItemEventRouterResponse } from "@spt-aki/models/eft/itemEvent/IItemEve
@injectable() @injectable()
export class RepairItemEventRouter extends ItemEventRouterDefinition export class RepairItemEventRouter extends ItemEventRouterDefinition
{ {
constructor( constructor(@inject("RepairCallbacks") protected repairCallbacks: RepairCallbacks)
@inject("RepairCallbacks") protected repairCallbacks: RepairCallbacks,
)
{ {
super(); super();
} }
public override getHandledRoutes(): HandledRoute[] public override getHandledRoutes(): HandledRoute[]
{ {
return [ return [new HandledRoute("Repair", false), new HandledRoute("TraderRepair", false)];
new HandledRoute("Repair", false),
new HandledRoute("TraderRepair", false),
];
} }
public override handleItemEvent( public override handleItemEvent(

View File

@ -8,9 +8,7 @@ import { IItemEventRouterResponse } from "@spt-aki/models/eft/itemEvent/IItemEve
@injectable() @injectable()
export class TradeItemEventRouter extends ItemEventRouterDefinition export class TradeItemEventRouter extends ItemEventRouterDefinition
{ {
constructor( constructor(@inject("TradeCallbacks") protected tradeCallbacks: TradeCallbacks)
@inject("TradeCallbacks") protected tradeCallbacks: TradeCallbacks,
)
{ {
super(); super();
} }

View File

@ -8,19 +8,14 @@ import { IItemEventRouterResponse } from "@spt-aki/models/eft/itemEvent/IItemEve
@injectable() @injectable()
export class WishlistItemEventRouter extends ItemEventRouterDefinition export class WishlistItemEventRouter extends ItemEventRouterDefinition
{ {
constructor( constructor(@inject("WishlistCallbacks") protected wishlistCallbacks: WishlistCallbacks)
@inject("WishlistCallbacks") protected wishlistCallbacks: WishlistCallbacks,
)
{ {
super(); super();
} }
public override getHandledRoutes(): HandledRoute[] public override getHandledRoutes(): HandledRoute[]
{ {
return [ return [new HandledRoute("AddToWishList", false), new HandledRoute("RemoveFromWishList", false)];
new HandledRoute("AddToWishList", false),
new HandledRoute("RemoveFromWishList", false),
];
} }
public override handleItemEvent( public override handleItemEvent(

View File

@ -8,19 +8,14 @@ export class HealthSaveLoadRouter extends SaveLoadRouter
{ {
public override getHandledRoutes(): HandledRoute[] public override getHandledRoutes(): HandledRoute[]
{ {
return [ return [new HandledRoute("aki-health", false)];
new HandledRoute("aki-health", false),
];
} }
public override handleLoad(profile: IAkiProfile): IAkiProfile public override handleLoad(profile: IAkiProfile): IAkiProfile
{ {
if (!profile.vitality) if (!profile.vitality)
{ // Occurs on newly created profiles { // Occurs on newly created profiles
profile.vitality = { profile.vitality = {health: null, effects: null};
health: null,
effects: null,
};
} }
profile.vitality.health = { profile.vitality.health = {
Hydration: 0, Hydration: 0,

View File

@ -8,19 +8,14 @@ export class InraidSaveLoadRouter extends SaveLoadRouter
{ {
public override getHandledRoutes(): HandledRoute[] public override getHandledRoutes(): HandledRoute[]
{ {
return [ return [new HandledRoute("aki-inraid", false)];
new HandledRoute("aki-inraid", false),
];
} }
public override handleLoad(profile: IAkiProfile): IAkiProfile public override handleLoad(profile: IAkiProfile): IAkiProfile
{ {
if (profile.inraid === undefined) if (profile.inraid === undefined)
{ {
profile.inraid = { profile.inraid = {location: "none", character: "none"};
location: "none",
character: "none",
};
} }
return profile; return profile;

View File

@ -8,9 +8,7 @@ export class InsuranceSaveLoadRouter extends SaveLoadRouter
{ {
public override getHandledRoutes(): HandledRoute[] public override getHandledRoutes(): HandledRoute[]
{ {
return [ return [new HandledRoute("aki-insurance", false)];
new HandledRoute("aki-insurance", false),
];
} }
public override handleLoad(profile: IAkiProfile): IAkiProfile public override handleLoad(profile: IAkiProfile): IAkiProfile

View File

@ -9,19 +9,14 @@ export class ProfileSaveLoadRouter extends SaveLoadRouter
{ {
public override getHandledRoutes(): HandledRoute[] public override getHandledRoutes(): HandledRoute[]
{ {
return [ return [new HandledRoute("aki-profile", false)];
new HandledRoute("aki-profile", false),
];
} }
public override handleLoad(profile: IAkiProfile): IAkiProfile public override handleLoad(profile: IAkiProfile): IAkiProfile
{ {
if (profile.characters === null) if (profile.characters === null)
{ {
profile.characters = { profile.characters = {pmc: {} as IPmcData, scav: {} as IPmcData};
pmc: {} as IPmcData,
scav: {} as IPmcData,
};
} }
return profile; return profile;
} }

View File

@ -7,9 +7,7 @@ import { ImageRouter } from "@spt-aki/routers/ImageRouter";
@injectable() @injectable()
export class ImageSerializer extends Serializer export class ImageSerializer extends Serializer
{ {
constructor( constructor(@inject("ImageRouter") protected imageRouter: ImageRouter)
@inject("ImageRouter") protected imageRouter: ImageRouter,
)
{ {
super(); super();
} }

View File

@ -27,9 +27,9 @@ export class NotifySerializer extends Serializer
* Take our array of JSON message objects and cast them to JSON strings, so that they can then * Take our array of JSON message objects and cast them to JSON strings, so that they can then
* be sent to client as NEWLINE separated strings... yup. * be sent to client as NEWLINE separated strings... yup.
*/ */
this.notifierController.notifyAsync(tmpSessionID) this.notifierController.notifyAsync(tmpSessionID).then((messages: any) =>
.then((messages: any) => messages.map((message: any) => this.jsonUtil.serialize(message)).join("\n")) messages.map((message: any) => this.jsonUtil.serialize(message)).join("\n")
.then((text) => this.httpServerHelper.sendTextJson(resp, text)); ).then((text) => this.httpServerHelper.sendTextJson(resp, text));
} }
public override canHandle(route: string): boolean public override canHandle(route: string): boolean

View File

@ -6,20 +6,16 @@ import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
@injectable() @injectable()
export class BotStaticRouter extends StaticRouter export class BotStaticRouter extends StaticRouter
{ {
constructor( constructor(@inject("BotCallbacks") protected botCallbacks: BotCallbacks)
@inject("BotCallbacks") protected botCallbacks: BotCallbacks,
)
{ {
super( super([
[ new RouteAction(
new RouteAction( "/client/game/bot/generate",
"/client/game/bot/generate", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.botCallbacks.generateBots(url, info, sessionID);
return this.botCallbacks.generateBots(url, info, sessionID); },
}, ),
), ]);
],
);
} }
} }

View File

@ -6,20 +6,13 @@ import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
@injectable() @injectable()
export class BundleStaticRouter extends StaticRouter export class BundleStaticRouter extends StaticRouter
{ {
constructor( constructor(@inject("BundleCallbacks") protected bundleCallbacks: BundleCallbacks)
@inject("BundleCallbacks") protected bundleCallbacks: BundleCallbacks,
)
{ {
super( super([
[ new RouteAction("/singleplayer/bundles", (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/singleplayer/bundles", return this.bundleCallbacks.getBundles(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => }),
{ ]);
return this.bundleCallbacks.getBundles(url, info, sessionID);
},
),
],
);
} }
} }

View File

@ -6,20 +6,13 @@ import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
@injectable() @injectable()
export class ClientLogStaticRouter extends StaticRouter export class ClientLogStaticRouter extends StaticRouter
{ {
constructor( constructor(@inject("ClientLogCallbacks") protected clientLogCallbacks: ClientLogCallbacks)
@inject("ClientLogCallbacks") protected clientLogCallbacks: ClientLogCallbacks,
)
{ {
super( super([
[ new RouteAction("/singleplayer/log", (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/singleplayer/log", return this.clientLogCallbacks.clientLog(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => }),
{ ]);
return this.clientLogCallbacks.clientLog(url, info, sessionID);
},
),
],
);
} }
} }

View File

@ -6,20 +6,16 @@ import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
@injectable() @injectable()
export class CustomizationStaticRouter extends StaticRouter export class CustomizationStaticRouter extends StaticRouter
{ {
constructor( constructor(@inject("CustomizationCallbacks") protected customizationCallbacks: CustomizationCallbacks)
@inject("CustomizationCallbacks") protected customizationCallbacks: CustomizationCallbacks,
)
{ {
super( super([
[ new RouteAction(
new RouteAction( "/client/trading/customization/storage",
"/client/trading/customization/storage", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.customizationCallbacks.getSuits(url, info, sessionID);
return this.customizationCallbacks.getSuits(url, info, sessionID); },
}, ),
), ]);
],
);
} }
} }

View File

@ -6,97 +6,75 @@ import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
@injectable() @injectable()
export class DataStaticRouter extends StaticRouter export class DataStaticRouter extends StaticRouter
{ {
constructor( constructor(@inject("DataCallbacks") protected dataCallbacks: DataCallbacks)
@inject("DataCallbacks") protected dataCallbacks: DataCallbacks,
)
{ {
super( super([
[ new RouteAction("/client/settings", (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/client/settings", return this.dataCallbacks.getSettings(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => }),
{ new RouteAction("/client/globals", (url: string, info: any, sessionID: string, output: string): any =>
return this.dataCallbacks.getSettings(url, info, sessionID); {
}, return this.dataCallbacks.getGlobals(url, info, sessionID);
), }),
new RouteAction( new RouteAction("/client/items", (url: string, info: any, sessionID: string, output: string): any =>
"/client/globals", {
(url: string, info: any, sessionID: string, output: string): any => return this.dataCallbacks.getTemplateItems(url, info, sessionID);
{ }),
return this.dataCallbacks.getGlobals(url, info, sessionID); new RouteAction(
}, "/client/handbook/templates",
), (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/client/items", return this.dataCallbacks.getTemplateHandbook(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => },
{ ),
return this.dataCallbacks.getTemplateItems(url, info, sessionID); new RouteAction("/client/customization", (url: string, info: any, sessionID: string, output: string): any =>
}, {
), return this.dataCallbacks.getTemplateSuits(url, info, sessionID);
new RouteAction( }),
"/client/handbook/templates", new RouteAction(
(url: string, info: any, sessionID: string, output: string): any => "/client/account/customization",
{ (url: string, info: any, sessionID: string, output: string): any =>
return this.dataCallbacks.getTemplateHandbook(url, info, sessionID); {
}, return this.dataCallbacks.getTemplateCharacter(url, info, sessionID);
), },
new RouteAction( ),
"/client/customization", new RouteAction(
(url: string, info: any, sessionID: string, output: string): any => "/client/hideout/production/recipes",
{ (url: string, info: any, sessionID: string, output: string): any =>
return this.dataCallbacks.getTemplateSuits(url, info, sessionID); {
}, return this.dataCallbacks.gethideoutProduction(url, info, sessionID);
), },
new RouteAction( ),
"/client/account/customization", new RouteAction(
(url: string, info: any, sessionID: string, output: string): any => "/client/hideout/settings",
{ (url: string, info: any, sessionID: string, output: string): any =>
return this.dataCallbacks.getTemplateCharacter(url, info, sessionID); {
}, return this.dataCallbacks.getHideoutSettings(url, info, sessionID);
), },
new RouteAction( ),
"/client/hideout/production/recipes", new RouteAction("/client/hideout/areas", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.dataCallbacks.getHideoutAreas(url, info, sessionID);
return this.dataCallbacks.gethideoutProduction(url, info, sessionID); }),
}, new RouteAction(
), "/client/hideout/production/scavcase/recipes",
new RouteAction( (url: string, info: any, sessionID: string, output: string): any =>
"/client/hideout/settings", {
(url: string, info: any, sessionID: string, output: string): any => return this.dataCallbacks.getHideoutScavcase(url, info, sessionID);
{ },
return this.dataCallbacks.getHideoutSettings(url, info, sessionID); ),
}, new RouteAction("/client/languages", (url: string, info: any, sessionID: string, output: string): any =>
), {
new RouteAction( return this.dataCallbacks.getLocalesLanguages(url, info, sessionID);
"/client/hideout/areas", }),
(url: string, info: any, sessionID: string, output: string): any => new RouteAction(
{ "/client/hideout/qte/list",
return this.dataCallbacks.getHideoutAreas(url, info, sessionID); (url: string, info: any, sessionID: string, output: string): any =>
}, {
), return this.dataCallbacks.getQteList(url, info, sessionID);
new RouteAction( },
"/client/hideout/production/scavcase/recipes", ),
(url: string, info: any, sessionID: string, output: string): any => ]);
{
return this.dataCallbacks.getHideoutScavcase(url, info, sessionID);
},
),
new RouteAction(
"/client/languages",
(url: string, info: any, sessionID: string, output: string): any =>
{
return this.dataCallbacks.getLocalesLanguages(url, info, sessionID);
},
),
new RouteAction(
"/client/hideout/qte/list",
(url: string, info: any, sessionID: string, output: string): any =>
{
return this.dataCallbacks.getQteList(url, info, sessionID);
},
),
],
);
} }
} }

View File

@ -6,160 +6,147 @@ import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
@injectable() @injectable()
export class DialogStaticRouter extends StaticRouter export class DialogStaticRouter extends StaticRouter
{ {
constructor( constructor(@inject("DialogueCallbacks") protected dialogueCallbacks: DialogueCallbacks)
@inject("DialogueCallbacks") protected dialogueCallbacks: DialogueCallbacks,
)
{ {
super( super([
[ new RouteAction(
new RouteAction( "/client/chatServer/list",
"/client/chatServer/list", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.dialogueCallbacks.getChatServerList(url, info, sessionID);
return this.dialogueCallbacks.getChatServerList(url, info, sessionID); },
}, ),
), new RouteAction(
new RouteAction( "/client/mail/dialog/list",
"/client/mail/dialog/list", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.dialogueCallbacks.getMailDialogList(url, info, sessionID);
return this.dialogueCallbacks.getMailDialogList(url, info, sessionID); },
}, ),
), new RouteAction(
new RouteAction( "/client/mail/dialog/view",
"/client/mail/dialog/view", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.dialogueCallbacks.getMailDialogView(url, info, sessionID);
return this.dialogueCallbacks.getMailDialogView(url, info, sessionID); },
}, ),
), new RouteAction(
new RouteAction( "/client/mail/dialog/info",
"/client/mail/dialog/info", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.dialogueCallbacks.getMailDialogInfo(url, info, sessionID);
return this.dialogueCallbacks.getMailDialogInfo(url, info, sessionID); },
}, ),
), new RouteAction(
new RouteAction( "/client/mail/dialog/remove",
"/client/mail/dialog/remove", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.dialogueCallbacks.removeDialog(url, info, sessionID);
return this.dialogueCallbacks.removeDialog(url, info, sessionID); },
}, ),
), new RouteAction(
new RouteAction( "/client/mail/dialog/pin",
"/client/mail/dialog/pin", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.dialogueCallbacks.pinDialog(url, info, sessionID);
return this.dialogueCallbacks.pinDialog(url, info, sessionID); },
}, ),
), new RouteAction(
new RouteAction( "/client/mail/dialog/unpin",
"/client/mail/dialog/unpin", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.dialogueCallbacks.unpinDialog(url, info, sessionID);
return this.dialogueCallbacks.unpinDialog(url, info, sessionID); },
}, ),
), new RouteAction(
new RouteAction( "/client/mail/dialog/read",
"/client/mail/dialog/read", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.dialogueCallbacks.setRead(url, info, sessionID);
return this.dialogueCallbacks.setRead(url, info, sessionID); },
}, ),
), new RouteAction(
new RouteAction( "/client/mail/dialog/remove",
"/client/mail/dialog/remove", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.dialogueCallbacks.removeMail(url, info, sessionID);
return this.dialogueCallbacks.removeMail(url, info, sessionID); },
}, ),
), new RouteAction(
new RouteAction( "/client/mail/dialog/getAllAttachments",
"/client/mail/dialog/getAllAttachments", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.dialogueCallbacks.getAllAttachments(url, info, sessionID);
return this.dialogueCallbacks.getAllAttachments(url, info, sessionID); },
}, ),
), new RouteAction("/client/mail/msg/send", (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/client/mail/msg/send", return this.dialogueCallbacks.sendMessage(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => }),
{ new RouteAction(
return this.dialogueCallbacks.sendMessage(url, info, sessionID); "/client/mail/dialog/clear",
}, (url: string, info: any, sessionID: string, output: string): any =>
), {
new RouteAction( return this.dialogueCallbacks.clearMail(url, info, sessionID);
"/client/mail/dialog/clear", },
(url: string, info: any, sessionID: string, output: string): any => ),
{ new RouteAction("/client/friend/list", (url: string, info: any, sessionID: string, output: string): any =>
return this.dialogueCallbacks.clearMail(url, info, sessionID); {
}, return this.dialogueCallbacks.getFriendList(url, info, sessionID);
), }),
new RouteAction( new RouteAction(
"/client/friend/list", "/client/friend/request/list/outbox",
(url: string, info: any, sessionID: string, output: string): any => (url: string, info: any, sessionID: string, output: string): any =>
{ {
return this.dialogueCallbacks.getFriendList(url, info, sessionID); return this.dialogueCallbacks.listOutbox(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/friend/request/list/outbox", "/client/friend/request/list/inbox",
(url: string, info: any, sessionID: string, output: string): any => (url: string, info: any, sessionID: string, output: string): any =>
{ {
return this.dialogueCallbacks.listOutbox(url, info, sessionID); return this.dialogueCallbacks.listInbox(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/friend/request/list/inbox", "/client/friend/request/send",
(url: string, info: any, sessionID: string, output: string): any => (url: string, info: any, sessionID: string, output: string): any =>
{ {
return this.dialogueCallbacks.listInbox(url, info, sessionID); return this.dialogueCallbacks.sendFriendRequest(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/friend/request/send", "/client/friend/request/accept",
(url: string, info: any, sessionID: string, output: string): any => (url: string, info: any, sessionID: string, output: string): any =>
{ {
return this.dialogueCallbacks.sendFriendRequest(url, info, sessionID); return this.dialogueCallbacks.acceptFriendRequest(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/friend/request/accept", "/client/friend/request/cancel",
(url: string, info: any, sessionID: string, output: string): any => (url: string, info: any, sessionID: string, output: string): any =>
{ {
return this.dialogueCallbacks.acceptFriendRequest(url, info, sessionID); return this.dialogueCallbacks.cancelFriendRequest(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction("/client/friend/delete", (url: string, info: any, sessionID: string, output: string): any =>
"/client/friend/request/cancel", {
(url: string, info: any, sessionID: string, output: string): any => return this.dialogueCallbacks.deleteFriend(url, info, sessionID);
{ }),
return this.dialogueCallbacks.cancelFriendRequest(url, info, sessionID); new RouteAction(
}, "/client/friend/ignore/set",
), (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/client/friend/delete", return this.dialogueCallbacks.ignoreFriend(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => },
{ ),
return this.dialogueCallbacks.deleteFriend(url, info, sessionID); new RouteAction(
}, "/client/friend/ignore/remove",
), (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/client/friend/ignore/set", return this.dialogueCallbacks.unIgnoreFriend(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => },
{ ),
return this.dialogueCallbacks.ignoreFriend(url, info, sessionID); ]);
},
),
new RouteAction(
"/client/friend/ignore/remove",
(url: string, info: any, sessionID: string, output: string): any =>
{
return this.dialogueCallbacks.unIgnoreFriend(url, info, sessionID);
},
),
],
);
} }
} }

View File

@ -6,83 +6,64 @@ import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
@injectable() @injectable()
export class GameStaticRouter extends StaticRouter export class GameStaticRouter extends StaticRouter
{ {
constructor( constructor(@inject("GameCallbacks") protected gameCallbacks: GameCallbacks)
@inject("GameCallbacks") protected gameCallbacks: GameCallbacks,
)
{ {
super( super([
[ new RouteAction("/client/game/config", (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/client/game/config", return this.gameCallbacks.getGameConfig(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => }),
{ new RouteAction("/client/server/list", (url: string, info: any, sessionID: string, output: string): any =>
return this.gameCallbacks.getGameConfig(url, info, sessionID); {
}, return this.gameCallbacks.getServer(url, info, sessionID);
), }),
new RouteAction( new RouteAction(
"/client/server/list", "/client/match/group/current",
(url: string, info: any, sessionID: string, output: string): any => (url: string, info: any, sessionID: string, output: string): any =>
{ {
return this.gameCallbacks.getServer(url, info, sessionID); return this.gameCallbacks.getCurrentGroup(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/client/match/group/current", "/client/game/version/validate",
(url: string, info: any, sessionID: string, output: string): any => (url: string, info: any, sessionID: string, output: string): any =>
{ {
return this.gameCallbacks.getCurrentGroup(url, info, sessionID); return this.gameCallbacks.versionValidate(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction("/client/game/start", (url: string, info: any, sessionID: string, output: string): any =>
"/client/game/version/validate", {
(url: string, info: any, sessionID: string, output: string): any => return this.gameCallbacks.gameStart(url, info, sessionID);
{ }),
return this.gameCallbacks.versionValidate(url, info, sessionID); new RouteAction("/client/game/logout", (url: string, info: any, sessionID: string, output: string): any =>
}, {
), return this.gameCallbacks.gameLogout(url, info, sessionID);
new RouteAction( }),
"/client/game/start", new RouteAction("/client/checkVersion", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.gameCallbacks.validateGameVersion(url, info, sessionID);
return this.gameCallbacks.gameStart(url, info, sessionID); }),
}, new RouteAction(
), "/client/game/keepalive",
new RouteAction( (url: string, info: any, sessionID: string, output: string): any =>
"/client/game/logout", {
(url: string, info: any, sessionID: string, output: string): any => return this.gameCallbacks.gameKeepalive(url, info, sessionID);
{ },
return this.gameCallbacks.gameLogout(url, info, sessionID); ),
}, new RouteAction(
), "/singleplayer/settings/version",
new RouteAction( (url: string, info: any, sessionID: string, output: string): any =>
"/client/checkVersion", {
(url: string, info: any, sessionID: string, output: string): any => return this.gameCallbacks.getVersion(url, info, sessionID);
{ },
return this.gameCallbacks.validateGameVersion(url, info, sessionID); ),
}, new RouteAction(
), "/client/reports/lobby/send",
new RouteAction( (url: string, info: any, sessionID: string, output: string): any =>
"/client/game/keepalive", {
(url: string, info: any, sessionID: string, output: string): any => return this.gameCallbacks.reportNickname(url, info, sessionID);
{ },
return this.gameCallbacks.gameKeepalive(url, info, sessionID); ),
}, ]);
),
new RouteAction(
"/singleplayer/settings/version",
(url: string, info: any, sessionID: string, output: string): any =>
{
return this.gameCallbacks.getVersion(url, info, sessionID);
},
),
new RouteAction(
"/client/reports/lobby/send",
(url: string, info: any, sessionID: string, output: string): any =>
{
return this.gameCallbacks.reportNickname(url, info, sessionID);
},
),
],
);
} }
} }

View File

@ -6,27 +6,20 @@ import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
@injectable() @injectable()
export class HealthStaticRouter extends StaticRouter export class HealthStaticRouter extends StaticRouter
{ {
constructor( constructor(@inject("HealthCallbacks") protected healthCallbacks: HealthCallbacks)
@inject("HealthCallbacks") protected healthCallbacks: HealthCallbacks,
)
{ {
super( super([
[ new RouteAction("/player/health/sync", (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/player/health/sync", return this.healthCallbacks.syncHealth(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => }),
{ new RouteAction(
return this.healthCallbacks.syncHealth(url, info, sessionID); "/client/hideout/workout",
}, (url: string, info: any, sessionID: string, output: string): any =>
), {
new RouteAction( return this.healthCallbacks.handleWorkoutEffects(url, info, sessionID);
"/client/hideout/workout", },
(url: string, info: any, sessionID: string, output: string): any => ),
{ ]);
return this.healthCallbacks.handleWorkoutEffects(url, info, sessionID);
},
),
],
);
} }
} }

View File

@ -6,48 +6,41 @@ import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
@injectable() @injectable()
export class InraidStaticRouter extends StaticRouter export class InraidStaticRouter extends StaticRouter
{ {
constructor( constructor(@inject("InraidCallbacks") protected inraidCallbacks: InraidCallbacks)
@inject("InraidCallbacks") protected inraidCallbacks: InraidCallbacks,
)
{ {
super( super([
[ new RouteAction("/raid/profile/save", (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/raid/profile/save", return this.inraidCallbacks.saveProgress(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => }),
{ new RouteAction(
return this.inraidCallbacks.saveProgress(url, info, sessionID); "/singleplayer/settings/raid/endstate",
}, (url: string, info: any, sessionID: string, output: string): any =>
), {
new RouteAction( return this.inraidCallbacks.getRaidEndState();
"/singleplayer/settings/raid/endstate", },
(url: string, info: any, sessionID: string, output: string): any => ),
{ new RouteAction(
return this.inraidCallbacks.getRaidEndState(); "/singleplayer/settings/weapon/durability",
}, (url: string, info: any, sessionID: string, output: string): any =>
), {
new RouteAction( return this.inraidCallbacks.getWeaponDurability();
"/singleplayer/settings/weapon/durability", },
(url: string, info: any, sessionID: string, output: string): any => ),
{ new RouteAction(
return this.inraidCallbacks.getWeaponDurability(); "/singleplayer/settings/raid/menu",
}, (url: string, info: any, sessionID: string, output: string): any =>
), {
new RouteAction( return this.inraidCallbacks.getRaidMenuSettings();
"/singleplayer/settings/raid/menu", },
(url: string, info: any, sessionID: string, output: string): any => ),
{ new RouteAction(
return this.inraidCallbacks.getRaidMenuSettings(); "/singleplayer/airdrop/config",
}, (url: string, info: any, sessionID: string, output: string): any =>
), {
new RouteAction( return this.inraidCallbacks.getAirdropConfig();
"/singleplayer/airdrop/config", },
(url: string, info: any, sessionID: string, output: string): any => ),
{ ]);
return this.inraidCallbacks.getAirdropConfig();
},
),
],
);
} }
} }

View File

@ -6,20 +6,16 @@ import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
@injectable() @injectable()
export class InsuranceStaticRouter extends StaticRouter export class InsuranceStaticRouter extends StaticRouter
{ {
constructor( constructor(@inject("InsuranceCallbacks") protected insuranceCallbacks: InsuranceCallbacks)
@inject("InsuranceCallbacks") protected insuranceCallbacks: InsuranceCallbacks,
)
{ {
super( super([
[ new RouteAction(
new RouteAction( "/client/insurance/items/list/cost",
"/client/insurance/items/list/cost", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.insuranceCallbacks.getInsuranceCost(url, info, sessionID);
return this.insuranceCallbacks.getInsuranceCost(url, info, sessionID); },
}, ),
), ]);
],
);
} }
} }

View File

@ -6,20 +6,16 @@ import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
@injectable() @injectable()
export class ItemEventStaticRouter extends StaticRouter export class ItemEventStaticRouter extends StaticRouter
{ {
constructor( constructor(@inject("ItemEventCallbacks") protected itemEventCallbacks: ItemEventCallbacks)
@inject("ItemEventCallbacks") protected itemEventCallbacks: ItemEventCallbacks,
)
{ {
super( super([
[ new RouteAction(
new RouteAction( "/client/game/profile/items/moving",
"/client/game/profile/items/moving", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.itemEventCallbacks.handleEvents(url, info, sessionID);
return this.itemEventCallbacks.handleEvents(url, info, sessionID); },
}, ),
), ]);
],
);
} }
} }

View File

@ -6,104 +6,94 @@ import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
@injectable() @injectable()
export class LauncherStaticRouter extends StaticRouter export class LauncherStaticRouter extends StaticRouter
{ {
constructor( constructor(@inject("LauncherCallbacks") protected launcherCallbacks: LauncherCallbacks)
@inject("LauncherCallbacks") protected launcherCallbacks: LauncherCallbacks,
)
{ {
super( super([
[ new RouteAction("/launcher/ping", (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/launcher/ping", return this.launcherCallbacks.ping(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => }),
{ new RouteAction(
return this.launcherCallbacks.ping(url, info, sessionID); "/launcher/server/connect",
}, (url: string, info: any, sessionID: string, output: string): any =>
), {
new RouteAction( return this.launcherCallbacks.connect();
"/launcher/server/connect", },
(url: string, info: any, sessionID: string, output: string): any => ),
{ new RouteAction(
return this.launcherCallbacks.connect(); "/launcher/profile/login",
}, (url: string, info: any, sessionID: string, output: string): any =>
), {
new RouteAction( return this.launcherCallbacks.login(url, info, sessionID);
"/launcher/profile/login", },
(url: string, info: any, sessionID: string, output: string): any => ),
{ new RouteAction(
return this.launcherCallbacks.login(url, info, sessionID); "/launcher/profile/register",
}, (url: string, info: any, sessionID: string, output: string): any =>
), {
new RouteAction( return this.launcherCallbacks.register(url, info, sessionID);
"/launcher/profile/register", },
(url: string, info: any, sessionID: string, output: string): any => ),
{ new RouteAction("/launcher/profile/get", (url: string, info: any, sessionID: string, output: string): any =>
return this.launcherCallbacks.register(url, info, sessionID); {
}, return this.launcherCallbacks.get(url, info, sessionID);
), }),
new RouteAction( new RouteAction(
"/launcher/profile/get", "/launcher/profile/change/username",
(url: string, info: any, sessionID: string, output: string): any => (url: string, info: any, sessionID: string, output: string): any =>
{ {
return this.launcherCallbacks.get(url, info, sessionID); return this.launcherCallbacks.changeUsername(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/launcher/profile/change/username", "/launcher/profile/change/password",
(url: string, info: any, sessionID: string, output: string): any => (url: string, info: any, sessionID: string, output: string): any =>
{ {
return this.launcherCallbacks.changeUsername(url, info, sessionID); return this.launcherCallbacks.changePassword(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/launcher/profile/change/password", "/launcher/profile/change/wipe",
(url: string, info: any, sessionID: string, output: string): any => (url: string, info: any, sessionID: string, output: string): any =>
{ {
return this.launcherCallbacks.changePassword(url, info, sessionID); return this.launcherCallbacks.wipe(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/launcher/profile/change/wipe", "/launcher/profile/remove",
(url: string, info: any, sessionID: string, output: string): any => (url: string, info: any, sessionID: string, output: string): any =>
{ {
return this.launcherCallbacks.wipe(url, info, sessionID); return this.launcherCallbacks.removeProfile(url, info, sessionID);
}, },
), ),
new RouteAction( new RouteAction(
"/launcher/profile/remove", "/launcher/profile/compatibleTarkovVersion",
(url: string, info: any, sessionID: string, output: string): any => (url: string, info: any, sessionID: string, output: string): any =>
{ {
return this.launcherCallbacks.removeProfile(url, info, sessionID); return this.launcherCallbacks.getCompatibleTarkovVersion();
}, },
), ),
new RouteAction( new RouteAction(
"/launcher/profile/compatibleTarkovVersion", "/launcher/server/version",
(url: string, info: any, sessionID: string, output: string): any => (url: string, info: any, sessionID: string, output: string): any =>
{ {
return this.launcherCallbacks.getCompatibleTarkovVersion(); return this.launcherCallbacks.getServerVersion();
}, },
), ),
new RouteAction( new RouteAction(
"/launcher/server/version", "/launcher/server/loadedServerMods",
(url: string, info: any, sessionID: string, output: string): any => (url: string, info: any, sessionID: string, output: string): any =>
{ {
return this.launcherCallbacks.getServerVersion(); return this.launcherCallbacks.getLoadedServerMods();
}, },
), ),
new RouteAction( new RouteAction(
"/launcher/server/loadedServerMods", "/launcher/server/serverModsUsedByProfile",
(url: string, info: any, sessionID: string, output: string): any => (url: string, info: any, sessionID: string, output: string): any =>
{ {
return this.launcherCallbacks.getLoadedServerMods(); return this.launcherCallbacks.getServerModsProfileUsed(url, info, sessionID);
}, },
), ),
new RouteAction( ]);
"/launcher/server/serverModsUsedByProfile",
(url: string, info: any, sessionID: string, output: string): any =>
{
return this.launcherCallbacks.getServerModsProfileUsed(url, info, sessionID);
},
),
],
);
} }
} }

View File

@ -6,27 +6,20 @@ import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
@injectable() @injectable()
export class LocationStaticRouter extends StaticRouter export class LocationStaticRouter extends StaticRouter
{ {
constructor( constructor(@inject("LocationCallbacks") protected locationCallbacks: LocationCallbacks)
@inject("LocationCallbacks") protected locationCallbacks: LocationCallbacks,
)
{ {
super( super([
[ new RouteAction("/client/locations", (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/client/locations", return this.locationCallbacks.getLocationData(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => }),
{ new RouteAction(
return this.locationCallbacks.getLocationData(url, info, sessionID); "/client/location/getAirdropLoot",
}, (url: string, info: any, sessionID: string, _output: string): any =>
), {
new RouteAction( return this.locationCallbacks.getAirdropLoot(url, info, sessionID);
"/client/location/getAirdropLoot", },
(url: string, info: any, sessionID: string, _output: string): any => ),
{ ]);
return this.locationCallbacks.getAirdropLoot(url, info, sessionID);
},
),
],
);
} }
} }

View File

@ -6,174 +6,158 @@ import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
@injectable() @injectable()
export class MatchStaticRouter extends StaticRouter export class MatchStaticRouter extends StaticRouter
{ {
constructor( constructor(@inject("MatchCallbacks") protected matchCallbacks: MatchCallbacks)
@inject("MatchCallbacks") protected matchCallbacks: MatchCallbacks,
)
{ {
super( super([
[ new RouteAction("/raid/profile/list", (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/raid/profile/list", return this.matchCallbacks.getProfile(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => }),
{ new RouteAction(
return this.matchCallbacks.getProfile(url, info, sessionID); "/client/match/available",
}, (url: string, info: any, sessionID: string, output: string): any =>
), {
new RouteAction( return this.matchCallbacks.serverAvailable(url, info, sessionID);
"/client/match/available", },
(url: string, info: any, sessionID: string, output: string): any => ),
{ new RouteAction(
return this.matchCallbacks.serverAvailable(url, info, sessionID); "/client/match/updatePing",
}, (url: string, info: any, sessionID: string, output: string): any =>
), {
new RouteAction( return this.matchCallbacks.updatePing(url, info, sessionID);
"/client/match/updatePing", },
(url: string, info: any, sessionID: string, output: string): any => ),
{ new RouteAction("/client/match/join", (url: string, info: any, sessionID: string, output: string): any =>
return this.matchCallbacks.updatePing(url, info, sessionID); {
}, return this.matchCallbacks.joinMatch(url, info, sessionID);
), }),
new RouteAction( new RouteAction("/client/match/exit", (url: string, info: any, sessionID: string, output: string): any =>
"/client/match/join", {
(url: string, info: any, sessionID: string, output: string): any => return this.matchCallbacks.exitMatch(url, info, sessionID);
{ }),
return this.matchCallbacks.joinMatch(url, info, sessionID); new RouteAction(
}, "/client/match/group/create",
), (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/client/match/exit", return this.matchCallbacks.createGroup(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => },
{ ),
return this.matchCallbacks.exitMatch(url, info, sessionID); new RouteAction(
}, "/client/match/group/delete",
), (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/client/match/group/create", return this.matchCallbacks.deleteGroup(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => },
{ ),
return this.matchCallbacks.createGroup(url, info, sessionID); new RouteAction(
}, "/client/match/group/leave",
), (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/client/match/group/delete", return this.matchCallbacks.leaveGroup(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => },
{ ),
return this.matchCallbacks.deleteGroup(url, info, sessionID); new RouteAction(
}, "/client/match/group/status",
), (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/client/match/group/leave", return this.matchCallbacks.getGroupStatus(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => },
{ ),
return this.matchCallbacks.leaveGroup(url, info, sessionID); new RouteAction(
}, "/client/match/group/start_game",
), (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/client/match/group/status", return this.matchCallbacks.joinMatch(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => },
{ ),
return this.matchCallbacks.getGroupStatus(url, info, sessionID); new RouteAction(
}, "/client/match/group/exit_from_menu",
), (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/client/match/group/start_game", return this.matchCallbacks.exitToMenu(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => },
{ ),
return this.matchCallbacks.joinMatch(url, info, sessionID); new RouteAction(
}, "/client/match/group/looking/start",
), (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/client/match/group/exit_from_menu", return this.matchCallbacks.startGroupSearch(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => },
{ ),
return this.matchCallbacks.exitToMenu(url, info, sessionID); new RouteAction(
}, "/client/match/group/looking/stop",
), (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/client/match/group/looking/start", return this.matchCallbacks.stopGroupSearch(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => },
{ ),
return this.matchCallbacks.startGroupSearch(url, info, sessionID); new RouteAction(
}, "/client/match/group/invite/send",
), (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/client/match/group/looking/stop", return this.matchCallbacks.sendGroupInvite(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => },
{ ),
return this.matchCallbacks.stopGroupSearch(url, info, sessionID); new RouteAction(
}, "/client/match/group/invite/accept",
), (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/client/match/group/invite/send", return this.matchCallbacks.acceptGroupInvite(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => },
{ ),
return this.matchCallbacks.sendGroupInvite(url, info, sessionID); new RouteAction(
}, "/client/match/group/invite/cancel",
), (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/client/match/group/invite/accept", return this.matchCallbacks.cancelGroupInvite(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => },
{ ),
return this.matchCallbacks.acceptGroupInvite(url, info, sessionID); new RouteAction(
}, "/client/match/group/invite/cancel-all",
), (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/client/match/group/invite/cancel", return this.matchCallbacks.cancelAllGroupInvite(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => },
{ ),
return this.matchCallbacks.cancelGroupInvite(url, info, sessionID); new RouteAction(
}, "/client/match/group/transfer",
), (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/client/match/group/invite/cancel-all", return this.matchCallbacks.transferGroup(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => },
{ ),
return this.matchCallbacks.cancelAllGroupInvite(url, info, sessionID); new RouteAction(
}, "/client/match/offline/end",
), (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/client/match/group/transfer", return this.matchCallbacks.endOfflineRaid(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => },
{ ),
return this.matchCallbacks.transferGroup(url, info, sessionID); new RouteAction("/client/putMetrics", (url: string, info: any, sessionID: string, output: string): any =>
}, {
), return this.matchCallbacks.putMetrics(url, info, sessionID);
new RouteAction( }),
"/client/match/offline/end", new RouteAction(
(url: string, info: any, sessionID: string, output: string): any => "/client/getMetricsConfig",
{ (url: string, info: any, sessionID: string, output: string): any =>
return this.matchCallbacks.endOfflineRaid(url, info, sessionID); {
}, return this.matchCallbacks.getMetrics(url, info, sessionID);
), },
new RouteAction( ),
"/client/putMetrics", new RouteAction(
(url: string, info: any, sessionID: string, output: string): any => "/client/raid/configuration",
{ (url: string, info: any, sessionID: string, output: string): any =>
return this.matchCallbacks.putMetrics(url, info, sessionID); {
}, return this.matchCallbacks.getRaidConfiguration(url, info, sessionID);
), },
new RouteAction( ),
"/client/getMetricsConfig", new RouteAction(
(url: string, info: any, sessionID: string, output: string): any => "/client/match/group/player/remove",
{ (url: string, info: any, sessionID: string, output: string): any =>
return this.matchCallbacks.getMetrics(url, info, sessionID); {
}, return this.matchCallbacks.removePlayerFromGroup(url, info, sessionID);
), },
new RouteAction( ),
"/client/raid/configuration", ]);
(url: string, info: any, sessionID: string, output: string): any =>
{
return this.matchCallbacks.getRaidConfiguration(url, info, sessionID);
},
),
new RouteAction(
"/client/match/group/player/remove",
(url: string, info: any, sessionID: string, output: string): any =>
{
return this.matchCallbacks.removePlayerFromGroup(url, info, sessionID);
},
),
],
);
} }
} }

View File

@ -6,27 +6,23 @@ import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
@injectable() @injectable()
export class NotifierStaticRouter extends StaticRouter export class NotifierStaticRouter extends StaticRouter
{ {
constructor( constructor(@inject("NotifierCallbacks") protected notifierCallbacks: NotifierCallbacks)
@inject("NotifierCallbacks") protected notifierCallbacks: NotifierCallbacks,
)
{ {
super( super([
[ new RouteAction(
new RouteAction( "/client/notifier/channel/create",
"/client/notifier/channel/create", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.notifierCallbacks.createNotifierChannel(url, info, sessionID);
return this.notifierCallbacks.createNotifierChannel(url, info, sessionID); },
}, ),
), new RouteAction(
new RouteAction( "/client/game/profile/select",
"/client/game/profile/select", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.notifierCallbacks.selectProfile(url, info, sessionID);
return this.notifierCallbacks.selectProfile(url, info, sessionID); },
}, ),
), ]);
],
);
} }
} }

View File

@ -6,20 +6,16 @@ import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
@injectable() @injectable()
export class PresetStaticRouter extends StaticRouter export class PresetStaticRouter extends StaticRouter
{ {
constructor( constructor(@inject("PresetBuildCallbacks") protected presetCallbacks: PresetBuildCallbacks)
@inject("PresetBuildCallbacks") protected presetCallbacks: PresetBuildCallbacks,
)
{ {
super( super([
[ new RouteAction(
new RouteAction( "/client/handbook/builds/my/list",
"/client/handbook/builds/my/list", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.presetCallbacks.getHandbookUserlist(url, info, sessionID);
return this.presetCallbacks.getHandbookUserlist(url, info, sessionID); },
}, ),
), ]);
],
);
} }
} }

View File

@ -6,97 +6,90 @@ import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
@injectable() @injectable()
export class ProfileStaticRouter extends StaticRouter export class ProfileStaticRouter extends StaticRouter
{ {
constructor( constructor(@inject("ProfileCallbacks") protected profileCallbacks: ProfileCallbacks)
@inject("ProfileCallbacks") protected profileCallbacks: ProfileCallbacks,
)
{ {
super( super([
[ new RouteAction(
new RouteAction( "/client/game/profile/create",
"/client/game/profile/create", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.profileCallbacks.createProfile(url, info, sessionID);
return this.profileCallbacks.createProfile(url, info, sessionID); },
}, ),
), new RouteAction(
new RouteAction( "/client/game/profile/list",
"/client/game/profile/list", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.profileCallbacks.getProfileData(url, info, sessionID);
return this.profileCallbacks.getProfileData(url, info, sessionID); },
}, ),
), new RouteAction(
new RouteAction( "/client/game/profile/savage/regenerate",
"/client/game/profile/savage/regenerate", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.profileCallbacks.regenerateScav(url, info, sessionID);
return this.profileCallbacks.regenerateScav(url, info, sessionID); },
}, ),
), new RouteAction(
new RouteAction( "/client/game/profile/voice/change",
"/client/game/profile/voice/change", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.profileCallbacks.changeVoice(url, info, sessionID);
return this.profileCallbacks.changeVoice(url, info, sessionID); },
}, ),
), new RouteAction(
new RouteAction( "/client/game/profile/nickname/change",
"/client/game/profile/nickname/change", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.profileCallbacks.changeNickname(url, info, sessionID);
return this.profileCallbacks.changeNickname(url, info, sessionID); },
}, ),
), new RouteAction(
new RouteAction( "/client/game/profile/nickname/validate",
"/client/game/profile/nickname/validate", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.profileCallbacks.validateNickname(url, info, sessionID);
return this.profileCallbacks.validateNickname(url, info, sessionID); },
}, ),
), new RouteAction(
new RouteAction( "/client/game/profile/nickname/reserved",
"/client/game/profile/nickname/reserved", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.profileCallbacks.getReservedNickname(url, info, sessionID);
return this.profileCallbacks.getReservedNickname(url, info, sessionID); },
}, ),
), new RouteAction(
new RouteAction( "/client/profile/status",
"/client/profile/status", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.profileCallbacks.getProfileStatus(url, info, sessionID);
return this.profileCallbacks.getProfileStatus(url, info, sessionID); },
}, ),
), new RouteAction(
new RouteAction( "/client/profile/settings",
"/client/profile/settings", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.profileCallbacks.getProfileSettings(url, info, sessionID);
return this.profileCallbacks.getProfileSettings(url, info, sessionID); },
}, ),
), new RouteAction(
new RouteAction( "/client/game/profile/search",
"/client/game/profile/search", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.profileCallbacks.searchFriend(url, info, sessionID);
return this.profileCallbacks.searchFriend(url, info, sessionID); },
}, ),
), new RouteAction(
new RouteAction( "/launcher/profile/info",
"/launcher/profile/info", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.profileCallbacks.getMiniProfile(url, info, sessionID);
return this.profileCallbacks.getMiniProfile(url, info, sessionID); },
}, ),
), new RouteAction("/launcher/profiles", (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/launcher/profiles", return this.profileCallbacks.getAllMiniProfiles(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => }),
{ ]);
return this.profileCallbacks.getAllMiniProfiles(url, info, sessionID);
},
),
],
);
} }
} }

View File

@ -6,27 +6,20 @@ import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
@injectable() @injectable()
export class QuestStaticRouter extends StaticRouter export class QuestStaticRouter extends StaticRouter
{ {
constructor( constructor(@inject("QuestCallbacks") protected questCallbacks: QuestCallbacks)
@inject("QuestCallbacks") protected questCallbacks: QuestCallbacks,
)
{ {
super( super([
[ new RouteAction("/client/quest/list", (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/client/quest/list", return this.questCallbacks.listQuests(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => }),
{ new RouteAction(
return this.questCallbacks.listQuests(url, info, sessionID); "/client/repeatalbeQuests/activityPeriods",
}, (url: string, info: any, sessionID: string, output: string): any =>
), {
new RouteAction( return this.questCallbacks.activityPeriods(url, info, sessionID);
"/client/repeatalbeQuests/activityPeriods", },
(url: string, info: any, sessionID: string, output: string): any => ),
{ ]);
return this.questCallbacks.activityPeriods(url, info, sessionID);
},
),
],
);
} }
} }

View File

@ -6,55 +6,45 @@ import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
@injectable() @injectable()
export class RagfairStaticRouter extends StaticRouter export class RagfairStaticRouter extends StaticRouter
{ {
constructor( constructor(@inject("RagfairCallbacks") protected ragfairCallbacks: RagfairCallbacks)
@inject("RagfairCallbacks") protected ragfairCallbacks: RagfairCallbacks,
)
{ {
super( super([
[ new RouteAction(
new RouteAction( "/client/ragfair/search",
"/client/ragfair/search", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.ragfairCallbacks.search(url, info, sessionID);
return this.ragfairCallbacks.search(url, info, sessionID); },
}, ),
), new RouteAction("/client/ragfair/find", (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/client/ragfair/find", return this.ragfairCallbacks.search(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => }),
{ new RouteAction(
return this.ragfairCallbacks.search(url, info, sessionID); "/client/ragfair/itemMarketPrice",
}, (url: string, info: any, sessionID: string, output: string): any =>
), {
new RouteAction( return this.ragfairCallbacks.getMarketPrice(url, info, sessionID);
"/client/ragfair/itemMarketPrice", },
(url: string, info: any, sessionID: string, output: string): any => ),
{ new RouteAction(
return this.ragfairCallbacks.getMarketPrice(url, info, sessionID); "/client/ragfair/offerfees",
}, (url: string, info: any, sessionID: string, output: string): any =>
), {
new RouteAction( return this.ragfairCallbacks.storePlayerOfferTaxAmount(url, info, sessionID);
"/client/ragfair/offerfees", },
(url: string, info: any, sessionID: string, output: string): any => ),
{ new RouteAction(
return this.ragfairCallbacks.storePlayerOfferTaxAmount(url, info, sessionID); "/client/reports/ragfair/send",
}, (url: string, info: any, sessionID: string, output: string): any =>
), {
new RouteAction( return this.ragfairCallbacks.sendReport(url, info, sessionID);
"/client/reports/ragfair/send", },
(url: string, info: any, sessionID: string, output: string): any => ),
{ new RouteAction("/client/items/prices", (url: string, info: any, sessionID: string, output: string): any =>
return this.ragfairCallbacks.sendReport(url, info, sessionID); {
}, return this.ragfairCallbacks.getFleaPrices(url, info, sessionID);
), }),
new RouteAction( ]);
"/client/items/prices",
(url: string, info: any, sessionID: string, output: string): any =>
{
return this.ragfairCallbacks.getFleaPrices(url, info, sessionID);
},
),
],
);
} }
} }

View File

@ -6,20 +6,16 @@ import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
@injectable() @injectable()
export class TraderStaticRouter extends StaticRouter export class TraderStaticRouter extends StaticRouter
{ {
constructor( constructor(@inject("TraderCallbacks") protected traderCallbacks: TraderCallbacks)
@inject("TraderCallbacks") protected traderCallbacks: TraderCallbacks,
)
{ {
super( super([
[ new RouteAction(
new RouteAction( "/client/trading/api/traderSettings",
"/client/trading/api/traderSettings", (url: string, info: any, sessionID: string, output: string): any =>
(url: string, info: any, sessionID: string, output: string): any => {
{ return this.traderCallbacks.getTraderSettings(url, info, sessionID);
return this.traderCallbacks.getTraderSettings(url, info, sessionID); },
}, ),
), ]);
],
);
} }
} }

View File

@ -6,20 +6,13 @@ import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
@injectable() @injectable()
export class WeatherStaticRouter extends StaticRouter export class WeatherStaticRouter extends StaticRouter
{ {
constructor( constructor(@inject("WeatherCallbacks") protected weatherCallbacks: WeatherCallbacks)
@inject("WeatherCallbacks") protected weatherCallbacks: WeatherCallbacks,
)
{ {
super( super([
[ new RouteAction("/client/weather", (url: string, info: any, sessionID: string, output: string): any =>
new RouteAction( {
"/client/weather", return this.weatherCallbacks.getWeather(url, info, sessionID);
(url: string, info: any, sessionID: string, output: string): any => }),
{ ]);
return this.weatherCallbacks.getWeather(url, info, sessionID);
},
),
],
);
} }
} }

View File

@ -36,9 +36,7 @@ export class ConfigServer
this.logger.debug("Importing configs..."); this.logger.debug("Importing configs...");
// Get all filepaths // Get all filepaths
const filepath = (globalThis.G_RELEASE_CONFIGURATION) const filepath = (globalThis.G_RELEASE_CONFIGURATION) ? "Aki_Data/Server/configs/" : "./assets/configs/";
? "Aki_Data/Server/configs/"
: "./assets/configs/";
const files = this.vfs.getFiles(filepath); const files = this.vfs.getFiles(filepath);
// Add file content to result // Add file content to result

View File

@ -142,10 +142,7 @@ export class SaveServer
throw new Error(`profile already exists for sessionId: ${profileInfo.id}`); throw new Error(`profile already exists for sessionId: ${profileInfo.id}`);
} }
this.profiles[profileInfo.id] = { this.profiles[profileInfo.id] = {info: profileInfo, characters: {pmc: {}, scav: {}}};
info: profileInfo,
characters: {pmc: {}, scav: {}},
};
} }
/** /**

View File

@ -28,19 +28,14 @@ export class WebSocketServer
} }
protected httpConfig: IHttpConfig; protected httpConfig: IHttpConfig;
protected defaultNotification: INotification = { protected defaultNotification: INotification = {type: NotificationType.PING, eventId: "ping"};
type: NotificationType.PING,
eventId: "ping",
};
protected webSockets: Record<string, WebSocket.WebSocket> = {}; protected webSockets: Record<string, WebSocket.WebSocket> = {};
protected websocketPingHandler = null; protected websocketPingHandler = null;
public setupWebSocket(httpServer: http.Server): void public setupWebSocket(httpServer: http.Server): void
{ {
const webSocketServer = new WebSocket.Server({ const webSocketServer = new WebSocket.Server({server: httpServer});
server: httpServer,
});
webSocketServer.addListener("listening", () => webSocketServer.addListener("listening", () =>
{ {

View File

@ -141,9 +141,7 @@ export class AkiHttpListener implements IHttpListener
if (globalThis.G_LOG_REQUESTS) if (globalThis.G_LOG_REQUESTS)
{ {
// Parse quest info into object // Parse quest info into object
const data = (typeof info === "object") const data = (typeof info === "object") ? info : this.jsonUtil.deserialize(info);
? info
: this.jsonUtil.deserialize(info);
const log = new Request(req.method, new RequestData(req.url, req.headers, data)); const log = new Request(req.method, new RequestData(req.url, req.headers, data));
this.requestsLogger.info(`REQUEST=${this.jsonUtil.serialize(log)}`); this.requestsLogger.info(`REQUEST=${this.jsonUtil.serialize(log)}`);
@ -184,28 +182,18 @@ export class AkiHttpListener implements IHttpListener
class RequestData class RequestData
{ {
constructor( constructor(public url: string, public headers: IncomingHttpHeaders, public data?: any)
public url: string,
public headers: IncomingHttpHeaders,
public data?: any,
)
{} {}
} }
class Request class Request
{ {
constructor( constructor(public type: string, public req: RequestData)
public type: string,
public req: RequestData,
)
{} {}
} }
class Response class Response
{ {
constructor( constructor(public type: string, public response: any)
public type: string,
public response: any,
)
{} {}
} }

View File

@ -54,9 +54,7 @@ export class BotEquipmentFilterService
{ {
const pmcProfile = this.profileHelper.getPmcProfile(sessionId); const pmcProfile = this.profileHelper.getPmcProfile(sessionId);
const botRole = (botGenerationDetails.isPmc) const botRole = (botGenerationDetails.isPmc) ? "pmc" : botGenerationDetails.role;
? "pmc"
: botGenerationDetails.role;
const botEquipmentBlacklist = this.getBotEquipmentBlacklist(botRole, botLevel); const botEquipmentBlacklist = this.getBotEquipmentBlacklist(botRole, botLevel);
const botEquipmentWhitelist = this.getBotEquipmentWhitelist(botRole, botLevel); const botEquipmentWhitelist = this.getBotEquipmentWhitelist(botRole, botLevel);
const botWeightingAdjustments = this.getBotWeightingAdjustments(botRole, botLevel); const botWeightingAdjustments = this.getBotWeightingAdjustments(botRole, botLevel);

View File

@ -168,8 +168,7 @@ export class BotLootCacheService
const specialLootItems = (botJsonTemplate.generation.items.specialItems.whitelist?.length > 0) const specialLootItems = (botJsonTemplate.generation.items.specialItems.whitelist?.length > 0)
? botJsonTemplate.generation.items.specialItems.whitelist.map((x) => this.itemHelper.getItem(x)[1]) ? botJsonTemplate.generation.items.specialItems.whitelist.map((x) => this.itemHelper.getItem(x)[1])
: specialLootTemplates.filter((template) => : specialLootTemplates.filter((template) =>
!(this.isBulletOrGrenade(template._props) !(this.isBulletOrGrenade(template._props) || this.isMagazine(template._props))
|| this.isMagazine(template._props))
); );
const healingItems = (botJsonTemplate.generation.items.healing.whitelist?.length > 0) const healingItems = (botJsonTemplate.generation.items.healing.whitelist?.length > 0)
@ -183,15 +182,13 @@ export class BotLootCacheService
const drugItems = (botJsonTemplate.generation.items.drugs.whitelist?.length > 0) const drugItems = (botJsonTemplate.generation.items.drugs.whitelist?.length > 0)
? botJsonTemplate.generation.items.drugs.whitelist.map((x) => this.itemHelper.getItem(x)[1]) ? botJsonTemplate.generation.items.drugs.whitelist.map((x) => this.itemHelper.getItem(x)[1])
: combinedPoolTemplates.filter((template) => : combinedPoolTemplates.filter((template) =>
this.isMedicalItem(template._props) this.isMedicalItem(template._props) && template._parent === BaseClasses.DRUGS
&& template._parent === BaseClasses.DRUGS
); );
const stimItems = (botJsonTemplate.generation.items.stims.whitelist?.length > 0) const stimItems = (botJsonTemplate.generation.items.stims.whitelist?.length > 0)
? botJsonTemplate.generation.items.stims.whitelist.map((x) => this.itemHelper.getItem(x)[1]) ? botJsonTemplate.generation.items.stims.whitelist.map((x) => this.itemHelper.getItem(x)[1])
: combinedPoolTemplates.filter((template) => : combinedPoolTemplates.filter((template) =>
this.isMedicalItem(template._props) this.isMedicalItem(template._props) && template._parent === BaseClasses.STIMULATOR
&& template._parent === BaseClasses.STIMULATOR
); );
const grenadeItems = (botJsonTemplate.generation.items.grenades.whitelist?.length > 0) const grenadeItems = (botJsonTemplate.generation.items.grenades.whitelist?.length > 0)
@ -201,9 +198,7 @@ export class BotLootCacheService
// Get loot items (excluding magazines, bullets, grenades and healing items) // Get loot items (excluding magazines, bullets, grenades and healing items)
const backpackLootItems = backpackLootTemplates.filter((template) => const backpackLootItems = backpackLootTemplates.filter((template) =>
// biome-ignore lint/complexity/useSimplifiedLogicExpression: <explanation> // biome-ignore lint/complexity/useSimplifiedLogicExpression: <explanation>
!this.isBulletOrGrenade(template._props) !this.isBulletOrGrenade(template._props) && !this.isMagazine(template._props) // && !this.isMedicalItem(template._props) // Disabled for now as followSanitar has a lot of med items as loot
&& !this.isMagazine(template._props)
// && !this.isMedicalItem(template._props) // Disabled for now as followSanitar has a lot of med items as loot
&& !this.isGrenade(template._props) && !this.isGrenade(template._props)
); );

View File

@ -294,9 +294,7 @@ export class FenceService
const desiredTotalCount = this.traderConfig.fence.assortSize; const desiredTotalCount = this.traderConfig.fence.assortSize;
const actualTotalCount = this.fenceAssort.items.reduce((count, item) => const actualTotalCount = this.fenceAssort.items.reduce((count, item) =>
{ {
return item.slotId === "hideout" return item.slotId === "hideout" ? count + 1 : count;
? count + 1
: count;
}, 0); }, 0);
return actualTotalCount < desiredTotalCount return actualTotalCount < desiredTotalCount
@ -587,10 +585,7 @@ export class FenceService
// Multiply weapon+mods rouble price by multipler in config // Multiply weapon+mods rouble price by multipler in config
assorts.barter_scheme[weaponAndMods[0]._id] = [[]]; assorts.barter_scheme[weaponAndMods[0]._id] = [[]];
assorts.barter_scheme[weaponAndMods[0]._id][0][0] = { assorts.barter_scheme[weaponAndMods[0]._id][0][0] = {_tpl: Money.ROUBLES, count: Math.round(rub)};
_tpl: Money.ROUBLES,
count: Math.round(rub),
};
assorts.loyal_level_items[weaponAndMods[0]._id] = loyaltyLevel; assorts.loyal_level_items[weaponAndMods[0]._id] = loyaltyLevel;
@ -658,8 +653,7 @@ export class FenceService
// Roll from 0 to 9999, then divide it by 100: 9999 = 99.99% // Roll from 0 to 9999, then divide it by 100: 9999 = 99.99%
const randomChance = this.randomUtil.getInt(0, 9999) / 100; const randomChance = this.randomUtil.getInt(0, 9999) / 100;
return randomChance > removalChance return randomChance > removalChance && !itemsBeingDeleted.includes(weaponMod._id);
&& !itemsBeingDeleted.includes(weaponMod._id);
} }
/** /**
@ -681,9 +675,7 @@ export class FenceService
// Randomise hp resource of med items // Randomise hp resource of med items
if ("MaxHpResource" in itemDetails._props && itemDetails._props.MaxHpResource > 0) if ("MaxHpResource" in itemDetails._props && itemDetails._props.MaxHpResource > 0)
{ {
itemToAdjust.upd.MedKit = { itemToAdjust.upd.MedKit = {HpResource: this.randomUtil.getInt(1, itemDetails._props.MaxHpResource)};
HpResource: this.randomUtil.getInt(1, itemDetails._props.MaxHpResource),
};
} }
// Randomise armor durability // Randomise armor durability
@ -692,8 +684,7 @@ export class FenceService
|| itemDetails._parent === BaseClasses.HEADWEAR || itemDetails._parent === BaseClasses.HEADWEAR
|| itemDetails._parent === BaseClasses.VEST || itemDetails._parent === BaseClasses.VEST
|| itemDetails._parent === BaseClasses.ARMOREDEQUIPMENT || itemDetails._parent === BaseClasses.ARMOREDEQUIPMENT
|| itemDetails._parent === BaseClasses.FACECOVER) || itemDetails._parent === BaseClasses.FACECOVER) && itemDetails._props.MaxDurability > 0
&& itemDetails._props.MaxDurability > 0
) )
{ {
const armorMaxDurabilityLimits = this.traderConfig.fence.armorMaxDurabilityPercentMinMax; const armorMaxDurabilityLimits = this.traderConfig.fence.armorMaxDurabilityPercentMinMax;
@ -703,10 +694,7 @@ export class FenceService
const maxDurability = this.randomUtil.getInt(duraMin, duraMax); const maxDurability = this.randomUtil.getInt(duraMin, duraMax);
const durability = this.randomUtil.getInt(1, maxDurability); const durability = this.randomUtil.getInt(1, maxDurability);
itemToAdjust.upd.Repairable = { itemToAdjust.upd.Repairable = {Durability: durability, MaxDurability: maxDurability};
Durability: durability,
MaxDurability: maxDurability,
};
return; return;
} }
@ -721,19 +709,14 @@ export class FenceService
const maxDurability = this.randomUtil.getInt(duraMin, duraMax); const maxDurability = this.randomUtil.getInt(duraMin, duraMax);
const durability = this.randomUtil.getInt(1, maxDurability); const durability = this.randomUtil.getInt(1, maxDurability);
itemToAdjust.upd.Repairable = { itemToAdjust.upd.Repairable = {Durability: durability, MaxDurability: maxDurability};
Durability: durability,
MaxDurability: maxDurability,
};
return; return;
} }
if (this.itemHelper.isOfBaseclass(itemDetails._id, BaseClasses.REPAIR_KITS)) if (this.itemHelper.isOfBaseclass(itemDetails._id, BaseClasses.REPAIR_KITS))
{ {
itemToAdjust.upd.RepairKit = { itemToAdjust.upd.RepairKit = {Resource: this.randomUtil.getInt(1, itemDetails._props.MaxRepairResource)};
Resource: this.randomUtil.getInt(1, itemDetails._props.MaxRepairResource),
};
return; return;
} }
@ -757,10 +740,7 @@ export class FenceService
const resourceMax = itemDetails._props.MaxResource; const resourceMax = itemDetails._props.MaxResource;
const resourceCurrent = this.randomUtil.getInt(1, itemDetails._props.MaxResource); const resourceCurrent = this.randomUtil.getInt(1, itemDetails._props.MaxResource);
itemToAdjust.upd.Resource = { itemToAdjust.upd.Resource = {Value: resourceMax - resourceCurrent, UnitsConsumed: resourceCurrent};
Value: resourceMax - resourceCurrent,
UnitsConsumed: resourceCurrent,
};
} }
} }
@ -775,10 +755,7 @@ export class FenceService
for (const x in limits) for (const x in limits)
{ {
itemTypeCounts[x] = { itemTypeCounts[x] = {current: 0, max: limits[x]};
current: 0,
max: limits[x],
};
} }
return itemTypeCounts; return itemTypeCounts;

View File

@ -202,9 +202,8 @@ export class InsuranceService
} }
const insuranceReturnTimeBonus = pmcData.Bonuses.find((b) => b.type === "InsuranceReturnTime"); const insuranceReturnTimeBonus = pmcData.Bonuses.find((b) => b.type === "InsuranceReturnTime");
const insuranceReturnTimeBonusPercent = 1.0 - (insuranceReturnTimeBonus const insuranceReturnTimeBonusPercent = 1.0
? Math.abs(insuranceReturnTimeBonus.value) - (insuranceReturnTimeBonus ? Math.abs(insuranceReturnTimeBonus.value) : 0) / 100;
: 0) / 100;
const traderMinReturnAsSeconds = trader.insurance.min_return_hour * TimeUtil.oneHourAsSeconds; const traderMinReturnAsSeconds = trader.insurance.min_return_hour * TimeUtil.oneHourAsSeconds;
const traderMaxReturnAsSeconds = trader.insurance.max_return_hour * TimeUtil.oneHourAsSeconds; const traderMaxReturnAsSeconds = trader.insurance.max_return_hour * TimeUtil.oneHourAsSeconds;
@ -335,9 +334,7 @@ export class InsuranceService
// Item didnt have faceshield object pre-raid, add it // Item didnt have faceshield object pre-raid, add it
if (!itemToReturn.upd.FaceShield) if (!itemToReturn.upd.FaceShield)
{ {
itemToReturn.upd.FaceShield = { itemToReturn.upd.FaceShield = {Hits: insuredItemFromClient.hits};
Hits: insuredItemFromClient.hits,
};
} }
else else
{ {
@ -355,12 +352,7 @@ export class InsuranceService
*/ */
protected updateSlotIdValue(playerBaseInventoryEquipmentId: string, itemToReturn: Item): void protected updateSlotIdValue(playerBaseInventoryEquipmentId: string, itemToReturn: Item): void
{ {
const pocketSlots = [ const pocketSlots = ["pocket1", "pocket2", "pocket3", "pocket4"];
"pocket1",
"pocket2",
"pocket3",
"pocket4",
];
// Some pockets can lose items with player death, some don't // Some pockets can lose items with player death, some don't
if (!("slotId" in itemToReturn) || pocketSlots.includes(itemToReturn.slotId)) if (!("slotId" in itemToReturn) || pocketSlots.includes(itemToReturn.slotId))

View File

@ -30,14 +30,12 @@ export class LocalisationService
? "Aki_Data/Server/database/locales/server" ? "Aki_Data/Server/database/locales/server"
: "./assets/database/locales/server", : "./assets/database/locales/server",
); );
this.i18n = new I18n( this.i18n = new I18n({
{ locales: this.localeService.getServerSupportedLocales(),
locales: this.localeService.getServerSupportedLocales(), defaultLocale: "en",
defaultLocale: "en", directory: localeFileDirectory,
directory: localeFileDirectory, retryInDefaultLocale: true,
retryInDefaultLocale: true, });
},
);
this.i18n.setLocale(this.localeService.getDesiredServerLocale()); this.i18n.setLocale(this.localeService.getDesiredServerLocale());
} }

View File

@ -420,10 +420,7 @@ export class MailSendService
parentItem.parentId = this.hashUtil.generate(); parentItem.parentId = this.hashUtil.generate();
} }
itemsToSendToPlayer = { itemsToSendToPlayer = {stash: parentItem.parentId, data: []};
stash: parentItem.parentId,
data: [],
};
// Ensure Ids are unique and cont collide with items in player inventory later // Ensure Ids are unique and cont collide with items in player inventory later
messageDetails.items = this.itemHelper.replaceIDs(null, messageDetails.items); messageDetails.items = this.itemHelper.replaceIDs(null, messageDetails.items);

View File

@ -8,9 +8,7 @@ export class MatchLocationService
{ {
protected locations = {}; protected locations = {};
constructor( constructor(@inject("TimeUtil") protected timeUtil: TimeUtil)
@inject("TimeUtil") protected timeUtil: TimeUtil,
)
{} {}
public createGroup(sessionID: string, info: ICreateGroupRequestData): any public createGroup(sessionID: string, info: ICreateGroupRequestData): any
@ -27,15 +25,13 @@ export class MatchLocationService
isSavage: false, isSavage: false,
timeShift: "CURR", timeShift: "CURR",
dt: this.timeUtil.getTimestamp(), dt: this.timeUtil.getTimestamp(),
players: [ players: [{
{ _id: `pmc${sessionID}`,
_id: `pmc${sessionID}`, region: "EUR",
region: "EUR", ip: "127.0.0.1",
ip: "127.0.0.1", savageId: `scav${sessionID}`,
savageId: `scav${sessionID}`, accessKeyId: "",
accessKeyId: "", }],
},
],
customDataCenter: [], customDataCenter: [],
}; };

View File

@ -93,8 +93,7 @@ export class ProfileFixerService
HideoutAreas.GENERATOR, HideoutAreas.GENERATOR,
6 6
+ this.databaseServer.getTables().globals.config.SkillsSettings.HideoutManagement.EliteSlots + this.databaseServer.getTables().globals.config.SkillsSettings.HideoutManagement.EliteSlots
.Generator .Generator.Slots,
.Slots,
pmcProfile, pmcProfile,
); );
} }
@ -276,34 +275,30 @@ export class ProfileFixerService
{ {
if (!pmcProfile.Hideout.Areas.find((x) => x.type === HideoutAreas.WEAPON_STAND)) if (!pmcProfile.Hideout.Areas.find((x) => x.type === HideoutAreas.WEAPON_STAND))
{ {
pmcProfile.Hideout.Areas.push( pmcProfile.Hideout.Areas.push({
{ type: 24,
type: 24, level: 0,
level: 0, active: true,
active: true, passiveBonusesEnabled: true,
passiveBonusesEnabled: true, completeTime: 0,
completeTime: 0, constructing: false,
constructing: false, slots: [],
slots: [], lastRecipe: "",
lastRecipe: "", });
},
);
} }
if (!pmcProfile.Hideout.Areas.find((x) => x.type === HideoutAreas.WEAPON_STAND_SECONDARY)) if (!pmcProfile.Hideout.Areas.find((x) => x.type === HideoutAreas.WEAPON_STAND_SECONDARY))
{ {
pmcProfile.Hideout.Areas.push( pmcProfile.Hideout.Areas.push({
{ type: 25,
type: 25, level: 0,
level: 0, active: true,
active: true, passiveBonusesEnabled: true,
passiveBonusesEnabled: true, completeTime: 0,
completeTime: 0, constructing: false,
constructing: false, slots: [],
slots: [], lastRecipe: "",
lastRecipe: "", });
},
);
} }
} }
@ -357,10 +352,7 @@ export class ProfileFixerService
if (!fullProfile.aki) if (!fullProfile.aki)
{ {
this.logger.debug("Adding aki object to profile"); this.logger.debug("Adding aki object to profile");
fullProfile.aki = { fullProfile.aki = {version: this.watermark.getVersionTag(), receivedGifts: []};
version: this.watermark.getVersionTag(),
receivedGifts: [],
};
} }
} }
@ -404,9 +396,7 @@ export class ProfileFixerService
if (!pmcProfile.UnlockedInfo) if (!pmcProfile.UnlockedInfo)
{ {
this.logger.debug("Adding UnlockedInfo object to profile"); this.logger.debug("Adding UnlockedInfo object to profile");
pmcProfile.UnlockedInfo = { pmcProfile.UnlockedInfo = {unlockedProductionRecipe: []};
unlockedProductionRecipe: [],
};
} }
} }
@ -554,9 +544,9 @@ export class ProfileFixerService
{ {
if ( if (
!(currentRepeatable.changeRequirement !(currentRepeatable.changeRequirement
&& currentRepeatable.activeQuests.every( && currentRepeatable.activeQuests.every((
(x) => (typeof x.changeCost !== "undefined" && typeof x.changeStandingCost !== "undefined"), x,
)) ) => (typeof x.changeCost !== "undefined" && typeof x.changeStandingCost !== "undefined")))
) )
{ {
repeatablesCompatible = false; repeatablesCompatible = false;
@ -798,28 +788,17 @@ export class ProfileFixerService
if (bonus.type.toLowerCase() === "stashsize") if (bonus.type.toLowerCase() === "stashsize")
{ {
return profileBonuses.find( return profileBonuses.find((x) => x.type === bonus.type && x.templateId === bonus.templateId);
(x) =>
x.type === bonus.type
&& x.templateId === bonus.templateId,
);
} }
if (bonus.type.toLowerCase() === "additionalslots") if (bonus.type.toLowerCase() === "additionalslots")
{ {
return profileBonuses.find( return profileBonuses.find((x) =>
(x) => x.type === bonus.type && x.value === bonus.value && x.visible === bonus.visible
x.type === bonus.type
&& x.value === bonus.value
&& x.visible === bonus.visible,
); );
} }
return profileBonuses.find( return profileBonuses.find((x) => x.type === bonus.type && x.value === bonus.value);
(x) =>
x.type === bonus.type
&& x.value === bonus.value,
);
} }
/** /**

View File

@ -8,9 +8,7 @@ export class ProfileSnapshotService
{ {
protected storedProfileSnapshots: Record<string, IAkiProfile> = {}; protected storedProfileSnapshots: Record<string, IAkiProfile> = {};
constructor( constructor(@inject("JsonUtil") protected jsonUtil: JsonUtil)
@inject("JsonUtil") protected jsonUtil: JsonUtil,
)
{} {}
/** /**

View File

@ -8,9 +8,7 @@ export class RagfairCategoriesService
{ {
protected categories: Record<string, number> = {}; protected categories: Record<string, number> = {};
constructor( constructor(@inject("WinstonLogger") protected logger: ILogger)
@inject("WinstonLogger") protected logger: ILogger,
)
{} {}
/** /**
@ -58,9 +56,7 @@ export class RagfairCategoriesService
const itemId = offer.items[0]._tpl; const itemId = offer.items[0]._tpl;
if (increment) if (increment)
{ {
categories[itemId] = categories[itemId] categories[itemId] = categories[itemId] ? categories[itemId] + 1 : 1;
? categories[itemId] + 1
: 1;
} }
else else
{ {

View File

@ -29,10 +29,7 @@ export class RagfairPriceService implements OnLoad
protected generatedDynamicPrices: boolean; protected generatedDynamicPrices: boolean;
protected generatedStaticPrices: boolean; protected generatedStaticPrices: boolean;
protected prices: IRagfairServerPrices = { protected prices: IRagfairServerPrices = {static: {}, dynamic: {}};
static: {},
dynamic: {},
};
constructor( constructor(
@inject("HandbookHelper") protected handbookHelper: HandbookHelper, @inject("HandbookHelper") protected handbookHelper: HandbookHelper,
@ -298,8 +295,7 @@ export class RagfairPriceService implements OnLoad
// Only adjust price if difference is > a percent AND item price passes threshhold set in config // Only adjust price if difference is > a percent AND item price passes threshhold set in config
if ( if (
priceDifferencePercent priceDifferencePercent > this.ragfairConfig.dynamic.offerAdjustment.maxPriceDifferenceBelowHandbookPercent
> this.ragfairConfig.dynamic.offerAdjustment.maxPriceDifferenceBelowHandbookPercent
&& itemPrice >= this.ragfairConfig.dynamic.offerAdjustment.priceThreshholdRub && itemPrice >= this.ragfairConfig.dynamic.offerAdjustment.priceThreshholdRub
) )
{ {
@ -418,10 +414,7 @@ export class RagfairPriceService implements OnLoad
const defaultPreset = presets.find((x) => x._encyclopedia); const defaultPreset = presets.find((x) => x._encyclopedia);
if (defaultPreset) if (defaultPreset)
{ {
return { return {isDefault: true, preset: defaultPreset};
isDefault: true,
preset: defaultPreset,
};
} }
if (presets.length === 1) if (presets.length === 1)
@ -441,9 +434,6 @@ export class RagfairPriceService implements OnLoad
); );
} }
return { return {isDefault: false, preset: presets[0]};
isDefault: false,
preset: presets[0],
};
} }
} }

View File

@ -69,9 +69,7 @@ export class RepairService
const priceCoef = this.traderHelper.getLoyaltyLevel(traderId, pmcData).repair_price_coef; const priceCoef = this.traderHelper.getLoyaltyLevel(traderId, pmcData).repair_price_coef;
const traderRepairDetails = this.traderHelper.getTrader(traderId, sessionID).repair; const traderRepairDetails = this.traderHelper.getTrader(traderId, sessionID).repair;
const repairQualityMultiplier = traderRepairDetails.quality; const repairQualityMultiplier = traderRepairDetails.quality;
const repairRate = (priceCoef <= 0) const repairRate = (priceCoef <= 0) ? 1 : (priceCoef / 100 + 1);
? 1
: (priceCoef / 100 + 1);
const itemToRepairDetails = this.databaseServer.getTables().templates.items[itemToRepair._tpl]; const itemToRepairDetails = this.databaseServer.getTables().templates.items[itemToRepair._tpl];
const repairItemIsArmor = !!itemToRepairDetails._props.ArmorMaterial; const repairItemIsArmor = !!itemToRepairDetails._props.ArmorMaterial;
@ -124,12 +122,7 @@ export class RepairService
{ {
const options: IProcessBuyTradeRequestData = { const options: IProcessBuyTradeRequestData = {
// eslint-disable-next-line @typescript-eslint/naming-convention // eslint-disable-next-line @typescript-eslint/naming-convention
scheme_items: [ scheme_items: [{id: repairedItemId, count: Math.round(repairCost)}],
{
id: repairedItemId,
count: Math.round(repairCost),
},
],
tid: traderId, tid: traderId,
Action: "", Action: "",
type: "", type: "",
@ -149,11 +142,7 @@ export class RepairService
* @param repairDetails details of item repaired, cost/item * @param repairDetails details of item repaired, cost/item
* @param pmcData Profile to add points to * @param pmcData Profile to add points to
*/ */
public addRepairSkillPoints( public addRepairSkillPoints(sessionId: string, repairDetails: RepairDetails, pmcData: IPmcData): void
sessionId: string,
repairDetails: RepairDetails,
pmcData: IPmcData,
): void
{ {
if ( if (
repairDetails.repairedByKit repairDetails.repairedByKit
@ -186,9 +175,7 @@ export class RepairService
} }
const isHeavyArmor = itemDetails[1]._props.ArmorType === "Heavy"; const isHeavyArmor = itemDetails[1]._props.ArmorType === "Heavy";
const vestSkillToLevel = isHeavyArmor const vestSkillToLevel = isHeavyArmor ? SkillTypes.HEAVY_VESTS : SkillTypes.LIGHT_VESTS;
? SkillTypes.HEAVY_VESTS
: SkillTypes.LIGHT_VESTS;
const pointsToAddToVestSkill = repairDetails.repairPoints const pointsToAddToVestSkill = repairDetails.repairPoints
* this.repairConfig.armorKitSkillPointGainPerRepairPointMultiplier; * this.repairConfig.armorKitSkillPointGainPerRepairPointMultiplier;
@ -227,9 +214,7 @@ export class RepairService
* @param repairDetails the repair details to calculate skill points for * @param repairDetails the repair details to calculate skill points for
* @returns the number of skill points to reward the user * @returns the number of skill points to reward the user
*/ */
protected getWeaponRepairSkillPoints( protected getWeaponRepairSkillPoints(repairDetails: RepairDetails): number
repairDetails: RepairDetails,
): number
{ {
// This formula and associated configs is calculated based on 30 repairs done on live // This formula and associated configs is calculated based on 30 repairs done on live
// The points always came out 2-aligned, which is why there's a divide/multiply by 2 with ceil calls // The points always came out 2-aligned, which is why there's a divide/multiply by 2 with ceil calls
@ -420,17 +405,11 @@ export class RepairService
if (!repairKitInInventory.upd) if (!repairKitInInventory.upd)
{ {
this.logger.debug(`Repair kit: ${repairKitInInventory._id} in inventory lacks upd object, adding`); this.logger.debug(`Repair kit: ${repairKitInInventory._id} in inventory lacks upd object, adding`);
repairKitInInventory.upd = { repairKitInInventory.upd = {RepairKit: {Resource: maxRepairAmount}};
RepairKit: {
Resource: maxRepairAmount,
},
};
} }
if (!repairKitInInventory.upd.RepairKit?.Resource) if (!repairKitInInventory.upd.RepairKit?.Resource)
{ {
repairKitInInventory.upd.RepairKit = { repairKitInInventory.upd.RepairKit = {Resource: maxRepairAmount};
Resource: maxRepairAmount,
};
} }
} }

View File

@ -236,10 +236,7 @@ export class SeasonalEventService
const eventEndDate = new Date(currentDate.getFullYear(), event.endMonth - 1, event.endDay); const eventEndDate = new Date(currentDate.getFullYear(), event.endMonth - 1, event.endDay);
// Current date is between start/end dates // Current date is between start/end dates
if ( if (currentDate >= eventStartDate && currentDate <= eventEndDate)
currentDate >= eventStartDate
&& currentDate <= eventEndDate
)
{ {
this.christmasEventActive = SeasonalEventType[event.type] === SeasonalEventType.CHRISTMAS; this.christmasEventActive = SeasonalEventType[event.type] === SeasonalEventType.CHRISTMAS;
this.halloweenEventActive = SeasonalEventType[event.type] === SeasonalEventType.HALLOWEEN; this.halloweenEventActive = SeasonalEventType[event.type] === SeasonalEventType.HALLOWEEN;

View File

@ -120,9 +120,7 @@ export class CustomItemService
*/ */
protected getOrGenerateIdForItem(newId: string): string protected getOrGenerateIdForItem(newId: string): string
{ {
return (newId === "") return (newId === "") ? this.hashUtil.generate() : newId;
? this.hashUtil.generate()
: newId;
} }
/** /**
@ -157,13 +155,7 @@ export class CustomItemService
*/ */
protected addToHandbookDb(newItemId: string, parentId: string, priceRoubles: number): void protected addToHandbookDb(newItemId: string, parentId: string, priceRoubles: number): void
{ {
this.tables.templates.handbook.Items.push( this.tables.templates.handbook.Items.push({Id: newItemId, ParentId: parentId, Price: priceRoubles});
{
Id: newItemId,
ParentId: parentId,
Price: priceRoubles,
},
);
} }
/** /**

View File

@ -2,10 +2,7 @@ import { DynamicRouter, RouteAction } from "@spt-aki/di/Router";
export class DynamicRouterMod extends DynamicRouter export class DynamicRouterMod extends DynamicRouter
{ {
public constructor( public constructor(routes: RouteAction[], private topLevelRoute: string)
routes: RouteAction[],
private topLevelRoute: string,
)
{ {
super(routes); super(routes);
} }

View File

@ -8,11 +8,7 @@ export class DynamicRouterModService
{ {
constructor(private container: DependencyContainer) constructor(private container: DependencyContainer)
{} {}
public registerDynamicRouter( public registerDynamicRouter(name: string, routes: RouteAction[], topLevelRoute: string): void
name: string,
routes: RouteAction[],
topLevelRoute: string,
): void
{ {
this.container.register(name, {useValue: new DynamicRouterMod(routes, topLevelRoute)}); this.container.register(name, {useValue: new DynamicRouterMod(routes, topLevelRoute)});
this.container.registerType("DynamicRoutes", name); this.container.registerType("DynamicRoutes", name);

View File

@ -2,10 +2,7 @@ import { OnLoad } from "@spt-aki/di/OnLoad";
export class OnLoadMod implements OnLoad export class OnLoadMod implements OnLoad
{ {
public constructor( public constructor(private onLoadOverride: () => void, private getRouteOverride: () => string)
private onLoadOverride: () => void,
private getRouteOverride: () => string,
)
{ {
// super(); // super();
} }

View File

@ -8,11 +8,7 @@ export class OnLoadModService
constructor(protected container: DependencyContainer) constructor(protected container: DependencyContainer)
{} {}
public registerOnLoad( public registerOnLoad(name: string, onLoad: () => void, getRoute: () => string): void
name: string,
onLoad: () => void,
getRoute: () => string,
): void
{ {
this.container.register(name, {useValue: new OnLoadMod(onLoad, getRoute)}); this.container.register(name, {useValue: new OnLoadMod(onLoad, getRoute)});
this.container.registerType("OnLoad", name); this.container.registerType("OnLoad", name);

View File

@ -8,11 +8,7 @@ export class OnUpdateModService
constructor(protected container: DependencyContainer) constructor(protected container: DependencyContainer)
{} {}
public registerOnUpdate( public registerOnUpdate(name: string, onUpdate: (timeSinceLastRun: number) => boolean, getRoute: () => string): void
name: string,
onUpdate: (timeSinceLastRun: number) => boolean,
getRoute: () => string,
): void
{ {
this.container.register(name, {useValue: new OnUpdateMod(onUpdate, getRoute)}); this.container.register(name, {useValue: new OnUpdateMod(onUpdate, getRoute)});
this.container.registerType("OnUpdate", name); this.container.registerType("OnUpdate", name);

View File

@ -2,10 +2,7 @@ import { RouteAction, StaticRouter } from "@spt-aki/di/Router";
export class StaticRouterMod extends StaticRouter export class StaticRouterMod extends StaticRouter
{ {
public constructor( public constructor(routes: RouteAction[], private topLevelRoute: string)
routes: RouteAction[],
private topLevelRoute: string,
)
{ {
super(routes); super(routes);
} }

View File

@ -8,11 +8,7 @@ export class StaticRouterModService
{ {
constructor(protected container: DependencyContainer) constructor(protected container: DependencyContainer)
{} {}
public registerStaticRouter( public registerStaticRouter(name: string, routes: RouteAction[], topLevelRoute: string): void
name: string,
routes: RouteAction[],
topLevelRoute: string,
): void
{ {
this.container.register(name, {useValue: new StaticRouterMod(routes, topLevelRoute)}); this.container.register(name, {useValue: new StaticRouterMod(routes, topLevelRoute)});
this.container.registerType("StaticRoutes", name); this.container.registerType("StaticRoutes", name);

View File

@ -45,9 +45,7 @@ export class DatabaseImporter implements OnLoad
*/ */
public getSptDataPath(): string public getSptDataPath(): string
{ {
return (globalThis.G_RELEASE_CONFIGURATION) return (globalThis.G_RELEASE_CONFIGURATION) ? "Aki_Data/Server/" : "./assets/";
? "Aki_Data/Server/"
: "./assets/";
} }
public async onLoad(): Promise<void> public async onLoad(): Promise<void>

View File

@ -6,9 +6,7 @@ import { TimeUtil } from "@spt-aki/utils/TimeUtil";
@injectable() @injectable()
export class HashUtil export class HashUtil
{ {
constructor( constructor(@inject("TimeUtil") protected timeUtil: TimeUtil)
@inject("TimeUtil") protected timeUtil: TimeUtil,
)
{} {}
/** /**

View File

@ -7,9 +7,7 @@ import { HttpServerHelper } from "@spt-aki/helpers/HttpServerHelper";
@injectable() @injectable()
export class HttpFileUtil export class HttpFileUtil
{ {
constructor( constructor(@inject("HttpServerHelper") protected httpServerHelper: HttpServerHelper)
@inject("HttpServerHelper") protected httpServerHelper: HttpServerHelper,
)
{ {
} }

View File

@ -18,12 +18,10 @@ export class HttpResponseUtil
protected clearString(s: string): any protected clearString(s: string): any
{ {
return s.replace(/[\b]/g, "") return s.replace(/[\b]/g, "").replace(/[\f]/g, "").replace(/[\n]/g, "").replace(/[\r]/g, "").replace(
.replace(/[\f]/g, "") /[\t]/g,
.replace(/[\n]/g, "") "",
.replace(/[\r]/g, "") ).replace(/[\\]/g, "");
.replace(/[\t]/g, "")
.replace(/[\\]/g, "");
} }
/** /**
@ -43,11 +41,7 @@ export class HttpResponseUtil
public getUnclearedBody(data: any, err = 0, errmsg = null): string public getUnclearedBody(data: any, err = 0, errmsg = null): string
{ {
return this.jsonUtil.serialize({ return this.jsonUtil.serialize({err: err, errmsg: errmsg, data: data});
err: err,
errmsg: errmsg,
data: data,
});
} }
public emptyResponse(): IGetBodyResponseData<string> public emptyResponse(): IGetBodyResponseData<string>
@ -71,11 +65,7 @@ export class HttpResponseUtil
errorCode = BackendErrorCodes.NONE, errorCode = BackendErrorCodes.NONE,
): IItemEventRouterResponse ): IItemEventRouterResponse
{ {
output.warnings = [{ output.warnings = [{index: 0, errmsg: message, code: errorCode.toString()}];
index: 0,
errmsg: message,
code: errorCode.toString(),
}];
return output; return output;
} }

View File

@ -9,10 +9,7 @@ import { Queue } from "@spt-aki/utils/collections/queue/Queue";
@injectable() @injectable()
export class ImporterUtil export class ImporterUtil
{ {
constructor( constructor(@inject("VFS") protected vfs: VFS, @inject("JsonUtil") protected jsonUtil: JsonUtil)
@inject("VFS") protected vfs: VFS,
@inject("JsonUtil") protected jsonUtil: JsonUtil,
)
{} {}
/** /**
@ -74,13 +71,9 @@ export class ImporterUtil
* @param filepath Path to folder with files * @param filepath Path to folder with files
* @returns * @returns
*/ */
public loadRecursive<T>( public loadRecursive<T>(filepath: string, onReadCallback: (fileWithPath: string, data: string) => void = () =>
filepath: string, {}, onObjectDeserialized: (fileWithPath: string, object: any) => void = () =>
onReadCallback: (fileWithPath: string, data: string) => void = () => {}): T
{},
onObjectDeserialized: (fileWithPath: string, object: any) => void = () =>
{},
): T
{ {
const result = {} as T; const result = {} as T;
@ -148,18 +141,16 @@ export class ImporterUtil
{ {
const filePathAndName = `${fileNode.filePath}${fileNode.fileName}`; const filePathAndName = `${fileNode.filePath}${fileNode.fileName}`;
promises.push( promises.push(
this.vfs.readFileAsync(filePathAndName) this.vfs.readFileAsync(filePathAndName).then(async (fileData) =>
.then(async (fileData) => {
{ onReadCallback(filePathAndName, fileData);
onReadCallback(filePathAndName, fileData); return this.jsonUtil.deserializeWithCacheCheckAsync<any>(fileData, filePathAndName);
return this.jsonUtil.deserializeWithCacheCheckAsync<any>(fileData, filePathAndName); }).then(async (fileDeserialized) =>
}) {
.then(async (fileDeserialized) => onObjectDeserialized(filePathAndName, fileDeserialized);
{ const strippedFilePath = this.vfs.stripExtension(filePathAndName).replace(filepath, "");
onObjectDeserialized(filePathAndName, fileDeserialized); this.placeObject(fileDeserialized, strippedFilePath, result, strippablePath);
const strippedFilePath = this.vfs.stripExtension(filePathAndName).replace(filepath, ""); }),
this.placeObject(fileDeserialized, strippedFilePath, result, strippablePath);
}),
); );
} }
} }
@ -196,9 +187,6 @@ export class ImporterUtil
class VisitNode class VisitNode
{ {
constructor( constructor(public filePath: string, public fileName: string)
public filePath: string,
public fileName: string,
)
{} {}
} }

View File

@ -63,11 +63,7 @@ export class JsonUtil
* @param options Stringify options or a replacer. * @param options Stringify options or a replacer.
* @returns The string converted from the JavaScript value * @returns The string converted from the JavaScript value
*/ */
public serializeJsonC( public serializeJsonC(data: any, filename?: string | null, options?: IStringifyOptions | Reviver): string
data: any,
filename?: string | null,
options?: IStringifyOptions | Reviver,
): string
{ {
try try
{ {
@ -81,11 +77,7 @@ export class JsonUtil
} }
} }
public serializeJson5( public serializeJson5(data: any, filename?: string | null, prettify = false): string
data: any,
filename?: string | null,
prettify = false,
): string
{ {
try try
{ {

View File

@ -6,9 +6,7 @@ import { TimeUtil } from "@spt-aki/utils/TimeUtil";
@injectable() @injectable()
export class ObjectId export class ObjectId
{ {
constructor( constructor(@inject("TimeUtil") protected timeUtil: TimeUtil)
@inject("TimeUtil") protected timeUtil: TimeUtil,
)
{} {}
protected randomBytes = crypto.randomBytes(5); protected randomBytes = crypto.randomBytes(5);

View File

@ -21,11 +21,7 @@ import { MathUtil } from "@spt-aki/utils/MathUtil";
*/ */
export class ProbabilityObjectArray<K, V = undefined> extends Array<ProbabilityObject<K, V>> export class ProbabilityObjectArray<K, V = undefined> extends Array<ProbabilityObject<K, V>>
{ {
constructor( constructor(private mathUtil: MathUtil, private jsonUtil: JsonUtil, ...items: ProbabilityObject<K, V>[])
private mathUtil: MathUtil,
private jsonUtil: JsonUtil,
...items: ProbabilityObject<K, V>[]
)
{ {
super(); super();
this.push(...items); this.push(...items);
@ -204,10 +200,7 @@ export class ProbabilityObject<K, V = undefined>
@injectable() @injectable()
export class RandomUtil export class RandomUtil
{ {
constructor( constructor(@inject("JsonUtil") protected jsonUtil: JsonUtil, @inject("WinstonLogger") protected logger: ILogger)
@inject("JsonUtil") protected jsonUtil: JsonUtil,
@inject("WinstonLogger") protected logger: ILogger,
)
{ {
} }
@ -381,10 +374,7 @@ export class RandomUtil
if (n < 1) if (n < 1)
{ {
throw { throw {name: "Invalid argument", message: `'n' must be 1 or greater (received ${n})`};
name: "Invalid argument",
message: `'n' must be 1 or greater (received ${n})`,
};
} }
if (min === max) if (min === max)
@ -453,10 +443,7 @@ export class RandomUtil
currentIndex--; currentIndex--;
// And swap it with the current element. // And swap it with the current element.
[array[currentIndex], array[randomIndex]] = [ [array[currentIndex], array[randomIndex]] = [array[randomIndex], array[currentIndex]];
array[randomIndex],
array[currentIndex],
];
} }
return array; return array;

View File

@ -26,9 +26,7 @@ export class VFS
rmdirPromisify: (path: fs.PathLike) => Promise<void>; rmdirPromisify: (path: fs.PathLike) => Promise<void>;
renamePromisify: (oldPath: fs.PathLike, newPath: fs.PathLike) => Promise<void>; renamePromisify: (oldPath: fs.PathLike, newPath: fs.PathLike) => Promise<void>;
constructor( constructor(@inject("AsyncQueue") protected asyncQueue: IAsyncQueue)
@inject("AsyncQueue") protected asyncQueue: IAsyncQueue,
)
{ {
this.accessFilePromisify = promisify(fs.access); this.accessFilePromisify = promisify(fs.access);
this.copyFilePromisify = promisify(fs.copyFile); this.copyFilePromisify = promisify(fs.copyFile);
@ -52,10 +50,7 @@ export class VFS
try try
{ {
// Create the command to add to the queue // Create the command to add to the queue
const command = { const command = {uuid: crypto.randomUUID(), cmd: async () => await this.accessFilePromisify(filepath)};
uuid: crypto.randomUUID(),
cmd: async () => await this.accessFilePromisify(filepath),
};
// Wait for the command completion // Wait for the command completion
await this.asyncQueue.waitFor(command); await this.asyncQueue.waitFor(command);
@ -76,10 +71,7 @@ export class VFS
public async copyAsync(filepath: fs.PathLike, target: fs.PathLike): Promise<void> public async copyAsync(filepath: fs.PathLike, target: fs.PathLike): Promise<void>
{ {
const command = { const command = {uuid: crypto.randomUUID(), cmd: async () => await this.copyFilePromisify(filepath, target)};
uuid: crypto.randomUUID(),
cmd: async () => await this.copyFilePromisify(filepath, target),
};
await this.asyncQueue.waitFor(command); await this.asyncQueue.waitFor(command);
} }

View File

@ -14,9 +14,7 @@ export class WatermarkLocale
protected warning: string[]; protected warning: string[];
protected modding: string[]; protected modding: string[];
constructor( constructor(@inject("LocalisationService") protected localisationService: LocalisationService)
@inject("LocalisationService") protected localisationService: LocalisationService,
)
{ {
this.description = [ this.description = [
this.localisationService.getText("watermark-discord_url"), this.localisationService.getText("watermark-discord_url"),

View File

@ -17,22 +17,8 @@ export abstract class AbstractWinstonLogger implements ILogger
protected showDebugInConsole = false; protected showDebugInConsole = false;
protected filePath: string; protected filePath: string;
protected logLevels = { protected logLevels = {
levels: { levels: {error: 0, warn: 1, succ: 2, info: 3, custom: 4, debug: 5},
error: 0, colors: {error: "red", warn: "yellow", succ: "green", info: "white", custom: "black", debug: "gray"},
warn: 1,
succ: 2,
info: 3,
custom: 4,
debug: 5,
},
colors: {
error: "red",
warn: "yellow",
succ: "green",
info: "white",
custom: "black",
debug: "gray",
},
bgColors: { bgColors: {
default: "", default: "",
blackBG: "blackBG", blackBG: "blackBG",
@ -48,9 +34,7 @@ export abstract class AbstractWinstonLogger implements ILogger
protected logger: winston.Logger & SptLogger; protected logger: winston.Logger & SptLogger;
protected writeFilePromisify: (path: fs.PathLike, data: string, options?: any) => Promise<void>; protected writeFilePromisify: (path: fs.PathLike, data: string, options?: any) => Promise<void>;
constructor( constructor(protected asyncQueue: IAsyncQueue)
protected asyncQueue: IAsyncQueue,
)
{ {
this.filePath = `${this.getFilePath()}${this.getFileName()}`; this.filePath = `${this.getFilePath()}${this.getFileName()}`;
this.writeFilePromisify = promisify(fs.writeFile); this.writeFilePromisify = promisify(fs.writeFile);
@ -101,10 +85,7 @@ export abstract class AbstractWinstonLogger implements ILogger
} }
winston.addColors(this.logLevels.colors); winston.addColors(this.logLevels.colors);
this.logger = createLogger({ this.logger = createLogger({levels: this.logLevels.levels, transports: [...transportsList]});
levels: this.logLevels.levels,
transports: [...transportsList],
});
if (this.isLogExceptions()) if (this.isLogExceptions())
{ {
@ -165,10 +146,7 @@ export abstract class AbstractWinstonLogger implements ILogger
if (typeof data === "string") if (typeof data === "string")
{ {
command = { command = {uuid: crypto.randomUUID(), cmd: async () => await tmpLogger.log("custom", data)};
uuid: crypto.randomUUID(),
cmd: async () => await tmpLogger.log("custom", data),
};
} }
else else
{ {
@ -183,37 +161,25 @@ export abstract class AbstractWinstonLogger implements ILogger
public async error(data: string | Record<string, unknown>): Promise<void> public async error(data: string | Record<string, unknown>): Promise<void>
{ {
const command: ICommand = { const command: ICommand = {uuid: crypto.randomUUID(), cmd: async () => await this.logger.error(data)};
uuid: crypto.randomUUID(),
cmd: async () => await this.logger.error(data),
};
await this.asyncQueue.waitFor(command); await this.asyncQueue.waitFor(command);
} }
public async warning(data: string | Record<string, unknown>): Promise<void> public async warning(data: string | Record<string, unknown>): Promise<void>
{ {
const command: ICommand = { const command: ICommand = {uuid: crypto.randomUUID(), cmd: async () => await this.logger.warn(data)};
uuid: crypto.randomUUID(),
cmd: async () => await this.logger.warn(data),
};
await this.asyncQueue.waitFor(command); await this.asyncQueue.waitFor(command);
} }
public async success(data: string | Record<string, unknown>): Promise<void> public async success(data: string | Record<string, unknown>): Promise<void>
{ {
const command: ICommand = { const command: ICommand = {uuid: crypto.randomUUID(), cmd: async () => await this.logger.succ(data)};
uuid: crypto.randomUUID(),
cmd: async () => await this.logger.succ(data),
};
await this.asyncQueue.waitFor(command); await this.asyncQueue.waitFor(command);
} }
public async info(data: string | Record<string, unknown>): Promise<void> public async info(data: string | Record<string, unknown>): Promise<void>
{ {
const command: ICommand = { const command: ICommand = {uuid: crypto.randomUUID(), cmd: async () => await this.logger.info(data)};
uuid: crypto.randomUUID(),
cmd: async () => await this.logger.info(data),
};
await this.asyncQueue.waitFor(command); await this.asyncQueue.waitFor(command);
} }
@ -243,17 +209,11 @@ export abstract class AbstractWinstonLogger implements ILogger
if (onlyShowInConsole) if (onlyShowInConsole)
{ {
command = { command = {uuid: crypto.randomUUID(), cmd: async () => await this.log(data, this.logLevels.colors.debug)};
uuid: crypto.randomUUID(),
cmd: async () => await this.log(data, this.logLevels.colors.debug),
};
} }
else else
{ {
command = { command = {uuid: crypto.randomUUID(), cmd: async () => await this.logger.debug(data)};
uuid: crypto.randomUUID(),
cmd: async () => await this.logger.debug(data),
};
} }
await this.asyncQueue.waitFor(command); await this.asyncQueue.waitFor(command);

View File

@ -6,9 +6,7 @@ import { AbstractWinstonLogger } from "@spt-aki/utils/logging/AbstractWinstonLog
@injectable() @injectable()
export class WinstonMainLogger extends AbstractWinstonLogger export class WinstonMainLogger extends AbstractWinstonLogger
{ {
constructor( constructor(@inject("AsyncQueue") protected asyncQueue: IAsyncQueue)
@inject("AsyncQueue") protected asyncQueue: IAsyncQueue,
)
{ {
super(asyncQueue); super(asyncQueue);
} }

View File

@ -6,9 +6,7 @@ import { AbstractWinstonLogger } from "@spt-aki/utils/logging/AbstractWinstonLog
@injectable() @injectable()
export class WinstonRequestLogger extends AbstractWinstonLogger export class WinstonRequestLogger extends AbstractWinstonLogger
{ {
constructor( constructor(@inject("AsyncQueue") protected asyncQueue: IAsyncQueue)
@inject("AsyncQueue") protected asyncQueue: IAsyncQueue,
)
{ {
super(asyncQueue); super(asyncQueue);
} }

View File

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

View File

@ -34,10 +34,7 @@ describe("InsuranceController", () =>
{ {
const session1 = "session1"; const session1 = "session1";
const session2 = "session2"; const session2 = "session2";
const profiles = { const profiles = {[session1]: {}, [session2]: {}};
[session1]: {},
[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( const processReturnByProfileSpy = vi.spyOn(insuranceController, "processReturnByProfile").mockReturnValue(
vi.fn(), vi.fn(),
@ -75,10 +72,12 @@ describe("InsuranceController", () =>
const sessionId = "session-id"; const sessionId = "session-id";
// Mock internal methods. // Mock internal methods.
const mockFilterInsuredItems = vi.spyOn(insuranceController, "filterInsuredItems") const mockFilterInsuredItems = vi.spyOn(insuranceController, "filterInsuredItems").mockReturnValue(
.mockReturnValue(insuranceFixture); insuranceFixture,
const mockProcessInsuredItems = vi.spyOn(insuranceController, "processInsuredItems") );
.mockImplementation(vi.fn()); const mockProcessInsuredItems = vi.spyOn(insuranceController, "processInsuredItems").mockImplementation(
vi.fn(),
);
insuranceController.processReturnByProfile(sessionId); insuranceController.processReturnByProfile(sessionId);
@ -92,10 +91,10 @@ describe("InsuranceController", () =>
const sessionId = "session-id"; const sessionId = "session-id";
// Mock internal methods. // Mock internal methods.
const mockFilterInsuredItems = vi.spyOn(insuranceController, "filterInsuredItems") const mockFilterInsuredItems = vi.spyOn(insuranceController, "filterInsuredItems").mockReturnValue([]); // Return an empty array.
.mockReturnValue([]); // Return an empty array. const mockProcessInsuredItems = vi.spyOn(insuranceController, "processInsuredItems").mockImplementation(
const mockProcessInsuredItems = vi.spyOn(insuranceController, "processInsuredItems") vi.fn(),
.mockImplementation(vi.fn()); );
insuranceController.processReturnByProfile(sessionId); insuranceController.processReturnByProfile(sessionId);
@ -113,8 +112,9 @@ describe("InsuranceController", () =>
const insured = JSON.parse(JSON.stringify(insuranceFixture)); const insured = JSON.parse(JSON.stringify(insuranceFixture));
// Mock getProfile to return the fixture. // Mock getProfile to return the fixture.
const mockGetProfile = vi.spyOn(insuranceController.saveServer, "getProfile") const mockGetProfile = vi.spyOn(insuranceController.saveServer, "getProfile").mockReturnValue({
.mockReturnValue({insurance: insured}); insurance: insured,
});
const mockLoggerDebug = vi.spyOn(insuranceController.logger, "debug"); const mockLoggerDebug = vi.spyOn(insuranceController.logger, "debug");
// Execute the method. // Execute the method.
@ -137,8 +137,9 @@ describe("InsuranceController", () =>
insured[0].scheduledTime = Math.floor((Date.now() / 1000) + (2 * 60 * 60)); insured[0].scheduledTime = Math.floor((Date.now() / 1000) + (2 * 60 * 60));
// Mock getProfile to return the fixture. // Mock getProfile to return the fixture.
const mockGetProfile = vi.spyOn(insuranceController.saveServer, "getProfile") const mockGetProfile = vi.spyOn(insuranceController.saveServer, "getProfile").mockReturnValue({
.mockReturnValue({insurance: insured}); insurance: insured,
});
const mockLoggerDebug = vi.spyOn(insuranceController.logger, "debug"); const mockLoggerDebug = vi.spyOn(insuranceController.logger, "debug");
// Execute the method. // Execute the method.
@ -158,8 +159,9 @@ describe("InsuranceController", () =>
const insured = JSON.parse(JSON.stringify(insuranceFixture)); const insured = JSON.parse(JSON.stringify(insuranceFixture));
// Mock getProfile to return the fixture. // Mock getProfile to return the fixture.
const mockGetProfile = vi.spyOn(insuranceController.saveServer, "getProfile") const mockGetProfile = vi.spyOn(insuranceController.saveServer, "getProfile").mockReturnValue({
.mockReturnValue({insurance: insured}); insurance: insured,
});
const mockLoggerDebug = vi.spyOn(insuranceController.logger, "debug"); const mockLoggerDebug = vi.spyOn(insuranceController.logger, "debug");
// 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
@ -241,25 +243,19 @@ describe("InsuranceController", () =>
{ {
it("should return the total number of items in all insurance packages", () => it("should return the total number of items in all insurance packages", () =>
{ {
const insurance = [ const insurance = [{
{ _id: "1",
_id: "1", upd: 1234567890,
upd: 1234567890, items: [{_id: "1", parentId: "1", slotId: "1"}, {_id: "2", parentId: "1", slotId: "2"}],
items: [ }, {
{_id: "1", parentId: "1", slotId: "1"}, _id: "2",
{_id: "2", parentId: "1", slotId: "2"}, upd: 1234567890,
], items: [{_id: "3", parentId: "2", slotId: "1"}, {_id: "4", parentId: "2", slotId: "2"}, {
}, _id: "5",
{ parentId: "2",
_id: "2", slotId: "3",
upd: 1234567890, }],
items: [ }];
{_id: "3", parentId: "2", slotId: "1"},
{_id: "4", parentId: "2", slotId: "2"},
{_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.
// Execute the method. // Execute the method.
@ -283,18 +279,7 @@ describe("InsuranceController", () =>
it("should return 0 if there are no items in any of the insurance packages", () => it("should return 0 if there are no items in any of the insurance packages", () =>
{ {
const insurance = [ const insurance = [{_id: "1", upd: 1234567890, items: []}, {_id: "2", upd: 1234567890, items: []}];
{
_id: "1",
upd: 1234567890,
items: [],
},
{
_id: "2",
upd: 1234567890,
items: [],
},
];
const expectedCount = 0; const expectedCount = 0;
// Execute the method. // Execute the method.
@ -310,32 +295,13 @@ describe("InsuranceController", () =>
it("should remove the specified insurance package from the profile", () => it("should remove the specified insurance package from the profile", () =>
{ {
const sessionID = "session-id"; const sessionID = "session-id";
const packageToRemove = { const packageToRemove = {date: "01.11.2023", time: "10:51", location: "factory4_day"};
date: "01.11.2023",
time: "10:51",
location: "factory4_day",
};
const profile = { const profile = {
insurance: [ insurance: [{
{ messageContent: {systemData: {date: "01.11.2023", time: "11:18", location: "factory4_day"}},
messageContent: { }, { // This one should be removed
systemData: { messageContent: {systemData: {date: "01.11.2023", time: "10:51", location: "factory4_day"}},
date: "01.11.2023", }],
time: "11:18",
location: "factory4_day",
},
},
},
{ // This one should be removed
messageContent: {
systemData: {
date: "01.11.2023",
time: "10:51",
location: "factory4_day",
},
},
},
],
}; };
// Mock the getProfile method to return the above profile. // Mock the getProfile method to return the above profile.
@ -356,23 +322,11 @@ describe("InsuranceController", () =>
it("should log a message indicating that the package was removed", () => it("should log a message indicating that the package was removed", () =>
{ {
const sessionID = "session-id"; const sessionID = "session-id";
const packageToRemove = { const packageToRemove = {date: "01.11.2023", time: "10:51", location: "factory4_day"};
date: "01.11.2023",
time: "10:51",
location: "factory4_day",
};
const profile = { const profile = {
insurance: [ insurance: [{
{ messageContent: {systemData: {date: "01.11.2023", time: "10:51", location: "factory4_day"}},
messageContent: { }],
systemData: {
date: "01.11.2023",
time: "10:51",
location: "factory4_day",
},
},
},
],
}; };
// Mock the getProfile method to return the above profile. // Mock the getProfile method to return the above profile.
@ -393,23 +347,11 @@ describe("InsuranceController", () =>
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", () =>
{ {
const sessionID = "session-id"; const sessionID = "session-id";
const packageToRemove = { const packageToRemove = {date: "01.11.2023", time: "10:51", location: "factory4_day"};
date: "01.11.2023",
time: "10:51",
location: "factory4_day",
};
const profile = { const profile = {
insurance: [ insurance: [{
{ messageContent: {systemData: {date: "02.11.2023", time: "10:50", location: "factory4_night"}},
messageContent: { }],
systemData: {
date: "02.11.2023",
time: "10:50",
location: "factory4_night",
},
},
},
],
}; };
// Mock the getProfile method to return the above profile. // Mock the getProfile method to return the above profile.
@ -975,10 +917,11 @@ describe("InsuranceController", () =>
{ {
it("should log details for each attachment", () => it("should log details for each attachment", () =>
{ {
const attachments = [ const attachments = [{_id: "item1", name: "Item 1", maxPrice: 100}, {
{_id: "item1", name: "Item 1", maxPrice: 100}, _id: "item2",
{_id: "item2", name: "Item 2", maxPrice: 200}, name: "Item 2",
]; maxPrice: 200,
}];
// Mock the logger.debug function. // Mock the logger.debug function.
const loggerDebugSpy = vi.spyOn(insuranceController.logger, "debug"); const loggerDebugSpy = vi.spyOn(insuranceController.logger, "debug");
@ -1018,8 +961,7 @@ describe("InsuranceController", () =>
// Mock rollForDelete to return true for the first two attachments. // Mock rollForDelete to return true for the first two attachments.
const mockRollForDelete = vi.spyOn(insuranceController, "rollForDelete").mockReturnValue(false) const mockRollForDelete = vi.spyOn(insuranceController, "rollForDelete").mockReturnValue(false)
.mockReturnValueOnce(true) .mockReturnValueOnce(true).mockReturnValueOnce(true);
.mockReturnValueOnce(true);
// Execute the method. // Execute the method.
const result = insuranceController.countSuccessfulRolls(attachments, insured.traderId); const result = insuranceController.countSuccessfulRolls(attachments, insured.traderId);
@ -1298,8 +1240,9 @@ describe("InsuranceController", () =>
const insuranceFailedTpl = "failed-message-template"; const insuranceFailedTpl = "failed-message-template";
// Mock the randomUtil to return a static failed template string. // Mock the randomUtil to return a static failed template string.
const mockGetArrayValue = vi.spyOn(insuranceController.randomUtil, "getArrayValue") const mockGetArrayValue = vi.spyOn(insuranceController.randomUtil, "getArrayValue").mockReturnValue(
.mockReturnValue(insuranceFailedTpl); insuranceFailedTpl,
);
// Don't actually send the message. // Don't actually send the message.
const sendMessageSpy = vi.spyOn(insuranceController.mailSendService, "sendLocalisedNpcMessageToPlayer") const sendMessageSpy = vi.spyOn(insuranceController.mailSendService, "sendLocalisedNpcMessageToPlayer")
@ -1332,8 +1275,9 @@ describe("InsuranceController", () =>
const insuranceFailedTpl = "failed-message-template"; const insuranceFailedTpl = "failed-message-template";
// Mock the randomUtil to return a static failed template string. // Mock the randomUtil to return a static failed template string.
const mockGetArrayValue = vi.spyOn(insuranceController.randomUtil, "getArrayValue") const mockGetArrayValue = vi.spyOn(insuranceController.randomUtil, "getArrayValue").mockReturnValue(
.mockReturnValue(insuranceFailedTpl); insuranceFailedTpl,
);
// Don't actually send the message. // Don't actually send the message.
const sendMessageSpy = vi.spyOn(insuranceController.mailSendService, "sendLocalisedNpcMessageToPlayer") const sendMessageSpy = vi.spyOn(insuranceController.mailSendService, "sendLocalisedNpcMessageToPlayer")
@ -1452,18 +1396,10 @@ describe("InsuranceController", () =>
// Setup shared test data. // Setup shared test data.
pmcData = { pmcData = {
Inventory: { Inventory: {items: [{_id: "item1", otherProps: "value1"}, {_id: "item2", otherProps: "value2"}]},
items: [
{_id: "item1", otherProps: "value1"},
{_id: "item2", otherProps: "value2"},
],
},
InsuredItems: [], InsuredItems: [],
}; };
body = { body = {items: ["item1", "item2"], tid: "someTraderId"};
items: ["item1", "item2"],
tid: "someTraderId",
};
sessionId = "session-id"; sessionId = "session-id";
// Setup shared mocks. // Setup shared mocks.
@ -1488,10 +1424,7 @@ describe("InsuranceController", () =>
expect(mockPayMoney).toHaveBeenCalledWith( expect(mockPayMoney).toHaveBeenCalledWith(
pmcData, pmcData,
{ {
scheme_items: [ scheme_items: [{id: "item1", count: 100}, {id: "item2", count: 100}],
{id: "item1", count: 100},
{id: "item2", count: 100},
],
tid: "someTraderId", tid: "someTraderId",
Action: "", Action: "",
type: "", type: "",
@ -1500,10 +1433,7 @@ describe("InsuranceController", () =>
scheme_id: 0, scheme_id: 0,
}, },
sessionId, sessionId,
{ {warnings: [], otherProperty: "property-value"},
warnings: [],
otherProperty: "property-value",
},
); );
}); });
@ -1529,10 +1459,7 @@ describe("InsuranceController", () =>
// Define the expected payment options structure based on the setup data. // Define the expected payment options structure based on the setup data.
const expectedPaymentOptions = { const expectedPaymentOptions = {
scheme_items: [ scheme_items: [{id: "item1", count: 100}, {id: "item2", count: 100}],
{id: "item1", count: 100},
{id: "item2", count: 100},
],
tid: body.tid, tid: body.tid,
Action: "", Action: "",
type: "", type: "",
@ -1571,11 +1498,7 @@ describe("InsuranceController", () =>
{ {
// Override the payMoney mock to simulate a payment failure with a warning. // Override the payMoney mock to simulate a payment failure with a warning.
const expectedPayMoneyReturn = { const expectedPayMoneyReturn = {
warnings: [{ warnings: [{index: 0, errmsg: "Not enough money to complete transaction", code: 500}],
index: 0,
errmsg: "Not enough money to complete transaction",
code: 500,
}],
otherProperty: "property-value", otherProperty: "property-value",
}; };
mockPayMoney.mockReturnValue(expectedPayMoneyReturn); mockPayMoney.mockReturnValue(expectedPayMoneyReturn);
@ -1594,11 +1517,7 @@ describe("InsuranceController", () =>
{ {
// Override the payMoney mock to simulate a payment failure with a warning. // Override the payMoney mock to simulate a payment failure with a warning.
const expectedPayMoneyReturn = { const expectedPayMoneyReturn = {
warnings: [{ warnings: [{index: 0, errmsg: "Not enough money to complete transaction", code: 500}],
index: 0,
errmsg: "Not enough money to complete transaction",
code: 500,
}],
otherProperty: "property-value", otherProperty: "property-value",
}; };
mockPayMoney.mockReturnValue(expectedPayMoneyReturn); mockPayMoney.mockReturnValue(expectedPayMoneyReturn);
@ -1623,11 +1542,11 @@ describe("InsuranceController", () =>
vi.spyOn(insuranceController.profileHelper, "getPmcProfile").mockReturnValue({ vi.spyOn(insuranceController.profileHelper, "getPmcProfile").mockReturnValue({
Inventory: { Inventory: {
items: [ items: [{_id: "itemId1", _tpl: "itemTpl1", otherProperty: "property-value1"}, {
{_id: "itemId1", _tpl: "itemTpl1", otherProperty: "property-value1"}, _id: "itemId2",
{_id: "itemId2", _tpl: "itemTpl2", otherProperty: "property-value2"}, _tpl: "itemTpl2",
{_id: "itemId3", _tpl: "itemTpl3", otherProperty: "property-value3"}, otherProperty: "property-value2",
], }, {_id: "itemId3", _tpl: "itemTpl3", otherProperty: "property-value3"}],
}, },
}); });
}); });
@ -1664,23 +1583,16 @@ describe("InsuranceController", () =>
it("should return the expected cost for each item and trader", () => it("should return the expected cost for each item and trader", () =>
{ {
const request = { const request = {traders: ["prapor", "therapist"], items: ["itemId1", "itemId2", "itemId3"]};
traders: ["prapor", "therapist"],
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.
vi.spyOn(insuranceController.insuranceService, "getPremium") vi.spyOn(insuranceController.insuranceService, "getPremium").mockReturnValueOnce(100).mockReturnValueOnce(
.mockReturnValueOnce(100) 200,
.mockReturnValueOnce(200) ).mockReturnValueOnce(300).mockReturnValueOnce(150).mockReturnValueOnce(250).mockReturnValueOnce(350);
.mockReturnValueOnce(300)
.mockReturnValueOnce(150)
.mockReturnValueOnce(250)
.mockReturnValueOnce(350);
const result = insuranceController.cost(request, sessionId); const result = insuranceController.cost(request, sessionId);
@ -1697,14 +1609,12 @@ describe("InsuranceController", () =>
"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.
vi.spyOn(insuranceController.insuranceService, "getPremium") vi.spyOn(insuranceController.insuranceService, "getPremium").mockReturnValueOnce(100).mockReturnValueOnce(
.mockReturnValueOnce(100) 200,
.mockReturnValueOnce(200); );
const result = insuranceController.cost(request, sessionId); const result = insuranceController.cost(request, sessionId);

View File

@ -59,19 +59,11 @@ describe("BotGenerator", () =>
{ {
botGenerator.botConfig.chanceAssaultScavHasPlayerScavName = 0; botGenerator.botConfig.chanceAssaultScavHasPlayerScavName = 0;
const mockPlayerProfile = { const mockPlayerProfile = {Info: {Nickname: "Player Nickname", Level: 1}};
Info: {
Nickname: "Player Nickname",
Level: 1,
},
};
vi.spyOn(botGenerator.profileHelper, "getPmcProfile").mockReturnValue(<IPmcData>mockPlayerProfile); vi.spyOn(botGenerator.profileHelper, "getPmcProfile").mockReturnValue(<IPmcData>mockPlayerProfile);
const botJsonTemplate = { const botJsonTemplate = {firstName: ["test"], lastName: []};
firstName: ["test"],
lastName: [],
};
const sessionId = "sessionId"; const sessionId = "sessionId";
const isPlayerScav = false; const isPlayerScav = false;
@ -85,18 +77,10 @@ describe("BotGenerator", () =>
{ {
botGenerator.botConfig.showTypeInNickname = true; botGenerator.botConfig.showTypeInNickname = true;
const mockPlayerProfile = { const mockPlayerProfile = {Info: {Nickname: "Player Nickname", Level: 1}};
Info: {
Nickname: "Player Nickname",
Level: 1,
},
};
vi.spyOn(botGenerator.profileHelper, "getPmcProfile").mockReturnValue(<IPmcData>mockPlayerProfile); vi.spyOn(botGenerator.profileHelper, "getPmcProfile").mockReturnValue(<IPmcData>mockPlayerProfile);
const botJsonTemplate = { const botJsonTemplate = {firstName: ["test"], lastName: []};
firstName: ["test"],
lastName: [],
};
const sessionId = "sessionId"; const sessionId = "sessionId";
const isPlayerScav = false; const isPlayerScav = false;
@ -111,19 +95,11 @@ describe("BotGenerator", () =>
botGenerator.botConfig.showTypeInNickname = false; botGenerator.botConfig.showTypeInNickname = false;
botGenerator.pmcConfig.addPrefixToSameNamePMCAsPlayerChance = 100; botGenerator.pmcConfig.addPrefixToSameNamePMCAsPlayerChance = 100;
const mockPlayerProfile = { const mockPlayerProfile = {Info: {Nickname: "Player", Level: 1}};
Info: {
Nickname: "Player",
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"], lastName: []};
firstName: ["Player"],
lastName: [],
};
const sessionId = "sessionId"; const sessionId = "sessionId";
const isPlayerScav = false; const isPlayerScav = false;
@ -137,18 +113,10 @@ describe("BotGenerator", () =>
{ {
botGenerator.botConfig.chanceAssaultScavHasPlayerScavName = 100; botGenerator.botConfig.chanceAssaultScavHasPlayerScavName = 100;
const mockPlayerProfile = { const mockPlayerProfile = {Info: {Nickname: "Player", Level: 1}};
Info: {
Nickname: "Player",
Level: 1,
},
};
vi.spyOn(botGenerator.profileHelper, "getPmcProfile").mockReturnValue(<IPmcData>mockPlayerProfile); vi.spyOn(botGenerator.profileHelper, "getPmcProfile").mockReturnValue(<IPmcData>mockPlayerProfile);
const botJsonTemplate = { const botJsonTemplate = {firstName: ["test"], lastName: []};
firstName: ["test"],
lastName: [],
};
const sessionId = "sessionId"; const sessionId = "sessionId";
const isPlayerScav = true; const isPlayerScav = true;
@ -164,18 +132,10 @@ describe("BotGenerator", () =>
botGenerator.databaseServer.getTables().bots.types.usec.firstName = ["usec"]; botGenerator.databaseServer.getTables().bots.types.usec.firstName = ["usec"];
botGenerator.databaseServer.getTables().bots.types.bear.firstName = []; botGenerator.databaseServer.getTables().bots.types.bear.firstName = [];
const mockPlayerProfile = { const mockPlayerProfile = {Info: {Nickname: "Player", Level: 1}};
Info: {
Nickname: "Player",
Level: 1,
},
};
vi.spyOn(botGenerator.profileHelper, "getPmcProfile").mockReturnValue(<IPmcData>mockPlayerProfile); vi.spyOn(botGenerator.profileHelper, "getPmcProfile").mockReturnValue(<IPmcData>mockPlayerProfile);
const botJsonTemplate = { const botJsonTemplate = {firstName: ["test"], lastName: []};
firstName: ["test"],
lastName: [],
};
const sessionId = "sessionId"; const sessionId = "sessionId";
const isPlayerScav = false; const isPlayerScav = false;

View File

@ -27,10 +27,7 @@ describe("BotLevelGenerator", () =>
{ {
it("should return value between 5 and 10 when player is level 5 and max is 10", () => it("should return value between 5 and 10 when player is level 5 and max is 10", () =>
{ {
const levelDetails: MinMax = { const levelDetails: MinMax = {min: 5, max: 10};
min: 5,
max: 10,
};
const botGenerationDetails: BotGenerationDetails = { const botGenerationDetails: BotGenerationDetails = {
isPmc: false, isPmc: false,
@ -53,10 +50,7 @@ describe("BotLevelGenerator", () =>
{ {
it("should return 10 when player level is 5 and delta is 5", () => it("should return 10 when player level is 5 and delta is 5", () =>
{ {
const levelDetails: MinMax = { const levelDetails: MinMax = {min: 5, max: 10};
min: 5,
max: 10,
};
const expTable = databaseServer.getTables().globals.config.exp.level.exp_table; const expTable = databaseServer.getTables().globals.config.exp.level.exp_table;
@ -67,10 +61,7 @@ describe("BotLevelGenerator", () =>
it("should return 79 when player level is above possible max (100), desired max is 100 and delta is 5", () => it("should return 79 when player level is above possible max (100), desired max is 100 and delta is 5", () =>
{ {
const levelDetails: MinMax = { const levelDetails: MinMax = {min: 100, max: 100};
min: 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;

View File

@ -24,16 +24,7 @@ describe("InRaidHelper", () =>
it("should return negative value when player kills 2 scavs as scav", () => it("should return negative value when player kills 2 scavs as scav", () =>
{ {
const fenceStanding = 0; const fenceStanding = 0;
const postRaidPlayerVictims = [ const postRaidPlayerVictims = [{Side: "Savage", Role: "assault"}, {Side: "Savage", Role: "assault"}]; // Kills
{
Side: "Savage",
Role: "assault",
},
{
Side: "Savage",
Role: "assault",
},
]; // Kills
const databaseServer = container.resolve<DatabaseServer>("DatabaseServer"); const databaseServer = container.resolve<DatabaseServer>("DatabaseServer");
const scavStandingChangeOnKill = databaseServer.getTables().bots.types.assault.experience.standingForKill; const scavStandingChangeOnKill = databaseServer.getTables().bots.types.assault.experience.standingForKill;
@ -46,16 +37,7 @@ describe("InRaidHelper", () =>
it("should return positive value when player kills 2 PMCs of different sides as scav", () => it("should return positive value when player kills 2 PMCs of different sides as scav", () =>
{ {
const fenceStanding = 0; const fenceStanding = 0;
const postRaidPlayerVictims = [ const postRaidPlayerVictims = [{Side: "Usec", Role: "sptUsec"}, {Side: "Bear", Role: "sptBear"}]; // Kills
{
Side: "Usec",
Role: "sptUsec",
},
{
Side: "Bear",
Role: "sptBear",
},
]; // Kills
const databaseServer = container.resolve<DatabaseServer>("DatabaseServer"); const databaseServer = container.resolve<DatabaseServer>("DatabaseServer");
const bearStandingChangeOnKill = databaseServer.getTables().bots.types.bear.experience.standingForKill; const bearStandingChangeOnKill = databaseServer.getTables().bots.types.bear.experience.standingForKill;
@ -69,24 +51,10 @@ describe("InRaidHelper", () =>
it("should return negative value when player kills 1 PMC, 1 boss and 2 scavs as scav", () => it("should return negative value when player kills 1 PMC, 1 boss and 2 scavs as scav", () =>
{ {
const fenceStanding = 0; const fenceStanding = 0;
const postRaidPlayerVictims = [ const postRaidPlayerVictims = [{Side: "Usec", Role: "sptUsec"}, {Side: "savage", Role: "assault"}, {
{ Side: "savage",
Side: "Usec", Role: "bossBoar",
Role: "sptUsec", }, {Side: "savage", Role: "assault"}]; // Kills
},
{
Side: "savage",
Role: "assault",
},
{
Side: "savage",
Role: "bossBoar",
},
{
Side: "savage",
Role: "assault",
},
]; // 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;
@ -104,12 +72,7 @@ describe("InRaidHelper", () =>
it("should return 0 when player kills bot with undefined standing as scav", () => it("should return 0 when player kills bot with undefined standing as scav", () =>
{ {
const fenceStanding = 0; const fenceStanding = 0;
const postRaidPlayerVictims = [ const postRaidPlayerVictims = [{Side: "savage", Role: "testRole"}]; // Kills
{
Side: "savage",
Role: "testRole",
},
]; // Kills
// Fake getFenceStandingChangeForKillAsScav() returning null // Fake getFenceStandingChangeForKillAsScav() returning null
vi.spyOn(inraidHelper, "getFenceStandingChangeForKillAsScav").mockReturnValueOnce(null).mockReturnValueOnce( vi.spyOn(inraidHelper, "getFenceStandingChangeForKillAsScav").mockReturnValueOnce(null).mockReturnValueOnce(

View File

@ -249,10 +249,7 @@ describe("ItemHelper", () =>
{ {
it("should set upd.StackObjectsCount to 1 if upd is undefined", () => it("should set upd.StackObjectsCount to 1 if upd is undefined", () =>
{ {
const initialItem: Item = { const initialItem: Item = {_id: "", _tpl: ""};
_id: "",
_tpl: "",
};
const fixedItem = itemHelper.fixItemStackCount(initialItem); const fixedItem = itemHelper.fixItemStackCount(initialItem);
expect(fixedItem.upd).toBeDefined(); expect(fixedItem.upd).toBeDefined();
@ -261,11 +258,7 @@ describe("ItemHelper", () =>
it("should set upd.StackObjectsCount to 1 if upd.StackObjectsCount is undefined", () => it("should set upd.StackObjectsCount to 1 if upd.StackObjectsCount is undefined", () =>
{ {
const initialItem: Item = { const initialItem: Item = {_id: "", _tpl: "", upd: {}};
_id: "",
_tpl: "",
upd: {},
};
const fixedItem = itemHelper.fixItemStackCount(initialItem); const fixedItem = itemHelper.fixItemStackCount(initialItem);
expect(fixedItem.upd).toBeDefined(); expect(fixedItem.upd).toBeDefined();
@ -274,13 +267,7 @@ describe("ItemHelper", () =>
it("should not change upd.StackObjectsCount if it is already defined", () => it("should not change upd.StackObjectsCount if it is already defined", () =>
{ {
const initialItem: Item = { const initialItem: Item = {_id: "", _tpl: "", upd: {StackObjectsCount: 5}};
_id: "",
_tpl: "",
upd: {
StackObjectsCount: 5,
},
};
const fixedItem = itemHelper.fixItemStackCount(initialItem); const fixedItem = itemHelper.fixItemStackCount(initialItem);
expect(fixedItem.upd).toBeDefined(); expect(fixedItem.upd).toBeDefined();
@ -465,12 +452,7 @@ describe("ItemHelper", () =>
const item: Item = { const item: Item = {
_id: itemId, _id: itemId,
_tpl: "5b40e1525acfc4771e1c6611", // "HighCom Striker ULACH IIIA helmet (Black)" _tpl: "5b40e1525acfc4771e1c6611", // "HighCom Striker ULACH IIIA helmet (Black)"
upd: { upd: {Repairable: {Durability: 19, MaxDurability: 38}},
Repairable: {
Durability: 19,
MaxDurability: 38,
},
},
}; };
const result = itemHelper.getItemQualityModifier(item); const result = itemHelper.getItemQualityModifier(item);
@ -484,12 +466,7 @@ describe("ItemHelper", () =>
const item: Item = { const item: Item = {
_id: itemId, _id: itemId,
_tpl: "5a38e6bac4a2826c6e06d79b", // "TOZ-106 20ga bolt-action shotgun" _tpl: "5a38e6bac4a2826c6e06d79b", // "TOZ-106 20ga bolt-action shotgun"
upd: { upd: {Repairable: {Durability: 20, MaxDurability: 100}},
Repairable: {
Durability: 20,
MaxDurability: 100,
},
},
}; };
const result = itemHelper.getItemQualityModifier(item); const result = itemHelper.getItemQualityModifier(item);
@ -521,11 +498,7 @@ describe("ItemHelper", () =>
const item: Item = { const item: Item = {
_id: itemId, _id: itemId,
_tpl: "5780cf7f2459777de4559322", // "Dorm room 314 marked key" _tpl: "5780cf7f2459777de4559322", // "Dorm room 314 marked key"
upd: { upd: {Key: {NumberOfUsages: 5}},
Key: {
NumberOfUsages: 5,
},
},
}; };
const result = itemHelper.getItemQualityModifier(item); const result = itemHelper.getItemQualityModifier(item);
@ -558,11 +531,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: {RepairKit: {Resource: 600}},
RepairKit: {
Resource: 600,
},
},
}; };
const result = itemHelper.getItemQualityModifier(item); const result = itemHelper.getItemQualityModifier(item);
@ -576,11 +545,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: {RepairKit: {Resource: 0}},
RepairKit: {
Resource: 0,
},
},
}; };
const result = itemHelper.getItemQualityModifier(item); const result = itemHelper.getItemQualityModifier(item);
@ -594,10 +559,7 @@ describe("ItemHelper", () =>
it("should return the correct quality value for armor items", () => it("should return the correct quality value for armor items", () =>
{ {
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, MaxDurability: 50};
Durability: 25,
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: "",
@ -630,14 +592,8 @@ describe("ItemHelper", () =>
it("should return the correct quality value for weapon items", () => it("should return the correct quality value for weapon items", () =>
{ {
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, MaxDurability: 100};
Durability: 50, const item: Item = {_id: "", _tpl: ""};
MaxDurability: 100,
};
const item: Item = {
_id: "",
_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.
const result = (itemHelper as any).getRepairableItemQualityValue(weapon, repairable, item); const result = (itemHelper as any).getRepairableItemQualityValue(weapon, repairable, item);
@ -653,10 +609,7 @@ describe("ItemHelper", () =>
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: "", _tpl: ""};
_id: "",
_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.
const result = (itemHelper as any).getRepairableItemQualityValue(weapon, repairable, item); const result = (itemHelper as any).getRepairableItemQualityValue(weapon, repairable, item);
@ -672,10 +625,7 @@ describe("ItemHelper", () =>
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: "", _tpl: ""};
_id: "",
_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.
const loggerErrorSpy = vi.spyOn((itemHelper as any).logger, "error").mockImplementation(() => const loggerErrorSpy = vi.spyOn((itemHelper as any).logger, "error").mockImplementation(() =>
@ -696,10 +646,7 @@ describe("ItemHelper", () =>
Durability: 50, Durability: 50,
MaxDurability: 0, // This is a problem. MaxDurability: 0, // This is a problem.
}; };
const item: Item = { const item: Item = {_id: "", _tpl: ""};
_id: "",
_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.
const result = (itemHelper as any).getRepairableItemQualityValue(weapon, repairable, item); const result = (itemHelper as any).getRepairableItemQualityValue(weapon, repairable, item);
@ -715,10 +662,7 @@ describe("ItemHelper", () =>
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: "", _tpl: ""};
_id: "",
_tpl: "",
};
const loggerErrorSpy = vi.spyOn((itemHelper as any).logger, "error"); const loggerErrorSpy = vi.spyOn((itemHelper as any).logger, "error");
@ -733,44 +677,40 @@ describe("ItemHelper", () =>
{ {
it("should return an array containing only the parent ID when no children are found", () => it("should return an array containing only the parent ID when no children are found", () =>
{ {
const items: Item[] = [ const items: Item[] = [{_id: "1", _tpl: "", parentId: null}, {_id: "2", _tpl: "", parentId: null}, {
{_id: "1", _tpl: "", parentId: null}, _id: "3",
{_id: "2", _tpl: "", parentId: null}, _tpl: "",
{_id: "3", _tpl: "", parentId: "2"}, parentId: "2",
]; }];
const result = itemHelper.findAndReturnChildrenByItems(items, "1"); const result = itemHelper.findAndReturnChildrenByItems(items, "1");
expect(result).toEqual(["1"]); expect(result).toEqual(["1"]);
}); });
it("should return array of child IDs when single-level children are found", () => it("should return array of child IDs when single-level children are found", () =>
{ {
const items: Item[] = [ const items: Item[] = [{_id: "1", _tpl: "", parentId: null}, {_id: "2", _tpl: "", parentId: "1"}, {
{_id: "1", _tpl: "", parentId: null}, _id: "3",
{_id: "2", _tpl: "", parentId: "1"}, _tpl: "",
{_id: "3", _tpl: "", parentId: "1"}, 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"]);
}); });
it("should return array of child IDs when multi-level children are found", () => it("should return array of child IDs when multi-level children are found", () =>
{ {
const items: Item[] = [ const items: Item[] = [{_id: "1", _tpl: "", parentId: null}, {_id: "2", _tpl: "", parentId: "1"}, {
{_id: "1", _tpl: "", parentId: null}, _id: "3",
{_id: "2", _tpl: "", parentId: "1"}, _tpl: "",
{_id: "3", _tpl: "", parentId: "2"}, 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"]);
}); });
it("should return an array containing only the parent ID when parent ID does not exist in items", () => it("should return an array containing only the parent ID when parent ID does not exist in items", () =>
{ {
const items: Item[] = [ const items: Item[] = [{_id: "1", _tpl: "", parentId: null}, {_id: "2", _tpl: "", parentId: "1"}];
{_id: "1", _tpl: "", parentId: null},
{_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"]);
}); });
@ -807,9 +747,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: {StackObjectsCount: 5},
StackObjectsCount: 5,
},
}; };
const result = itemHelper.getItemStackSize(item); const result = itemHelper.getItemStackSize(item);
expect(result).toBe(5); expect(result).toBe(5);
@ -824,10 +762,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: {BuyRestrictionCurrent: 0, BuyRestrictionMax: 1},
BuyRestrictionCurrent: 0,
BuyRestrictionMax: 1,
},
}; };
const result = itemHelper.hasBuyRestrictions(item); const result = itemHelper.hasBuyRestrictions(item);
expect(result).toBe(true); expect(result).toBe(true);
@ -1089,15 +1024,7 @@ describe("ItemHelper", () =>
const mockTemplateItem = { const mockTemplateItem = {
_id: "571a29dc2459771fb2755a6a", _id: "571a29dc2459771fb2755a6a",
_name: "mag_tt_toz_std_762x25tt_8", _name: "mag_tt_toz_std_762x25tt_8",
_props: { _props: {Cartridges: [{_props: {filters: [{Filter: validAmmoItems}]}}]},
Cartridges: [{
_props: {
filters: [{
Filter: validAmmoItems,
}],
},
}],
},
}; };
vi.spyOn((itemHelper as any).randomUtil, "getArrayValue").mockReturnValue(validAmmoItems[0]); vi.spyOn((itemHelper as any).randomUtil, "getArrayValue").mockReturnValue(validAmmoItems[0]);
@ -1109,13 +1036,7 @@ describe("ItemHelper", () =>
it("should return null when passed template has empty cartridge property", () => it("should return null when passed template has empty cartridge property", () =>
{ {
const fakeTemplateItem = { const fakeTemplateItem = {_props: {Cartridges: [{}]}};
_props: {
Cartridges: [
{},
],
},
};
const result = itemHelper.getRandomCompatibleCaliberTemplateId(fakeTemplateItem as ITemplateItem); const result = itemHelper.getRandomCompatibleCaliberTemplateId(fakeTemplateItem as ITemplateItem);
expect(result).toBe(null); expect(result).toBe(null);

View File

@ -50,16 +50,8 @@ describe("PaymentService", () =>
// Object representing the player's PMC inventory. // Object representing the player's PMC inventory.
const pmcData = { const pmcData = {
TradersInfo: { TradersInfo: {[traderId]: {salesSum: 0, unlocked: true, disabled: false}},
[traderId]: { Inventory: {items: [moneyItem]},
salesSum: 0,
unlocked: true,
disabled: false,
},
},
Inventory: {
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
@ -71,12 +63,7 @@ describe("PaymentService", () =>
item_id: purchaseItemId, item_id: purchaseItemId,
count: purchaseQuantity, count: purchaseQuantity,
scheme_id: 0, scheme_id: 0,
scheme_items: [ scheme_items: [{id: costItemId, count: costAmount}],
{
id: costItemId,
count: costAmount,
},
],
} as IProcessBuyTradeRequestData; } as IProcessBuyTradeRequestData;
// Inconsequential profile ID // Inconsequential profile ID
@ -84,16 +71,7 @@ describe("PaymentService", () =>
const itemEventRouterResponse = { const itemEventRouterResponse = {
warnings: [], warnings: [],
profileChanges: { profileChanges: {sessionID: {_id: sessionID, items: {new: [], change: [], del: []}}},
sessionID: {
_id: sessionID,
items: {
new: [],
change: [],
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.
@ -102,25 +80,13 @@ 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") const traderHelperGetTraderSpy = vi.spyOn((paymentService as any).traderHelper, "getTrader")
.mockReturnValue({ .mockReturnValue({tid: traderId, currency: "RUB"} as unknown as ITraderBase);
tid: traderId,
currency: "RUB",
} 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 {warnings: [], profileChanges: {[sessionID]: {items: {change: [moneyItem]}}}};
warnings: [],
profileChanges: {
[sessionID]: {
items: {
change: [moneyItem],
},
},
},
};
}); });
// Mock the traderHelper lvlUp method to return void. // Mock the traderHelper lvlUp method to return void.

View File

@ -7,9 +7,7 @@ export default defineConfig({
reporters: ["default"], reporters: ["default"],
root: "./", root: "./",
include: ["**/*.{test,spec}.?(c|m)[jt]s?(x)"], include: ["**/*.{test,spec}.?(c|m)[jt]s?(x)"],
cache: { cache: {dir: "./tests/__cache__"},
dir: "./tests/__cache__",
},
environment: "./tests/CustomEnvironment.ts", environment: "./tests/CustomEnvironment.ts",
globals: true, globals: true,
coverage: { coverage: {
@ -22,15 +20,7 @@ export default defineConfig({
exclude: ["src/models/**", "tests/**"], exclude: ["src/models/**", "tests/**"],
}, },
pool: "threads", pool: "threads",
poolOptions: { poolOptions: {threads: {singleThread: true, isolate: false}},
threads: { alias: {"@spt-aki": path.resolve(__dirname, "src"), "@tests": path.resolve(__dirname, "tests")},
singleThread: true,
isolate: false,
},
},
alias: {
"@spt-aki": path.resolve(__dirname, "src"),
"@tests": path.resolve(__dirname, "tests"),
},
}, },
}); });