This pull request introduces several enhancements and fixes to the
`RandomUtil` class in the `project/src/utils/RandomUtil.ts` file, as
well as corresponding updates to the test suite in
`project/tests/utils/RandomUtil.test.ts`. The primary changes include
the addition of new methods for determining number precision and
generating random numbers with specified precision, as well as
improvements to existing methods to handle edge cases and log warnings
appropriately.
Enhancements to `RandomUtil` class:
* Added `MAX_SIGNIFICANT_DIGITS` constant to define the safe upper bound
for significant digits in floating-point numbers.
* Introduced `getNumberPrecision` method to determine the number of
decimal places in a number, addressing floating-point precision issues.
* Enhanced `randInt` method to handle float inputs by logging a warning
and rounding to the nearest integer.
* Added `randNum` method to generate random numbers between two values
with optional precision, including validation for precision and handling
of edge cases.
Updates to test suite:
* Added tests for the new `getNumberPrecision` method to verify correct
handling of various numeric inputs.
* Expanded tests for `randInt` to cover scenarios with equal low and
high values, float inputs, and logging of debug messages.
* Added comprehensive tests for the new `randNum` method to ensure
correct functionality across different ranges, precision levels, and
edge cases.
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.
Better handle rewards not fitting (they shouldn't just poof) by instead
trimming the rewards amount until they fit.
(cherry picked from commit 8d05bf0069b22968d7e4fcdc4901ae0babd948c3)
Reworked Cultist circle code to pass blacklist around as a set rather than array
Removed cultist circle use of `itemRewardBlacklist` to store item parent ids, feature is handled by new config property
Removed hard-coded money/ammo blacklist from `generateRandomisedItemsAndAddToRewardPool()` and moved into config
Updated function to check chosen reward items parentid against item reward blacklist
Brings Cultist Cicle rewards closer to live behavior.
---------
Co-authored-by: Bob S <shibdib@users.noreply.github.com>
Co-authored-by: Chomp <dev@dev.sp-tarkov.com>
- Resolve issue where we were storing favorites in the incorrect format,
resulting in a client error on game load
- Resolve issue where we were clearing favorites when they were meant to
be saved
- On login, fix any previously corrupted favorites array
- Properly implement favorite data in `getOtherProfile`, now shows your
favorites when viewing your profile
Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Co-authored-by: Chomp <27521899+chompDev@users.noreply.github.com>
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>
We've created our own Git Large File Storage (LFS) server due to the
excessive cost of GitHub's bandwidth. Did you know all of their Ethernet
cables are actually gold coated diamonds?
This PR reverses the work done in #954 to compress large location JSON
files into a 7zip archive and handle the (de)compression of the archive.
Only JSON files within the `project/assets/database/` directory that are
larger than 5MB have been included in LFS. This translates to all of the
`looseLoot.json` files. The rest are small enough to be included in the
base repo.
A `.lfsconfig` file has been added to the root of the project to alert
git to the presence of the custom LFS server. This public server is
read-only. Write access is only available to developers within the
Single Player Tarkov GitHub organization.
<img
src="https://github.com/user-attachments/assets/7ddfec9b-5a9a-42e6-806d-fd419e4eaa4f"
width="250">