- Adds tests for the remaining methods in the `InsuranceController`.
- Adds a `countAllInsuranceItems()` method to the `InsuranceController`.
- Adds the Vitest UI and coverage packages.
- Updates the `profileInsuranceFactory` to use second-epoch dates instead of millisecond-epoch dates.
- Updates the `InsuranceController.fetchHideoutItemParent()` method to log a warning when an item with a slotId of 'hideout' cannot be found.
TODO:
- The Vitest coverage options are not working.
Event bots are generated from their base type, then their role is updated before being sent to the client e.g. peacefullZryachiyEvent becomes bossZryachiy for generation, then back to peacefullZryachiyEvent
- Implement formula based on 30 weapon repairs done on live
- Return the repair amount as `repairAmount` from `repairItemByKit`
- Add an additional `repairPoints` to `RepairDetails` to return the repair points used
- Update `repairAmount` references to `repairPoints` to keep old behavior
- Add new parameter to rewardSkillPoints that applies live-like level scaling
- Only give weapon maintenance XP when using a repair kit
This implementation comes with a "Crit Fail" and "Crit Success" mechanic to account for live sometimes randomly being -4 or +4 off from my estimated values. By default the chance of each is 10%, and they can overlap and cancel each other out
Spreadsheet of live repair data:
https://docs.google.com/spreadsheets/d/1-tR4WYelhZfKZ3ZDbxr3nd73Y60E1wQRjDWONpMVSew/edit?usp=sharing
Useful columns:
C: The amount of dura attempted to be repaired, this is used in the estimated skill calculated
G: Hand entered value of how much skill gain I actually saw on live (Multiplied by 10 for readability. So "3.2" would be "32")
J: The estimated skill gain, based on the calculation included in this merge request
K: How far off the estimated skill gain was (Negative implies we guessed high and the actual result was lower)
One thing of note:
I've modified all the existing references to `repairAmount` to be the new `repairPoints` when a repair kit is used. This is to keep the existing behaviour outside of my direct changes as much as possible.
However, this seems to be incorrect in some cases (For example, buff chance is repairPoints/maxDura, but repairPoints will go down the higher your int. I'm assuming this is meant to be repairedDura/maxDura). May want to update these references to use `repairAmount` once they've been confirmed to expect the repair amount instead of repair points used.
Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/164
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
- Created profileInsurance test fixture.
- Created ProfileInsurance test factory class.
- Improved many of the InsuranceController method tests by utilizing the factory and fixture. Still some left to do here.
- Adds the `date-fns` package as a development dependancy for easy date manipulation.
- Cleaned up some comments.
Bug Fixes 🐞
- Resolved an issue where `ItemHelper.getAttachmentMainParent()` was not returning null when it should have.
- Resolved an issue where `InsuranceController.populateParentAttachmentsMap()` would continue to process when the parent could not be found.
- Adds tests for the majority of the methods within InsuranceController.
- Simplifies the `InsuranceController.sendMail()` method so that the toDelete parameter is no longer required.
- Modifies `InsuranceController.findItemsToDelete()` to only process regular and attachment items when they exist.
- Modifies `InsuranceController.rollForDelete()` to return null in the event that the provided Trader can not be found.
Removed `parcel` and `babel` config files and dependencies, as the project isn't using these tools anymore.
Swapped `rome` for `biome`, `rome` is archived and won't be receiving updates anymore, `biome` is a community fork.
Co-authored-by: Pedro Silva <sparta14gaming@gmail.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/163
Co-authored-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
Co-committed-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
Adds a single test for the basic functionality of the `PaymentService.payMoney` method. It's huge. I hate it. It works. The entire class needs to be refactored to be more testable. Each of these methods should be split up to only have (ideally) a single responsibility--It has about 6 going on right now.
It was just too damn slow... 25+ seconds for *two*. Profile information will have to be partial-mocked using the sections and properties that the tested method will use, and casted as the parameter type (`IPmcData`, for example).
Remove unneeded HttpBufferHandler
-----------
The old code processed each chunk of data as an entire request, which is not correct. It was observed split data after ~14600 bytes (on a 1 gig lan connection). I think it was worse on remote connections.
This was the cause of the "unknown compression method" and invalid json parse errors when saving the profile.
Co-authored-by: Decoy <redacted@example.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/162
Reviewed-by: Terkoiz <terkoiz@noreply.dev.sp-tarkov.com>
Co-authored-by: ree <ree@noreply.dev.sp-tarkov.com>
Co-committed-by: ree <ree@noreply.dev.sp-tarkov.com>
- Made it so Watermark doesn't initialize on the constructor, this makes it possible for tests to use `@spt-aki/di/Container`;
- Removed unnecessary calls to `ErrorHandler.handleCriticalError`, all you really need to do is `throw new Error()` and it'll get caught automatically.
Basically the same, except it plays nicer with Typescript and ESM.
I have it mostly working, except for a type error:
`TypeError: Int32Array is not a constructor`
But I'm too damn tired it debug it at the moment.
- Adds additional ItemHelper tests
- Attempts to bring container registration into the environment to debug how we can register everything but not actually start the server.
Only adds lower when weapon has no launcher attached
Adjust sub stock adding code to trigger when stock has a subslot that starts with `mod_stock`, this means `mod_stock_akms` and `mod_stock_000` will be included
Add a new /singleplayer/log route for logging data to the server console from the client
Supports:
- All server log levels
- `Custom` log level with text/background color
- Specifying the source of the log line (ex. Plugin name)
Example output:
![Example](https://i.imgur.com/c0XBYLm.png)
Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/160
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
This commit includes a series of changes aimed at improving the logic and readability of the `payMoney` method in the PaymentService class. The method is pivotal for handling in-game payments, specifically in cases involving multiple types of currencies and barter trades. The changes resolve an issue that prevented barter payments that included both a currency and another item.
## Changes:
- Replaced `barterPrice` variable with a `currencyAmounts` mapping that efficiently tracks each type of currency involved in the trade.
- Updated how the `costOfPurchaseInCurrency` variable is calculated to factor in multiple currencies.
- Introduced a new variable `totalCurrencyAmount` to sum up the total amount of all currencies, which is checked to determine whether any (non)currency payment is necessary.
- Added some inline comments for readability.
Resolves#176
Co-authored-by: Refringe <brownelltyler@gmail.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/159
Co-authored-by: Refringe <refringe@noreply.dev.sp-tarkov.com>
Co-committed-by: Refringe <refringe@noreply.dev.sp-tarkov.com>
- Ability to use @spt-aki path alias on the whole project.
- Swapped all imports from relative paths, for imports using the path alias.
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/157
Co-authored-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
Co-committed-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
This PR adds the ability to set `loadBefore` and `loadAfter` on a mod's package.json, this allows for modders to define an array of mods their current mod needs to load before or after.
Examples:
if we have <u>__MOD1__</u> that has `loadAfter` = `[ "MOD2" ]` the loading order would be:
1 - MOD2
2 - MOD1
if we have <u>__MOD2__</u> that has `loadBefore` = `[ "MOD1" ]` the loading order would also be:
1 - MOD2
2 - MOD1
Begone zzzzzz, name your mods the way you want to.
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/156
Co-authored-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
Co-committed-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
This PR makes it so typescript generates inline sourcemaps when transpiling mods to javascript.
This will make it so stacktraces originating in the mod source code point to the typescript files, lines and columns.
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/155
Co-authored-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
Co-committed-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>