0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-12 16:50:43 -05:00

99 Commits

Author SHA1 Message Date
653b9723b8
Vitest Updates (#985)
Includes updates to Vitest dependencies, a small bug fix, and a
configuration change. All three of which were throwing warnings when the
test suite was ran.

### Dependency Updates:
*
[`project/package.json`](diffhunk://#diff-18e5b8a4dad7b1ed0da6b50ed507b3ab8116e07a8e44abd959a28261878d021fL69-R70):
Updated `@vitest/coverage-istanbul` and `@vitest/ui` to version `^2.1.8`
and added `vitest` dependency.
[[1]](diffhunk://#diff-18e5b8a4dad7b1ed0da6b50ed507b3ab8116e07a8e44abd959a28261878d021fL69-R70)
[[2]](diffhunk://#diff-18e5b8a4dad7b1ed0da6b50ed507b3ab8116e07a8e44abd959a28261878d021fL84-R85)

### Bug Fix:
*
[`project/src/controllers/RepeatableQuestController.ts`](diffhunk://#diff-92e6bd4234ed3c13309eb9bd27437f0933e58dedee51544e9b017b57c2a3c51cL581-R581):
Fixed a bug in the charisma bonus calculation for the `cost.count`
value.

### Configuration Changes:
*
[`project/tests/CustomEnvironment.ts`](diffhunk://#diff-79780538b7a90a5f7befb22838a460f65e3e0bce53d3685f36ed2b74894246a0L9-R9):
Updated the import path for `Environment` from `vitest`.
*
[`project/vitest.config.mts`](diffhunk://#diff-18152746ad4df10b798ca21a09c321bc8ad4adc393ebc6a26016a524203e599cR5-L10):
Added `cacheDir` configuration and renamed the file from
`vitest.config.ts`.
2024-12-16 22:12:30 +00:00
d3d7a6ed35
Adds RandomUtil.randNum that can generate random integers or floating-point numbers within a range.
Adds a public `randNum` method to the `RandomUtil` class which can be seen as a "superseeded" version of the `randInt` method. It can handle generating random numbers, including both integers or floating-point numbers with support for providing a precision.

Adds a private `getNumberPrecision` method to the `RandomUtil` class which simply counts the number of fractional digits in a number.

Changes `randInt` to log a debug message saying that the ability to pass it a floating-point number is deprecated.
2024-12-09 21:42:16 -05:00
f278ff9294
Updates RandomUtil.randInt to handle floating-point parameters by flooring values. I hate this! 2024-12-09 21:42:11 -05:00
1074306758
Updates RandomUtil.randInt to return the input when the input values are the same.
Adds a test.
2024-12-09 21:42:05 -05:00
Chomp
fdca5d39f6 Various unit test fixes 2024-12-06 17:08:48 +00:00
Chomp
43025ed8e1 Fixed generateUniqueBotNickname test 2024-12-06 16:38:22 +00:00
c071702851
Better Random (#972)
This started as a small update.

This pull request includes updates to the `RandomUtil` class to improve
the security and accuracy of random number generation by utilizing the
`node:crypto` module. Additionally, it enhances the documentation and
refactors several methods for clarity and performance.

Includes tests, both before and after the changes.

The only *possible* breaking change is that now the `getKey`,
`getKeyValue`, and `drawRandomFromDict` methods are typed with generics
instead of `any`. I tried to keep them as *generic* as possible, but we
should probably include this in a BE to ensure it doesn't break
anything.

No further changes are planned--Saved as a draft because it's late and I
still want to review.

---------

Co-authored-by: Chomp <27521899+chompDev@users.noreply.github.com>
2024-12-06 16:25:44 +00:00
Dev
776f925d91 Updated interfaces to follow correct naming scheme 2024-10-19 12:43:38 +01:00
Dev
ab1422bc40 Updated interfaces to follow correct naming convention
Removed some interface duplication
2024-09-24 12:47:29 +01:00
f362f4eddc Remove failing profile fixer tests (!404)
The code this was testing has been deleted so these tests were failing, don't see any point to keep the empty file after deleting the tests that are gone.

Reviewed-on: SPT/Server#404
Co-authored-by: Alex McAuliffe <alex@romanx.co.uk>
Co-committed-by: Alex McAuliffe <alex@romanx.co.uk>
2024-08-31 17:35:46 +00:00
79f0949610 Updated bot tests 2024-08-19 16:55:11 +01:00
Dev
6c4b53f95e Fixed broken tests 2024-08-01 08:45:37 +01:00
Dev
7be6b47e23 Fixed various Biome issues 2024-07-23 17:30:20 +01:00
5740774a46
Apply Biome Formatting
This is the result of running `npm run format` which applies the Biome formatting rules. Rejoice!
2024-07-23 11:12:53 -04:00
ed8dbbd195 Adds Biome - Removes ESLint & Prettier (!383)
Boogidy, boogidy, boogidy. Let's go racing! 🏎️

Removes the over-complicated and super-slow setup we had with ESLint & Prettier in favour of Biome. The largest change with the formatting is moving from Allman braces to 1TBS braces. Other than that, it's *pretty much* the same. Ah, and that Biome runs formatting and linting on the entire project about x10 faster than the old system ran formatting on one file. Seriously, the guy who came up with that last solution should be fired. :runs:

I've kept all of the formatting and linting commands the same as before, with the main mamma-jamma being: `npm run format`, which applies formatting and linting changes to the entire project.

Formatting-on-save works (quickly!) by (1) ensuring that you're working within the VSC workspace (as you should be), and (2) have the recommended Biome VSC extension installed. The link to the Biome extension is in the README.

This limits our options on code formatting going forward; Biome, like prettier, is very opinionated with very few formatting options available. But I see this as a good thing. I'd rather spend my time arguing about which gun in Tarkov is the best, rather than coding brace styles...

...It's the TOZ, and it always will be. Don't DM me.

Co-authored-by: chomp <chomp@noreply.dev.sp-tarkov.com>
Reviewed-on: SPT/Server#383
Co-authored-by: Refringe <me@refringe.com>
Co-committed-by: Refringe <me@refringe.com>
2024-07-22 21:15:57 +00:00
b3b1f76a77 Migrate PMCs (sptBear/sptUsec) To Bsg Types (pmcBEAR/pmcUSEC) (!360)
Co-authored-by: Dev <dev@dev.sp-tarkov.com>
Reviewed-on: SPT/Server#360
2024-06-06 16:59:44 +00:00
Dev
b7a9296fac Expanded getItemName() to return short name when full name is not found 2024-05-31 11:09:19 +01:00
Dev
7d515ad680 Replaced uses of DatabaseServer with DatabaseService 2024-05-28 22:24:52 +01:00
Dev
b9148514ce Fixed unit tests 2024-05-28 19:52:21 +01:00
Dev
d330ab3715 Fixed insurance tests 2024-05-27 16:51:20 +01:00
d13e86ba46 Rebranding to SPT (!345)
Rebranded src code and scripts to SPT

Co-authored-by: clodan <clodan@clodan.com>
Reviewed-on: SPT-AKI/Server#345
Co-authored-by: Alex <clodan@noreply.dev.sp-tarkov.com>
Co-committed-by: Alex <clodan@noreply.dev.sp-tarkov.com>
2024-05-21 17:59:04 +00:00
Dev
2fd5c918ce Updated localeService test after recent PR merge
Linted test file
2024-05-20 09:54:40 +01:00
Dev
98620d2e1f Added tests for botDifficultyHelper 2024-05-14 15:45:56 +01:00
Dev
512054d29f Added additional localeService tests
Fixed issue with existing tests overwriting function result that bled into other tests
2024-05-14 10:26:07 +01:00
adab18e3fb Fix issues around locales (!332)
- Remove locale check for give command (Now handled in the localeService itself)
- Fix variable names/spelling/lowercase in LocaleService.getPlatformForServerLocale (should be no change in behaviour)
- Rewrite LocaleService.getPlatformForClientLocale to not depend on serverSupportedLocales, and instead just use the tables for validity checking
- Expand fallback of client locale handling to include the region code (Handles Czech and Korean locales)
- Write tests for locales

Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: SPT-AKI/Server#332
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
2024-05-13 21:42:58 +00:00
Dev
5254e9753e Fixed two getHighestRelativeBotLevel() tests caused by a refactor of the functions parameters 2024-05-13 22:41:34 +01:00
Dev
5ec6bc1aae FIxed getItems() test due to changes in how items are cloned 2024-05-13 22:31:53 +01:00
Dev
fa76578880 Updated insurance tests
Added logging of items attachments that are being removed
Only add items with a price to weight dictionary
2024-05-06 19:33:44 +01:00
316234e9ae Fix TradersInfo nextResupply if it is null in profile data (!305)
Add test covering fixNullTraderNextResupply

Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: SPT-AKI/Server#305
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
2024-04-24 07:13:31 +00:00
a572e8e67e
Runs Style Fix 2024-04-22 15:53:07 -04:00
c71aaa7fb3 Use dynamic ragfair pricing for insurance deletion sorting (!294)
Change sort value for insured attachments to use dynamic ragfair prices.
Small change to method to return directly instead of setting passed-by-value parameter.

SPT-AKI/Issues#618

Reviewed-on: SPT-AKI/Server#294
Co-authored-by: Brent <wiggyvidyadev@gmail.com>
Co-committed-by: Brent <wiggyvidyadev@gmail.com>
2024-04-17 13:10:43 +00:00
0e63ced3ac
Test - Insurance - Updates for v3.8
- Updates the tests for insuranceController methods for v3.8
- Updates the profileInsurance fixture with updated insurance packages for v3.8
- Updated the profileInsurance factory to remove outdated references as of v3.8
2024-04-11 21:18:38 -04:00
4a0d3c3487
Test - BotGenerator - Refactored
- Made the sessionId parameter for generateBotNickname optional and marked it as deprecated, to be removed in v3.9. It wasn't being used.
- Refactored the tests for the generateBotNickname method in the BotGenerator class. Mostly to bring it inline with v3.8 changes to the structure of botGenerationDetails.
2024-04-11 21:18:37 -04:00
b59ffd8ff2
Test - InRaidHelper
- Removes tests for missing calculateFenceStandingChangeFromKills method
- Adds a test for the resetSkillPointsEarnedDuringRaid method
2024-04-11 21:18:36 -04:00
5aebbb9c86
Test - ItemHelper - 3.8 Refactor
- Removes unused code from getRepairableItemQualityValue in itemHelper
- Updated tests for getRepairableItemQualityValue to no longer assume a special calculation for armour
- Added tests for adoptOrphanedItems (moved from insuranceController)
2024-04-11 21:18:36 -04:00
7d3eaf735a
Test - PaymentService - Refactored payMoney test
Refactored the payMoney test to work with 3.8. The output is no longer returned, but updated by reference.
2024-04-11 21:18:35 -04:00
1cd4b055eb
Test - Updates ItemBaseClassService tests to inline with recent code changes 2024-04-10 23:16:04 -04:00
c123c034cf
Test - Updates ItemHelper Tests
- Removes tests for a method that no longer exists: `generateItemsFromStackSlot`
- Updates a test to use a mock to ensure test data reliability
2024-04-10 23:13:46 -04:00
0ec0b7a40c
Test - Updates fromRUB tests to use mocks 2024-04-10 23:10:17 -04:00
68c2358b08
Test - Adds missing property to mock of BotGenerationDetails 2024-04-10 23:07:41 -04:00
85aec72a63
Test - Updates the experince needed to reach level 79 2024-04-10 23:06:40 -04:00
3d77ed8595
Seperates ragfair pricing into seperate method
This changes the `RagfairPriceService.getDynamicOfferPriceForOffer()` method to handle the logic surrounding collecting prices for items in offers, while offloading the individual price generation to a new method. The new method, `RagfairPriceService.getDynamicItemPrice()`, is responsible for generating a price for either an item template, or optionally an offerItems collection. This change also allows `getDynamicItemPrice()` to be used elsewhere in the code-base to gather more "realistic" pricing for specific item templates.

Fixes an edge-case where unreasonable prices would only be adjusted on the first item within an offer.

Includes some tests.

Related to #618. This will allow the insurance system to use this method to get better pricing for items.
2024-04-10 12:23:28 -04:00
34121182a1
Biome Linting Issues
Fixed some instances of:
- Unordered imports
- Reassigning function parameters
- Modifying values in assignment/return statements
- Array.forEach being used instead of for...of
- Simplified control logic
2024-02-05 19:03:26 -05:00
90492f3aa2
Formatting
Have you been using the recommended VSCode extensions? ;)
2024-02-02 15:00:21 -05:00
4f8670c657 Reworked LinkedList and Queue
- Reworked LinkedList and Queue
- Written tests for LinkedList and Queue
2023-12-21 22:27:19 +00:00
Dev
60ead44b30 Add HealthController.healthTreatment() tests 2023-11-18 15:01:51 +00:00
5d2af422cb
Fixes InsuranceController Tests 2023-11-16 23:55:32 -05:00
0793df60c2
Formatting Change - Space is now given around object properties. 2023-11-13 12:38:16 -05:00
32b47bdc18
Formatting Change - When a statement can be moved into a single line and still be under the maximum line length, it is. 2023-11-13 12:31:52 -05:00
11b5c76512
Favours single line variable declarations. 2023-11-13 11:51:52 -05:00