Compare commits

...

70 Commits

Author SHA1 Message Date
f796f9a851 feat: resetQuestProgress (#2461)
Just giving the client an 'ok' response. It seems that it does use updateQuest to manage the state itself mostly, just the server and webui are a bit confused about a quest with all stages completed still being active.
Re #1323

Reviewed-on: OpenWF/SpaceNinjaServer#2461
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-10 20:59:39 -07:00
e18b8e09ea fix: properly track xp for modular items (#2460)
Closes #2454

Reviewed-on: OpenWF/SpaceNinjaServer#2460
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-10 20:59:32 -07:00
0d8044b87c chore(webui): update to Spanish translation (#2466)
Reviewed-on: OpenWF/SpaceNinjaServer#2466
Co-authored-by: hxedcl <hxedcl@noreply.localhost>
Co-committed-by: hxedcl <hxedcl@noreply.localhost>
2025-07-10 20:59:22 -07:00
a109ea6c5d chore: update PE+ (#2459)
Closes #2455

Reviewed-on: OpenWF/SpaceNinjaServer#2459
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-09 21:22:23 -07:00
7eb95c995c feat: initial invasions (#2458)
A rough generation of 3 invasions that change at daily reset, so missing the planet-based invasion 'chains'.
Battle pay is fully working tho, just a few points of uncertainty there due to missing research and logs.
Death marks are also roughly working.
Re #1097

Reviewed-on: OpenWF/SpaceNinjaServer#2458
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-09 19:58:01 -07:00
dc8f32d4d8 chore(webui): update Chinese translation (#2453)
Reviewed-on: OpenWF/SpaceNinjaServer#2453
Co-authored-by: Corvus <corvus@noreply.localhost>
Co-committed-by: Corvus <corvus@noreply.localhost>
2025-07-08 22:12:26 -07:00
ba70ba88dd fix(webui): recreate missing datalist-QuestKeys entries after refreshing inventory (#2452)
Closes #2448

Reviewed-on: OpenWF/SpaceNinjaServer#2452
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-08 20:52:45 -07:00
08d4a03c50 fix: use the correct magic number for crew member seeds (#2451)
Closes #2444

Reviewed-on: OpenWF/SpaceNinjaServer#2451
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-08 20:52:24 -07:00
45feff682b feat: give on call crew gear item for command rank 9 (#2450)
Closes #2445

Reviewed-on: OpenWF/SpaceNinjaServer#2450
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-08 20:52:14 -07:00
65be1083ce feat(webui): mark inbox as read (#2449)
Closes #1117

Reviewed-on: OpenWF/SpaceNinjaServer#2449
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-08 20:52:01 -07:00
07e7c9e897 fix: add eudico's post-new war yapping to allDialogue (#2447)
Reviewed-on: OpenWF/SpaceNinjaServer#2447
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-08 20:51:46 -07:00
dcb26471c9 feat: handle all slot types in inventorySlots.php (#2443)
Reviewed-on: OpenWF/SpaceNinjaServer#2443
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-08 20:51:35 -07:00
5a75d88385 feat: give skiajati and umbra mods alongside umbra, with max rank and potatoes (#2442)
Not 100% sure if the response format is correct and if this is even the correct time/place to do it, but impossible to say without a log from live.

Closes #1054

Reviewed-on: OpenWF/SpaceNinjaServer#2442
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-08 20:51:18 -07:00
a35572e306 fix(webui): move "add maxed" after "add" button (#2441)
Apparently the onclick event is being fired even when pressing enter. I originally moved it to make alt+enter add it maxed, but now even just pressing enter adds it maxed which is not what I wanted. :|

Reviewed-on: OpenWF/SpaceNinjaServer#2441
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-08 20:50:51 -07:00
c46c43f143 chore(webui): add loading string to translation system (#2440)
Closes #2439

Reviewed-on: OpenWF/SpaceNinjaServer#2440
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-08 20:50:28 -07:00
98ed2b5ee4 chore: use ideal time when going backwards to satisfy constraints (#2438)
"Before next expected world state refresh" is now used as a bare minimum constraint. If it cannot be met, we align to the ideal second. Compromising when multiple constraints are in use to avoid having to go back like 7 years, as this would break navigation.

Closes #2434

Reviewed-on: OpenWF/SpaceNinjaServer#2438
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-08 20:50:10 -07:00
7aa1b12306 fix: show multiplied relic reward amount on eom screen (#2437)
Reviewed-on: OpenWF/SpaceNinjaServer#2437
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-08 20:49:46 -07:00
b410f6b554 chore(webui): indicate unsaved changes (#2436)
Reviewed-on: OpenWF/SpaceNinjaServer#2436
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-08 20:49:22 -07:00
1dffcf979f feat: send tennokai email after WitW quest completion (#2433)
Reviewed-on: OpenWF/SpaceNinjaServer#2433
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-08 00:29:16 -07:00
c86bba017b chore(webui): update Chinese translation (#2432)
Reviewed-on: OpenWF/SpaceNinjaServer#2432
Co-authored-by: Corvus <corvus@noreply.localhost>
Co-committed-by: Corvus <corvus@noreply.localhost>
2025-07-08 00:29:05 -07:00
2c499cec3d fix: set proper dominant traits for helminth charger (#2429)
Closes #2417

Reviewed-on: OpenWF/SpaceNinjaServer#2429
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-08 00:28:56 -07:00
d6145561fd chore: improve randomness of void storm missions (#2428)
Instead of alternating the mission pool every hour, we now use sequentiallyUniqueRandomElement which should ensure that we don't duplicate any of the last x missions (x = 3 for Lith & Axi and x = 1 Meso & Neo).

Reviewed-on: OpenWF/SpaceNinjaServer#2428
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-08 00:28:49 -07:00
1545cdb8ce fix(webui): handle config having no worldState entry at all (#2427)
Reviewed-on: OpenWF/SpaceNinjaServer#2427
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-06 20:14:05 -07:00
80b5e2df7f feat: random recessive traits for beasts (#2426)
Reviewed-on: OpenWF/SpaceNinjaServer#2426
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-06 20:13:59 -07:00
76e61129bf fix: skip birthdays of characters we can't talk to (#2425)
Closes #2424

Reviewed-on: OpenWF/SpaceNinjaServer#2425
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-06 20:13:50 -07:00
ea3e299861 fix: ensure nightwave weekly challenges are unique (#2423)
Re #2411

Reviewed-on: OpenWF/SpaceNinjaServer#2423
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-06 20:13:42 -07:00
3d8c1d036a fix: ensure nightwave daily challenges are unique (#2422)
When generating a daily challenge, we now use sequentiallyUniqueRandomElement with a lookbehind of 2 to ensure the 2 previous (and still active) daily challenges are not duplicated.

Re #2411

Reviewed-on: OpenWF/SpaceNinjaServer#2422
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-06 20:13:32 -07:00
773f96ebbc fix: set PrimeTokenAvailability to true (#2420)
Closes #2416

Reviewed-on: OpenWF/SpaceNinjaServer#2420
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-06 20:13:20 -07:00
2a80307c26 chore(webui): reuse "code_remove" for "general_removeButton" (#2421)
Closes #2418

Reviewed-on: OpenWF/SpaceNinjaServer#2421
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-05 20:18:18 -07:00
a40ff27fea fix: add InitialStartDate to PrimeVaultTrader (#2419)
Closes #2414

Reviewed-on: OpenWF/SpaceNinjaServer#2419
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-05 20:18:01 -07:00
c9a4359714 chore(webui): update Chinese translation (#2413)
Reviewed-on: OpenWF/SpaceNinjaServer#2413
Co-authored-by: Corvus <corvus@noreply.localhost>
Co-committed-by: Corvus <corvus@noreply.localhost>
2025-07-05 16:52:16 -07:00
280ed8bef1 chore(webui): improve string (#2412)
The `100% chance` part is unnecessary in practice and can be shortened. In-game it also never mentions the `100% chance` part either.

Reviewed-on: OpenWF/SpaceNinjaServer#2412
Co-authored-by: Animan8000 <animan8000@noreply.localhost>
Co-committed-by: Animan8000 <animan8000@noreply.localhost>
2025-07-05 06:41:26 -07:00
9c89e907b1 chore(webui): update Chinese translation (#2410)
Reviewed-on: OpenWF/SpaceNinjaServer#2410
Co-authored-by: Corvus <corvus@noreply.localhost>
Co-committed-by: Corvus <corvus@noreply.localhost>
2025-07-05 06:23:17 -07:00
b54fd96098 chore: fix cyclic includes due to saveConfig used in controllers (#2409)
Reviewed-on: OpenWF/SpaceNinjaServer#2409
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-05 06:23:10 -07:00
c7c7fd4ea0 chore: enforce consistent imports (#2408)
Reviewed-on: OpenWF/SpaceNinjaServer#2408
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-04 17:40:06 -07:00
a75e6d6b95 chore: add warning coverage for cyclic includes (#2407)
and some initial refactoring to avoid it where possible

Reviewed-on: OpenWF/SpaceNinjaServer#2407
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-04 16:49:25 -07:00
5089f67146 chore: improve ship customization stuff (#2402)
The only functionally relevant change is that orbiter scenes are now saved via SkinFlavourItem (as of U39?).
The rest is cleanup of the types because the ship customization stuff was duplicated all over the place.

Reviewed-on: OpenWF/SpaceNinjaServer#2402
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-04 15:19:15 -07:00
0416221d15 feat: reset custom obstable course leaderboard (#2401)
Reviewed-on: OpenWF/SpaceNinjaServer#2401
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-04 15:19:03 -07:00
26729ce21a feat: railjack skins (#2400)
Technically worked before but some weird behaviour. Also updating saveLoadout again. I think warn is a more appropriate severity. It's certainly not a progession stopper if some category is unimplemented.

Closes #2397

Reviewed-on: OpenWF/SpaceNinjaServer#2400
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-04 15:18:53 -07:00
ee4adc7d55 feat: Varzia (Prime Resurgence) rotation (#2390)
Also closes #1059

Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Reviewed-on: OpenWF/SpaceNinjaServer#2390
Co-authored-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com>
Co-committed-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com>
2025-07-04 15:18:41 -07:00
29aadf4e78 chore(webui): improve string (#2406)
other `after Hacking` or `while Hacking` strings are in uppercase, but this particular one wasn't

Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Reviewed-on: OpenWF/SpaceNinjaServer#2406
Co-authored-by: Animan8000 <animan8000@noreply.localhost>
Co-committed-by: Animan8000 <animan8000@noreply.localhost>
2025-07-04 15:02:30 -07:00
0b32bc21be chore(webui): improve string (#2405)
was missing a plus and this shorter version may fit better

Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Reviewed-on: OpenWF/SpaceNinjaServer#2405
Co-authored-by: Animan8000 <animan8000@noreply.localhost>
Co-committed-by: Animan8000 <animan8000@noreply.localhost>
2025-07-04 04:55:36 -07:00
e09e5ebec2 fix: infinite loop when attempting to generate loid commisions (#2399)
Reviewed-on: OpenWF/SpaceNinjaServer#2399
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-04 03:26:41 -07:00
b2de8608c6 chore: fix duplicate import 2025-07-04 11:46:49 +02:00
2b23db1433 chore: remove usage of markModified (#2403)
Only this one remained, but not needed because it's schema'd.

Reviewed-on: OpenWF/SpaceNinjaServer#2403
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-03 22:45:07 -07:00
a45bacc388 chore: update PE+ (#2398)
Closes #2392

Reviewed-on: OpenWF/SpaceNinjaServer#2398
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-03 22:44:26 -07:00
46d37d3688 chore(webui): update Chinese translation (#2396)
Reviewed-on: OpenWF/SpaceNinjaServer#2396
Co-authored-by: Corvus <corvus@noreply.localhost>
Co-committed-by: Corvus <corvus@noreply.localhost>
2025-07-03 11:09:07 -07:00
41686aea88 fix: properly cap negative syndicate standing (#2393)
Closes #2388

Reviewed-on: OpenWF/SpaceNinjaServer#2393
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-03 11:08:57 -07:00
61ac2f8b72 chore(webui): update Chinese translation (#2394)
Reviewed-on: OpenWF/SpaceNinjaServer#2394
Co-authored-by: Corvus <corvus@noreply.localhost>
Co-committed-by: Corvus <corvus@noreply.localhost>
2025-07-02 15:04:42 -07:00
d2ab894c01 fix(webui): assign labels for appropriate inputs (#2391)
Reviewed-on: OpenWF/SpaceNinjaServer#2391
Co-authored-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com>
Co-committed-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com>
2025-07-02 14:29:41 -07:00
8c85cdcd1d feat(webui): "add maxed" for mods (#2387)
Closes #2382

Reviewed-on: OpenWF/SpaceNinjaServer#2387
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-02 14:18:24 -07:00
aa6191f033 feat: relic rng cheats (#2386)
Closes #2370

Reviewed-on: OpenWF/SpaceNinjaServer#2386
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-02 14:17:14 -07:00
e26d2635fb chore(webui): fix inconsistent % chance strings (#2385)
Closes #2381

Reviewed-on: OpenWF/SpaceNinjaServer#2385
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-02 14:15:50 -07:00
dd6ae8898f chore(webui): move max rank button before detailed view link (#2384)
Reviewed-on: OpenWF/SpaceNinjaServer#2384
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-02 14:14:19 -07:00
499ca23ffb chore(webui): update inventory when equipment was forma'd (#2383)
Reviewed-on: OpenWF/SpaceNinjaServer#2383
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-02 14:14:13 -07:00
d3102acb7c chore(webui): update Chinese translation (#2380)
Reviewed-on: OpenWF/SpaceNinjaServer#2380
Co-authored-by: Corvus <corvus@noreply.localhost>
Co-committed-by: Corvus <corvus@noreply.localhost>
2025-07-01 10:58:47 -07:00
363028c9ce chore: clarify log output related to saveLoadout (#2379)
Reviewed-on: OpenWF/SpaceNinjaServer#2379
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-01 07:48:03 -07:00
1d60745f18 feat: year rollover kiss emails (#2376)
Closes #2375

Reviewed-on: OpenWF/SpaceNinjaServer#2376
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-01 07:45:41 -07:00
a9b3b16d31 feat: dojo visitors (#2374)
Closes #2373

Reviewed-on: OpenWF/SpaceNinjaServer#2374
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-01 07:45:12 -07:00
fd1d72a1cf chore(webui): add inventory update note to quests tab (#2372)
Reviewed-on: OpenWF/SpaceNinjaServer#2372
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-01 07:44:30 -07:00
75832afdbe feat: relicRewardItemCountMultiplier cheat (#2369)
Reviewed-on: OpenWF/SpaceNinjaServer#2369
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-01 07:44:13 -07:00
aa916d2820 feat: sell genetic imprints (#2368)
Reviewed-on: OpenWF/SpaceNinjaServer#2368
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-07-01 07:44:05 -07:00
5a5f6106a3 chore: save inventory and account in parallel when claiming login reward (#2371)
Reviewed-on: OpenWF/SpaceNinjaServer#2371
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-06-30 17:55:06 -07:00
24d9dc27e2 chore(webui): update inventory when login reward was claimed (#2367)
Closes #2360

Reviewed-on: OpenWF/SpaceNinjaServer#2367
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-06-30 13:30:09 -07:00
5e05a15743 fix: update calendar progress at daily reset (#2365)
Closes #2364

Reviewed-on: OpenWF/SpaceNinjaServer#2365
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-06-30 13:28:27 -07:00
545b949202 feat: sell crew members (#2366)
Closes #2363

Reviewed-on: OpenWF/SpaceNinjaServer#2366
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-06-30 12:58:24 -07:00
0c9b27a29b chore: optimise creditsController (#2359)
Doing both lookups in parallel saves around 1 ms in the happy case (20% of baseline time), and in case nonce does not match, the error is simply raised as per usual with the inventory request being lightweight enough to be negligible.

Noteworthy that this reasoning doesn't really work for other controllers because in the error case, the inventory request would still be quite significant, even if the HTTP request itself would still finish quickly.

Reviewed-on: OpenWF/SpaceNinjaServer#2359
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-06-30 11:05:49 -07:00
cfa750b6f7 fix: handle crafting of archwing summon for versions prior to U39 (#2358)
Closes #2356

Reviewed-on: OpenWF/SpaceNinjaServer#2358
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-06-30 11:05:16 -07:00
049baa4313 fix(webui): make sidebar sticky as intended (#2354)
also a bit of language-specific width adjustment

Reviewed-on: OpenWF/SpaceNinjaServer#2354
Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com>
Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
2025-06-30 11:04:58 -07:00
e267ca8f55 chore(webui): update to Spanish translation (#2355)
Reviewed-on: OpenWF/SpaceNinjaServer#2355
Co-authored-by: hxedcl <hxedcl@noreply.localhost>
Co-committed-by: hxedcl <hxedcl@noreply.localhost>
2025-06-29 19:42:24 -07:00
132 changed files with 6566 additions and 1662 deletions

View File

@ -1,10 +1,12 @@
{
"plugins": ["@typescript-eslint", "prettier", "import"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking"
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:import/recommended",
"plugin:import/typescript"
],
"plugins": ["@typescript-eslint", "prettier"],
"env": {
"browser": true,
"es6": true,
@ -26,11 +28,19 @@
"no-case-declarations": "error",
"prettier/prettier": "error",
"no-mixed-spaces-and-tabs": "error",
"require-await": "off",
"@typescript-eslint/require-await": "error"
"@typescript-eslint/require-await": "error",
"import/no-named-as-default-member": "off",
"import/no-cycle": "warn"
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"settings": {
"import/extensions": [ ".ts" ],
"import/resolver": {
"typescript": true,
"node": true
}
}
}

View File

@ -19,6 +19,7 @@ jobs:
- run: npm run lint:ci
- run: npm run prettier
- run: npm run update-translations
- run: npm run fix-imports
- name: Fail if there are uncommitted changes
run: |
if [[ -n "$(git status --porcelain)" ]]; then

View File

@ -60,6 +60,7 @@
"unlockAllSimarisResearchEntries": false,
"disableDailyTribute": false,
"spoofMasteryRank": -1,
"relicRewardItemCountMultiplier": 1,
"nightwaveStandingMultiplier": 1,
"unfaithfulBugFixes": {
"ignore1999LastRegionPlayed": false,
@ -77,7 +78,9 @@
"nightwaveOverride": "",
"allTheFissures": "",
"circuitGameModes": null,
"darvoStockMultiplier": 1
"darvoStockMultiplier": 1,
"varziaOverride": "",
"varziaFullyStocked": false
},
"dev": {
"keepVendorsExpired": false

2196
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -19,7 +19,9 @@
"lint:ci": "eslint --ext .ts --rule \"prettier/prettier: off\" .",
"lint:fix": "eslint --fix --ext .ts .",
"prettier": "prettier --write .",
"update-translations": "cd scripts && node update-translations.js"
"update-translations": "cd scripts && node update-translations.js",
"fix-imports": "cd scripts && node fix-imports.js",
"fix": "npm run update-translations && npm run fix-imports && npm run prettier"
},
"license": "GNU",
"dependencies": {
@ -37,7 +39,7 @@
"ncp": "^2.0.0",
"typescript": "^5.5",
"undici": "^7.10.0",
"warframe-public-export-plus": "^0.5.74",
"warframe-public-export-plus": "^0.5.78",
"warframe-riven-info": "^0.1.2",
"winston": "^3.17.0",
"winston-daily-rotate-file": "^5.0.0",
@ -47,6 +49,8 @@
"@typescript-eslint/eslint-plugin": "^8.28.0",
"@typescript-eslint/parser": "^8.28.0",
"eslint": "^8",
"eslint-import-resolver-typescript": "^4.4.4",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-prettier": "^5.2.5",
"prettier": "^3.5.3",
"tree-kill": "^1.2.2"

46
scripts/fix-imports.js Normal file
View File

@ -0,0 +1,46 @@
/* eslint-disable */
const fs = require("fs");
const path = require("path");
const root = path.join(process.cwd(), "..");
function listFiles(dir) {
const entries = fs.readdirSync(dir, { withFileTypes: true });
let results = [];
for (const entry of entries) {
const fullPath = path.join(dir, entry.name);
if (entry.isDirectory()) {
results = results.concat(listFiles(fullPath));
} else {
results.push(fullPath);
}
}
return results;
}
const files = listFiles(path.join(root, "src"));
for (const file of files) {
let content;
try {
content = fs.readFileSync(file, "utf8");
} catch (e) {
continue;
}
const dir = path.dirname(file);
const fixedContent = content.replaceAll(/} from "([^"]+)";/g, (sub, importPath) => {
if (!importPath.startsWith("@/")) {
const fullImportPath = path.resolve(dir, importPath);
if (fs.existsSync(fullImportPath + ".ts")) {
const relative = path.relative(root, fullImportPath).replace(/\\/g, "/");
const fixedPath = "@/" + relative;
console.log(`${importPath} -> ${fixedPath}`);
return sub.split(importPath).join(fixedPath);
}
}
return sub;
});
if (content != fixedContent) {
fs.writeFileSync(file, fixedContent, "utf8");
}
}

View File

@ -31,7 +31,7 @@ fs.readdirSync("../static/webui/translations").forEach(file => {
const strings = extractStrings(line);
if (Object.keys(strings).length > 0) {
Object.entries(strings).forEach(([key, value]) => {
if (targetStrings.hasOwnProperty(key)) {
if (targetStrings.hasOwnProperty(key) && !targetStrings[key].startsWith("[UNTRANSLATED] ")) {
fs.writeSync(fileHandle, ` ${key}: \`${targetStrings[key]}\`,\n`);
} else {
fs.writeSync(fileHandle, ` ${key}: \`[UNTRANSLATED] ${value}\`,\n`);

View File

@ -24,7 +24,6 @@ export const artifactsController: RequestHandler = async (req, res) => {
if (itemIndex !== -1) {
Upgrades[itemIndex].UpgradeFingerprint = stringifiedUpgradeFingerprint;
inventory.markModified(`Upgrades.${itemIndex}.UpgradeFingerprint`);
} else {
itemIndex =
Upgrades.push({

View File

@ -14,15 +14,17 @@ import {
addRecipes,
occupySlot,
combineInventoryChanges,
addKubrowPetPrint
addKubrowPetPrint,
addPowerSuit,
addEquipment
} from "@/src/services/inventoryService";
import { IInventoryChanges } from "@/src/types/purchaseTypes";
import { IEquipmentClient } from "@/src/types/inventoryTypes/commonInventoryTypes";
import { InventorySlot, IPendingRecipeDatabase, Status } from "@/src/types/inventoryTypes/inventoryTypes";
import { InventorySlot, IPendingRecipeDatabase } from "@/src/types/inventoryTypes/inventoryTypes";
import { toOid2 } from "@/src/helpers/inventoryHelpers";
import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel";
import { IRecipe } from "warframe-public-export-plus";
import { config } from "@/src/services/configService";
import { EquipmentFeatures, IEquipmentClient, Status } from "@/src/types/equipmentTypes";
interface IClaimCompletedRecipeRequest {
RecipeIds: IOid[];
@ -124,17 +126,122 @@ export const claimCompletedRecipeController: RequestHandler = async (req, res) =
const pet = inventory.KubrowPets.id(pendingRecipe.KubrowPet!)!;
addKubrowPetPrint(inventory, pet, InventoryChanges);
} else if (recipe.secretIngredientAction != "SIA_UNBRAND") {
InventoryChanges = {
...InventoryChanges,
...(await addItem(
if (recipe.resultType == "/Lotus/Powersuits/Excalibur/ExcaliburUmbra") {
// Quite the special case here...
// We don't just get Umbra, but also Skiajati and Umbra Mods. Both items are max rank, potatoed, and with the mods are pre-installed.
// Source: https://wiki.warframe.com/w/The_Sacrifice, https://wiki.warframe.com/w/Excalibur/Umbra, https://wiki.warframe.com/w/Skiajati
const umbraModA = (
await addItem(
inventory,
"/Lotus/Upgrades/Mods/Sets/Umbra/WarframeUmbraModA",
1,
false,
undefined,
`{"lvl":5}`
)
).Upgrades![0];
const umbraModB = (
await addItem(
inventory,
"/Lotus/Upgrades/Mods/Sets/Umbra/WarframeUmbraModB",
1,
false,
undefined,
`{"lvl":5}`
)
).Upgrades![0];
const umbraModC = (
await addItem(
inventory,
"/Lotus/Upgrades/Mods/Sets/Umbra/WarframeUmbraModC",
1,
false,
undefined,
`{"lvl":5}`
)
).Upgrades![0];
const sacrificeModA = (
await addItem(
inventory,
"/Lotus/Upgrades/Mods/Sets/Sacrifice/MeleeSacrificeModA",
1,
false,
undefined,
`{"lvl":5}`
)
).Upgrades![0];
const sacrificeModB = (
await addItem(
inventory,
"/Lotus/Upgrades/Mods/Sets/Sacrifice/MeleeSacrificeModB",
1,
false,
undefined,
`{"lvl":5}`
)
).Upgrades![0];
InventoryChanges.Upgrades ??= [];
InventoryChanges.Upgrades.push(umbraModA, umbraModB, umbraModC, sacrificeModA, sacrificeModB);
await addPowerSuit(
inventory,
recipe.resultType,
recipe.num,
false,
undefined,
pendingRecipe.TargetFingerprint
))
};
"/Lotus/Powersuits/Excalibur/ExcaliburUmbra",
{
Configs: [
{
Upgrades: [
"",
"",
"",
"",
"",
umbraModA.ItemId.$oid,
umbraModB.ItemId.$oid,
umbraModC.ItemId.$oid
]
}
],
XP: 900_000,
Features: EquipmentFeatures.DOUBLE_CAPACITY
},
InventoryChanges
);
inventory.XPInfo.push({
ItemType: "/Lotus/Powersuits/Excalibur/ExcaliburUmbra",
XP: 900_000
});
addEquipment(
inventory,
"Melee",
"/Lotus/Weapons/Tenno/Melee/Swords/UmbraKatana/UmbraKatana",
{
Configs: [
{ Upgrades: ["", "", "", "", "", "", sacrificeModA.ItemId.$oid, sacrificeModB.ItemId.$oid] }
],
XP: 450_000,
Features: EquipmentFeatures.DOUBLE_CAPACITY
},
InventoryChanges
);
inventory.XPInfo.push({
ItemType: "/Lotus/Weapons/Tenno/Melee/Swords/UmbraKatana/UmbraKatana",
XP: 450_000
});
} else {
InventoryChanges = {
...InventoryChanges,
...(await addItem(
inventory,
recipe.resultType,
recipe.num,
false,
undefined,
pendingRecipe.TargetFingerprint
))
};
}
}
if (
config.claimingBlueprintRefundsIngredients &&

View File

@ -1,4 +1,4 @@
import { checkCalendarChallengeCompletion, getCalendarProgress, getInventory } from "@/src/services/inventoryService";
import { checkCalendarAutoAdvance, getCalendarProgress, getInventory } from "@/src/services/inventoryService";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { handleStoreItemAcquisition } from "@/src/services/purchaseService";
import { getWorldState } from "@/src/services/worldStateService";
@ -28,7 +28,7 @@ export const completeCalendarEventController: RequestHandler = async (req, res)
}
}
calendarProgress.SeasonProgress.LastCompletedDayIdx = dayIndex;
checkCalendarChallengeCompletion(calendarProgress, currentSeason);
checkCalendarAutoAdvance(inventory, currentSeason);
await inventory.save();
res.json({
InventoryChanges: inventoryChanges,

View File

@ -21,7 +21,8 @@ import {
updateCurrency
} from "@/src/services/inventoryService";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { IFusionTreasure, IMiscItem, ITypeCount } from "@/src/types/inventoryTypes/inventoryTypes";
import { ITypeCount } from "@/src/types/commonTypes";
import { IFusionTreasure, IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
import { RequestHandler } from "express";
export const contributeToVaultController: RequestHandler = async (req, res) => {

View File

@ -4,9 +4,15 @@ import { getAccountIdForRequest } from "@/src/services/loginService";
import { getInventory } from "@/src/services/inventoryService";
export const creditsController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
const inventory = await getInventory(accountId, "RegularCredits TradesRemaining PremiumCreditsFree PremiumCredits");
const inventory = (
await Promise.all([
getAccountIdForRequest(req),
getInventory(
req.query.accountId as string,
"RegularCredits TradesRemaining PremiumCreditsFree PremiumCredits"
)
])
)[1];
const response = {
RegularCredits: inventory.RegularCredits,

View File

@ -12,7 +12,7 @@ import { getJSONfromString } from "@/src/helpers/stringHelpers";
import { IInventoryChanges } from "@/src/types/purchaseTypes";
import { getRandomInt } from "@/src/services/rngService";
import { IFingerprintStat } from "@/src/helpers/rivenHelper";
import { IEquipmentDatabase } from "@/src/types/inventoryTypes/commonInventoryTypes";
import { IEquipmentDatabase } from "@/src/types/equipmentTypes";
export const crewShipIdentifySalvageController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);

View File

@ -1,12 +1,15 @@
import { getJSONfromString } from "@/src/helpers/stringHelpers";
import { Guild } from "@/src/models/guildModel";
import { getAccountForRequest } from "@/src/services/loginService";
import { hasAccessToDojo, hasGuildPermission } from "@/src/services/guildService";
import { getInventory } from "@/src/services/inventoryService";
import { getAccountForRequest, getAccountIdForRequest } from "@/src/services/loginService";
import { GuildPermission } from "@/src/types/guildTypes";
import { logger } from "@/src/utils/logger";
import { RequestHandler } from "express";
export const customObstacleCourseLeaderboardController: RequestHandler = async (req, res) => {
const data = getJSONfromString<ICustomObstacleCourseLeaderboardRequest>(String(req.body));
const guild = (await Guild.findById(data.g, "DojoComponents"))!;
const guild = (await Guild.findById(data.g, "DojoComponents Ranks"))!;
const component = guild.DojoComponents.id(data.c)!;
if (req.query.act == "f") {
res.json({
@ -34,6 +37,19 @@ export const customObstacleCourseLeaderboardController: RequestHandler = async (
entry.r = ++r;
}
await guild.save();
res.status(200).end();
} else if (req.query.act == "c") {
// TOVERIFY: What clan permission is actually needed for this?
const accountId = await getAccountIdForRequest(req);
const inventory = await getInventory(accountId, "GuildId LevelKeys");
if (!hasAccessToDojo(inventory) || !(await hasGuildPermission(guild, accountId, GuildPermission.Decorator))) {
res.status(400).end();
return;
}
component.Leaderboard = undefined;
await guild.save();
res.status(200).end();
} else {
logger.debug(`data provided to ${req.path}: ${String(req.body)}`);

View File

@ -3,7 +3,7 @@ import { getAccountIdForRequest } from "@/src/services/loginService";
import { addMiscItems, getInventory } from "@/src/services/inventoryService";
import { getJSONfromString } from "@/src/helpers/stringHelpers";
import { getRecipe, WeaponTypeInternal } from "@/src/services/itemDataService";
import { EquipmentFeatures } from "@/src/types/inventoryTypes/commonInventoryTypes";
import { EquipmentFeatures } from "@/src/types/equipmentTypes";
export const evolveWeaponController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);

View File

@ -4,7 +4,6 @@ import { getInventory, addMiscItems, addEquipment, occupySlot } from "@/src/serv
import { IMiscItem, TFocusPolarity, TEquipmentKey, InventorySlot } from "@/src/types/inventoryTypes/inventoryTypes";
import { logger } from "@/src/utils/logger";
import { ExportFocusUpgrades } from "warframe-public-export-plus";
import { IEquipmentClient } from "@/src/types/inventoryTypes/commonInventoryTypes";
import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
export const focusController: RequestHandler = async (req, res) => {
@ -116,7 +115,7 @@ export const focusController: RequestHandler = async (req, res) => {
});
occupySlot(inventory, InventorySlot.AMPS, false);
await inventory.save();
res.json((inventoryChanges.OperatorAmps as IEquipmentClient[])[0]);
res.json(inventoryChanges.OperatorAmps![0]);
break;
}
case FocusOperation.UnbindUpgrade: {

View File

@ -6,9 +6,8 @@ import { getAccountIdForRequest } from "@/src/services/loginService";
import { createGarden, getPersonalRooms } from "@/src/services/personalRoomsService";
import { IMongoDate } from "@/src/types/commonTypes";
import { IMissionReward } from "@/src/types/missionTypes";
import { IPersonalRoomsClient } from "@/src/types/personalRoomsTypes";
import { IGardeningClient, IPersonalRoomsClient } from "@/src/types/personalRoomsTypes";
import { IInventoryChanges } from "@/src/types/purchaseTypes";
import { IGardeningClient } from "@/src/types/shipTypes";
import { RequestHandler } from "express";
import { dict_en, ExportResources } from "warframe-public-export-plus";

View File

@ -1,6 +1,6 @@
import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
import { generateRewardSeed } from "@/src/services/inventoryService";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { generateRewardSeed } from "@/src/services/rngService";
import { RequestHandler } from "express";
export const getNewRewardSeedController: RequestHandler = async (req, res) => {

View File

@ -3,10 +3,9 @@ import { config } from "@/src/services/configService";
import allShipFeatures from "@/static/fixed_responses/allShipFeatures.json";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { createGarden, getPersonalRooms } from "@/src/services/personalRoomsService";
import { toOid } from "@/src/helpers/inventoryHelpers";
import { IGetShipResponse } from "@/src/types/shipTypes";
import { IPersonalRoomsClient } from "@/src/types/personalRoomsTypes";
import { IGetShipResponse, IPersonalRoomsClient } from "@/src/types/personalRoomsTypes";
import { getLoadout } from "@/src/services/loadoutService";
import { toOid } from "@/src/helpers/inventoryHelpers";
export const getShipController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
@ -26,15 +25,7 @@ export const getShipController: RequestHandler = async (req, res) => {
LoadOutInventory: { LoadOutPresets: loadout.toJSON() },
Ship: {
...personalRooms.Ship,
ShipId: toOid(personalRoomsDb.activeShipId),
ShipInterior: {
Colors: personalRooms.ShipInteriorColors,
ShipAttachments: { HOOD_ORNAMENT: "" },
SkinFlavourItem: ""
},
FavouriteLoadoutId: personalRooms.Ship.FavouriteLoadoutId
? toOid(personalRooms.Ship.FavouriteLoadoutId)
: undefined
ShipId: toOid(personalRoomsDb.activeShipId)
},
Apartment: personalRooms.Apartment,
TailorShop: personalRooms.TailorShop

View File

@ -3,9 +3,10 @@ import { getAccountIdForRequest } from "@/src/services/loginService";
import { getJSONfromString } from "@/src/helpers/stringHelpers";
import { addMiscItems, getInventory } from "@/src/services/inventoryService";
import { TEquipmentKey } from "@/src/types/inventoryTypes/inventoryTypes";
import { ArtifactPolarity, EquipmentFeatures, IEquipmentClient } from "@/src/types/inventoryTypes/commonInventoryTypes";
import { ArtifactPolarity } from "@/src/types/inventoryTypes/commonInventoryTypes";
import { ExportRecipes } from "warframe-public-export-plus";
import { IInventoryChanges } from "@/src/types/purchaseTypes";
import { EquipmentFeatures, IEquipmentClient } from "@/src/types/equipmentTypes";
interface IGildWeaponRequest {
ItemName: string;

View File

@ -1,7 +1,8 @@
import { getJSONfromString } from "@/src/helpers/stringHelpers";
import { addLoreFragmentScans, addShipDecorations, getInventory } from "@/src/services/inventoryService";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { ILoreFragmentScan, ITypeCount } from "@/src/types/inventoryTypes/inventoryTypes";
import { ITypeCount } from "@/src/types/commonTypes";
import { ILoreFragmentScan } from "@/src/types/inventoryTypes/inventoryTypes";
import { RequestHandler } from "express";
export const giveShipDecoAndLoreFragmentController: RequestHandler = async (req, res) => {

View File

@ -5,6 +5,7 @@ import {
getGuildVault,
hasAccessToDojo,
hasGuildPermission,
processCompletedGuildTechProject,
processFundedGuildTechProject,
processGuildTechProjectContributionsUpdate,
removePigmentsFromGuildMembers,
@ -51,8 +52,12 @@ export const guildTechController: RequestHandler = async (req, res) => {
};
if (project.CompletionDate) {
techProject.CompletionDate = toMongoDate(project.CompletionDate);
if (Date.now() >= project.CompletionDate.getTime()) {
needSave ||= setGuildTechLogState(guild, project.ItemType, 4, project.CompletionDate);
if (
Date.now() >= project.CompletionDate.getTime() &&
setGuildTechLogState(guild, project.ItemType, 4, project.CompletionDate)
) {
processCompletedGuildTechProject(guild, project.ItemType);
needSave = true;
}
}
techProjects.push(techProject);

View File

@ -5,15 +5,25 @@ import { config } from "@/src/services/configService";
import allDialogue from "@/static/fixed_responses/allDialogue.json";
import { ILoadoutDatabase } from "@/src/types/saveLoadoutTypes";
import { IInventoryClient, IShipInventory, equipmentKeys } from "@/src/types/inventoryTypes/inventoryTypes";
import { IPolarity, ArtifactPolarity, EquipmentFeatures } from "@/src/types/inventoryTypes/commonInventoryTypes";
import { ExportCustoms, ExportFlavour, ExportResources, ExportVirtuals } from "warframe-public-export-plus";
import { IPolarity, ArtifactPolarity } from "@/src/types/inventoryTypes/commonInventoryTypes";
import {
eFaction,
ExportCustoms,
ExportFlavour,
ExportResources,
ExportVirtuals,
ICountedItem
} from "warframe-public-export-plus";
import { applyCheatsToInfestedFoundry, handleSubsumeCompletion } from "@/src/services/infestedFoundryService";
import {
addEmailItem,
addItem,
addMiscItems,
allDailyAffiliationKeys,
checkCalendarAutoAdvance,
cleanupInventory,
createLibraryDailyTask,
generateRewardSeed
getCalendarProgress
} from "@/src/services/inventoryService";
import { logger } from "@/src/utils/logger";
import { addString, catBreadHash } from "@/src/helpers/stringHelpers";
@ -26,6 +36,10 @@ import { toLegacyOid, toOid, version_compare } from "@/src/helpers/inventoryHelp
import { Inbox } from "@/src/models/inboxModel";
import { unixTimesInMs } from "@/src/constants/timeConstants";
import { DailyDeal } from "@/src/models/worldStateModel";
import { EquipmentFeatures } from "@/src/types/equipmentTypes";
import { generateRewardSeed } from "@/src/services/rngService";
import { getInvasionByOid, getWorldState } from "@/src/services/worldStateService";
import { createMessage } from "@/src/services/inboxService";
export const inventoryController: RequestHandler = async (request, response) => {
const account = await getAccountForRequest(request);
@ -108,6 +122,64 @@ export const inventoryController: RequestHandler = async (request, response) =>
}
}
// TODO: Setup CalendarProgress as part of 1999 mission completion?
const previousYearIteration = inventory.CalendarProgress?.Iteration;
// We need to do the following to ensure the in-game calendar does not break:
getCalendarProgress(inventory); // Keep the CalendarProgress up-to-date (at least for the current year iteration) (https://onlyg.it/OpenWF/SpaceNinjaServer/issues/2364)
checkCalendarAutoAdvance(inventory, getWorldState().KnownCalendarSeasons[0]); // Skip birthday events for characters if we do not have them unlocked yet (https://onlyg.it/OpenWF/SpaceNinjaServer/issues/2424)
// also handle sending of kiss cinematic at year rollover
if (
inventory.CalendarProgress!.Iteration != previousYearIteration &&
inventory.DialogueHistory &&
inventory.DialogueHistory.Dialogues
) {
let kalymos = false;
for (const { dialogueName, kissEmail } of [
{
dialogueName: "/Lotus/Types/Gameplay/1999Wf/Dialogue/ArthurDialogue_rom.dialogue",
kissEmail: "/Lotus/Types/Items/EmailItems/ArthurKissEmailItem"
},
{
dialogueName: "/Lotus/Types/Gameplay/1999Wf/Dialogue/EleanorDialogue_rom.dialogue",
kissEmail: "/Lotus/Types/Items/EmailItems/EleanorKissEmailItem"
},
{
dialogueName: "/Lotus/Types/Gameplay/1999Wf/Dialogue/LettieDialogue_rom.dialogue",
kissEmail: "/Lotus/Types/Items/EmailItems/LettieKissEmailItem"
},
{
dialogueName: "/Lotus/Types/Gameplay/1999Wf/Dialogue/JabirDialogue_rom.dialogue",
kissEmail: "/Lotus/Types/Items/EmailItems/AmirKissEmailItem"
},
{
dialogueName: "/Lotus/Types/Gameplay/1999Wf/Dialogue/AoiDialogue_rom.dialogue",
kissEmail: "/Lotus/Types/Items/EmailItems/AoiKissEmailItem"
},
{
dialogueName: "/Lotus/Types/Gameplay/1999Wf/Dialogue/QuincyDialogue_rom.dialogue",
kissEmail: "/Lotus/Types/Items/EmailItems/QuincyKissEmailItem"
}
]) {
const dialogue = inventory.DialogueHistory.Dialogues.find(x => x.DialogueName == dialogueName);
if (dialogue) {
if (dialogue.Rank == 7) {
await addEmailItem(inventory, kissEmail);
kalymos = false;
break;
}
if (dialogue.Rank == 6) {
kalymos = true;
}
}
}
if (kalymos) {
await addEmailItem(inventory, "/Lotus/Types/Items/EmailItems/KalymosKissEmailItem");
}
}
cleanupInventory(inventory);
inventory.NextRefill = new Date((today + 1) * 86400000); // tomorrow at 0 UTC
@ -123,6 +195,63 @@ export const inventoryController: RequestHandler = async (request, response) =>
//await inventory.save();
}
for (let i = 0; i != inventory.QualifyingInvasions.length; ) {
const qi = inventory.QualifyingInvasions[i];
const invasion = getInvasionByOid(qi.invasionId.toString());
if (!invasion) {
logger.debug(`removing QualifyingInvasions entry for unknown invasion: ${qi.invasionId.toString()}`);
inventory.QualifyingInvasions.splice(i, 1);
continue;
}
if (invasion.Completed) {
let factionSidedWith: string | undefined;
let battlePay: ICountedItem[] | undefined;
if (qi.AttackerScore >= 3) {
factionSidedWith = invasion.Faction;
battlePay = invasion.AttackerReward.countedItems;
logger.debug(`invasion pay from ${factionSidedWith}`, { battlePay });
} else if (qi.DefenderScore >= 3) {
factionSidedWith = invasion.DefenderFaction;
battlePay = invasion.DefenderReward.countedItems;
logger.debug(`invasion pay from ${factionSidedWith}`, { battlePay });
}
if (factionSidedWith) {
if (battlePay) {
// Decoupling rewards from the inbox message because it may delete itself without being read
for (const item of battlePay) {
await addItem(inventory, item.ItemType, item.ItemCount);
}
await createMessage(account._id, [
{
sndr: eFaction.find(x => x.tag == factionSidedWith)?.name ?? factionSidedWith, // TOVERIFY
msg: `/Lotus/Language/G1Quests/${factionSidedWith}_InvasionThankyouMessageBody`,
sub: `/Lotus/Language/G1Quests/${factionSidedWith}_InvasionThankyouMessageSubject`,
countedAtt: battlePay,
attVisualOnly: true,
icon:
factionSidedWith == "FC_GRINEER"
? "/Lotus/Interface/Icons/Npcs/EliteRifleLancerAvatar.png" // Source: https://www.reddit.com/r/Warframe/comments/1aj4usx/battle_pay_worth_10_plat/, https://www.youtube.com/watch?v=XhNZ6ai6BOY
: "/Lotus/Interface/Icons/Npcs/CrewmanNormal.png", // My best source for this is https://www.youtube.com/watch?v=rxrCCFm73XE around 1:37
// TOVERIFY: highPriority?
endDate: new Date(Date.now() + 86400_000) // TOVERIFY: This type of inbox message seems to automatically delete itself. We'll just delete it after 24 hours, but it's not clear if this is correct.
}
]);
}
if (invasion.Faction != "FC_INFESTATION") {
// Sided with grineer -> opposed corpus -> send zanuka (harvester)
// Sided with corpus -> opposed grineer -> send g3 (death squad)
inventory[factionSidedWith != "FC_GRINEER" ? "DeathSquadable" : "Harvestable"] = true;
// TOVERIFY: Should this happen earlier?
// TOVERIFY: Should this send an (ephemeral) email?
}
}
logger.debug(`removing QualifyingInvasions entry for completed invasion: ${qi.invasionId.toString()}`);
inventory.QualifyingInvasions.splice(i, 1);
continue;
}
++i;
}
if (inventory.LastInventorySync) {
const lastSyncDuviriMood = Math.trunc(inventory.LastInventorySync.getTimestamp().getTime() / 7200000);
const currentDuviriMood = Math.trunc(Date.now() / 7200000);

View File

@ -1,9 +1,8 @@
import { getAccountIdForRequest } from "@/src/services/loginService";
import { getInventory, updateCurrency } from "@/src/services/inventoryService";
import { getInventory, updateCurrency, updateSlots } from "@/src/services/inventoryService";
import { RequestHandler } from "express";
import { updateSlots } from "@/src/services/inventoryService";
import { InventorySlot } from "@/src/types/inventoryTypes/inventoryTypes";
import { logger } from "@/src/utils/logger";
import { exhaustive } from "@/src/utils/ts-utils";
/*
loadout slots are additionally purchased slots only
@ -23,13 +22,44 @@ export const inventorySlotsController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
const body = JSON.parse(req.body as string) as IInventorySlotsRequest;
if (body.Bin != InventorySlot.SUITS && body.Bin != InventorySlot.PVE_LOADOUTS) {
logger.warn(`unexpected slot purchase of type ${body.Bin}, account may be overcharged`);
let price;
let amount;
switch (body.Bin) {
case InventorySlot.SUITS:
case InventorySlot.MECHSUITS:
case InventorySlot.PVE_LOADOUTS:
case InventorySlot.CREWMEMBERS:
price = 20;
amount = 1;
break;
case InventorySlot.SPACESUITS:
price = 12;
amount = 1;
break;
case InventorySlot.WEAPONS:
case InventorySlot.SPACEWEAPONS:
case InventorySlot.SENTINELS:
case InventorySlot.RJ_COMPONENT_AND_ARMAMENTS:
case InventorySlot.AMPS:
price = 12;
amount = 2;
break;
case InventorySlot.RIVENS:
price = 60;
amount = 3;
break;
default:
exhaustive(body.Bin);
throw new Error(`unexpected slot purchase of type ${body.Bin as string}`);
}
const inventory = await getInventory(accountId);
const currencyChanges = updateCurrency(inventory, 20, true);
updateSlots(inventory, body.Bin, 1, 1);
const currencyChanges = updateCurrency(inventory, price, true);
updateSlots(inventory, body.Bin, amount, amount);
await inventory.save();
res.json({ InventoryChanges: currencyChanges });

View File

@ -8,7 +8,7 @@ import { createAccount, createNonce, getUsernameFromEmail, isCorrectPassword } f
import { IDatabaseAccountJson, ILoginRequest, ILoginResponse } from "@/src/types/loginTypes";
import { logger } from "@/src/utils/logger";
import { version_compare } from "@/src/helpers/inventoryHelpers";
import { sendWsBroadcastTo } from "@/src/services/webService";
import { sendWsBroadcastTo } from "@/src/services/wsService";
export const loginController: RequestHandler = async (request, response) => {
const loginRequest = JSON.parse(String(request.body)) as ILoginRequest; // parse octet stream of json data to json object

View File

@ -9,6 +9,7 @@ import {
} from "@/src/services/loginRewardService";
import { getInventory } from "@/src/services/inventoryService";
import { config } from "@/src/services/configService";
import { sendWsBroadcastTo } from "@/src/services/wsService";
export const loginRewardsController: RequestHandler = async (req, res) => {
const account = await getAccountForRequest(req);
@ -47,10 +48,10 @@ export const loginRewardsController: RequestHandler = async (req, res) => {
response.DailyTributeInfo.HasChosenReward = true;
response.DailyTributeInfo.ChosenReward = randomRewards[0];
response.DailyTributeInfo.NewInventory = await claimLoginReward(inventory, randomRewards[0]);
await inventory.save();
setAccountGotLoginRewardToday(account);
await account.save();
await Promise.all([inventory.save(), account.save()]);
sendWsBroadcastTo(account._id.toString(), { update_inventory: true });
}
res.json(response);
};

View File

@ -6,6 +6,7 @@ import {
} from "@/src/services/loginRewardService";
import { getAccountForRequest } from "@/src/services/loginService";
import { handleStoreItemAcquisition } from "@/src/services/purchaseService";
import { sendWsBroadcastTo } from "@/src/services/wsService";
import { IInventoryChanges } from "@/src/types/purchaseTypes";
import { logger } from "@/src/utils/logger";
import { RequestHandler } from "express";
@ -34,11 +35,10 @@ export const loginRewardsSelectionController: RequestHandler = async (req, res)
chosenReward = randomRewards.find(x => x.StoreItemType == body.ChosenReward)!;
inventoryChanges = await claimLoginReward(inventory, chosenReward);
}
await inventory.save();
setAccountGotLoginRewardToday(account);
await account.save();
await Promise.all([inventory.save(), account.save()]);
sendWsBroadcastTo(account._id.toString(), { update_inventory: true });
res.json({
DailyTributeInfo: {
NewInventory: inventoryChanges,

View File

@ -1,6 +1,6 @@
import { RequestHandler } from "express";
import { Account } from "@/src/models/loginModel";
import { sendWsBroadcastTo } from "@/src/services/webService";
import { sendWsBroadcastTo } from "@/src/services/wsService";
export const logoutController: RequestHandler = async (req, res) => {
if (!req.query.accountId) {

View File

@ -3,11 +3,12 @@ import { getJSONfromString } from "@/src/helpers/stringHelpers";
import { getAccountForRequest } from "@/src/services/loginService";
import { IMissionInventoryUpdateRequest } from "@/src/types/requestTypes";
import { addMissionInventoryUpdates, addMissionRewards } from "@/src/services/missionInventoryUpdateService";
import { generateRewardSeed, getInventory } from "@/src/services/inventoryService";
import { getInventoryResponse } from "./inventoryController";
import { getInventory } from "@/src/services/inventoryService";
import { getInventoryResponse } from "@/src/controllers/api/inventoryController";
import { logger } from "@/src/utils/logger";
import { IMissionInventoryUpdateResponse } from "@/src/types/missionTypes";
import { sendWsBroadcastTo } from "@/src/services/webService";
import { sendWsBroadcastTo } from "@/src/services/wsService";
import { generateRewardSeed } from "@/src/services/rngService";
/*
**** INPUT ****

View File

@ -15,10 +15,9 @@ import {
import { IInventoryChanges } from "@/src/types/purchaseTypes";
import { getDefaultUpgrades } from "@/src/services/itemDataService";
import { modularWeaponTypes } from "@/src/helpers/modularWeaponHelper";
import { IEquipmentDatabase } from "@/src/types/inventoryTypes/commonInventoryTypes";
import { getRandomInt } from "@/src/services/rngService";
import { ExportSentinels, ExportWeapons, IDefaultUpgrade } from "warframe-public-export-plus";
import { Status } from "@/src/types/inventoryTypes/inventoryTypes";
import { IEquipmentDatabase, Status } from "@/src/types/equipmentTypes";
interface IModularCraftRequest {
WeaponType: string;

View File

@ -3,7 +3,7 @@ import { ExportWeapons } from "warframe-public-export-plus";
import { IMongoDate } from "@/src/types/commonTypes";
import { toMongoDate } from "@/src/helpers/inventoryHelpers";
import { SRng } from "@/src/services/rngService";
import { ArtifactPolarity, EquipmentFeatures } from "@/src/types/inventoryTypes/commonInventoryTypes";
import { ArtifactPolarity } from "@/src/types/inventoryTypes/commonInventoryTypes";
import { getJSONfromString } from "@/src/helpers/stringHelpers";
import {
addEquipment,
@ -17,6 +17,7 @@ import { getDefaultUpgrades } from "@/src/services/itemDataService";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { modularWeaponTypes } from "@/src/helpers/modularWeaponHelper";
import { IInventoryChanges } from "@/src/types/purchaseTypes";
import { EquipmentFeatures } from "@/src/types/equipmentTypes";
export const modularWeaponSaleController: RequestHandler = async (req, res) => {
const partTypeToParts: Record<string, string[]> = {};

View File

@ -3,7 +3,7 @@ import { getAccountIdForRequest } from "@/src/services/loginService";
import { getInventory, updateCurrency } from "@/src/services/inventoryService";
import { getJSONfromString } from "@/src/helpers/stringHelpers";
import { TEquipmentKey } from "@/src/types/inventoryTypes/inventoryTypes";
import { sendWsBroadcastTo } from "@/src/services/webService";
import { sendWsBroadcastTo } from "@/src/services/wsService";
interface INameWeaponRequest {
ItemName: string;

View File

@ -1,7 +1,6 @@
import { version_compare } from "@/src/helpers/inventoryHelpers";
import {
antivirusMods,
consumeModCharge,
decodeNemesisGuess,
encodeNemesisGuess,
getInfNodes,
@ -17,12 +16,13 @@ import {
parseUpgrade
} from "@/src/helpers/nemesisHelpers";
import { getJSONfromString } from "@/src/helpers/stringHelpers";
import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel";
import { Loadout } from "@/src/models/inventoryModels/loadoutModel";
import { freeUpSlot, getInventory } from "@/src/services/inventoryService";
import { addMods, freeUpSlot, getInventory } from "@/src/services/inventoryService";
import { getAccountForRequest } from "@/src/services/loginService";
import { SRng } from "@/src/services/rngService";
import { IMongoDate, IOid } from "@/src/types/commonTypes";
import { IEquipmentClient } from "@/src/types/inventoryTypes/commonInventoryTypes";
import { IEquipmentClient } from "@/src/types/equipmentTypes";
import {
IInnateDamageFingerprint,
IInventoryClient,
@ -36,6 +36,7 @@ import {
} from "@/src/types/inventoryTypes/inventoryTypes";
import { logger } from "@/src/utils/logger";
import { RequestHandler } from "express";
import { Types } from "mongoose";
export const nemesisController: RequestHandler = async (req, res) => {
const account = await getAccountForRequest(req);
@ -391,3 +392,54 @@ interface IKnife {
AttachedUpgrades: IUpgradeClient[];
HiddenWhenHolstered: boolean;
}
const consumeModCharge = (
response: IKnifeResponse,
inventory: TInventoryDatabaseDocument,
upgrade: { ItemId: IOid; ItemType: string },
dataknifeUpgrades: string[]
): void => {
response.UpgradeIds ??= [];
response.UpgradeTypes ??= [];
response.UpgradeFingerprints ??= [];
response.UpgradeNew ??= [];
response.HasKnife = true;
if (upgrade.ItemId.$oid != "000000000000000000000000") {
const dbUpgrade = inventory.Upgrades.id(upgrade.ItemId.$oid)!;
const fingerprint = JSON.parse(dbUpgrade.UpgradeFingerprint!) as { lvl: number };
fingerprint.lvl += 1;
dbUpgrade.UpgradeFingerprint = JSON.stringify(fingerprint);
response.UpgradeIds.push(upgrade.ItemId.$oid);
response.UpgradeTypes.push(upgrade.ItemType);
response.UpgradeFingerprints.push(fingerprint);
response.UpgradeNew.push(false);
} else {
const id = new Types.ObjectId();
inventory.Upgrades.push({
_id: id,
ItemType: upgrade.ItemType,
UpgradeFingerprint: `{"lvl":1}`
});
addMods(inventory, [
{
ItemType: upgrade.ItemType,
ItemCount: -1
}
]);
const dataknifeRawUpgradeIndex = dataknifeUpgrades.indexOf(upgrade.ItemType);
if (dataknifeRawUpgradeIndex != -1) {
dataknifeUpgrades[dataknifeRawUpgradeIndex] = id.toString();
} else {
logger.warn(`${upgrade.ItemType} not found in dataknife config`);
}
response.UpgradeIds.push(id.toString());
response.UpgradeTypes.push(upgrade.ItemType);
response.UpgradeFingerprints.push({ lvl: 1 });
response.UpgradeNew.push(true);
}
};

View File

@ -57,8 +57,12 @@ export const placeDecoInComponentController: RequestHandler = async (req, res) =
component.DecoCapacity -= meta.capacityCost;
}
} else {
const [itemType, meta] = Object.entries(ExportResources).find(arr => arr[1].deco == deco.Type)!;
if (!itemType || meta.dojoCapacityCost === undefined) {
const entry = Object.entries(ExportResources).find(arr => arr[1].deco == deco.Type);
if (!entry) {
throw new Error(`unknown deco type: ${deco.Type}`);
}
const [itemType, meta] = entry;
if (meta.dojoCapacityCost === undefined) {
throw new Error(`unknown deco type: ${deco.Type}`);
}
component.DecoCapacity -= meta.dojoCapacityCost;
@ -75,7 +79,13 @@ export const placeDecoInComponentController: RequestHandler = async (req, res) =
if (meta) {
processDojoBuildMaterialsGathered(guild, meta);
}
} else if (guild.AutoContributeFromVault && guild.VaultRegularCredits && guild.VaultMiscItems) {
} else if (
deco.Type.startsWith("/Lotus/Objects/Tenno/Dojo/NpcPlaceables/") ||
(guild.AutoContributeFromVault && guild.VaultRegularCredits && guild.VaultMiscItems)
) {
if (!guild.VaultRegularCredits || !guild.VaultMiscItems) {
throw new Error(`dojo visitor placed without anything in vault?!`);
}
if (guild.VaultRegularCredits >= scaleRequiredCount(guild.Tier, meta.price)) {
let enoughMiscItems = true;
for (const ingredient of meta.ingredients) {

View File

@ -1,25 +1,39 @@
import { getJSONfromString } from "@/src/helpers/stringHelpers";
import { getInventory } from "@/src/services/inventoryService";
import { addConsumables, getInventory } from "@/src/services/inventoryService";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { IPlayerSkills } from "@/src/types/inventoryTypes/inventoryTypes";
import { IInventoryChanges } from "@/src/types/purchaseTypes";
import { RequestHandler } from "express";
export const playerSkillsController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
const inventory = await getInventory(accountId, "PlayerSkills");
const inventory = await getInventory(accountId, "PlayerSkills Consumables");
const request = getJSONfromString<IPlayerSkillsRequest>(String(req.body));
const oldRank: number = inventory.PlayerSkills[request.Skill as keyof IPlayerSkills];
const cost = (request.Pool == "LPP_DRIFTER" ? drifterCosts[oldRank] : 1 << oldRank) * 1000;
inventory.PlayerSkills[request.Pool as keyof IPlayerSkills] -= cost;
inventory.PlayerSkills[request.Skill as keyof IPlayerSkills]++;
await inventory.save();
const inventoryChanges: IInventoryChanges = {};
if (request.Skill == "LPS_COMMAND" && inventory.PlayerSkills.LPS_COMMAND == 9) {
const consumablesChanges = [
{
ItemType: "/Lotus/Types/Restoratives/Consumable/CrewmateBall",
ItemCount: 1
}
];
addConsumables(inventory, consumablesChanges);
inventoryChanges.Consumables = consumablesChanges;
}
await inventory.save();
res.json({
Pool: request.Pool,
PoolInc: -cost,
Skill: request.Skill,
Rank: oldRank + 1
Rank: oldRank + 1,
InventoryChanges: inventoryChanges
});
};

View File

@ -3,7 +3,7 @@ import { getAccountIdForRequest } from "@/src/services/loginService";
import { IPurchaseRequest } from "@/src/types/purchaseTypes";
import { handlePurchase } from "@/src/services/purchaseService";
import { getInventory } from "@/src/services/inventoryService";
import { sendWsBroadcastTo } from "@/src/services/webService";
import { sendWsBroadcastTo } from "@/src/services/wsService";
export const purchaseController: RequestHandler = async (req, res) => {
const purchaseRequest = JSON.parse(String(req.body)) as IPurchaseRequest;

View File

@ -1,7 +1,7 @@
import { getJSONfromString } from "@/src/helpers/stringHelpers";
import { getInventory, updateCurrency } from "@/src/services/inventoryService";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { sendWsBroadcastTo } from "@/src/services/webService";
import { sendWsBroadcastTo } from "@/src/services/wsService";
import { IInventoryChanges } from "@/src/types/purchaseTypes";
import { RequestHandler } from "express";

View File

@ -0,0 +1,5 @@
import { RequestHandler } from "express";
export const resetQuestProgressController: RequestHandler = (_req, res) => {
res.send("1").end();
};

View File

@ -1,7 +1,7 @@
import { getJSONfromString } from "@/src/helpers/stringHelpers";
import { getInventory } from "@/src/services/inventoryService";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { Status } from "@/src/types/inventoryTypes/inventoryTypes";
import { Status } from "@/src/types/equipmentTypes";
import { RequestHandler } from "express";
export const retrievePetFromStasisController: RequestHandler = async (req, res) => {

View File

@ -2,7 +2,7 @@ import { getAccountIdForRequest } from "@/src/services/loginService";
import { getJSONfromString } from "@/src/helpers/stringHelpers";
import { getInventory } from "@/src/services/inventoryService";
import { RequestHandler } from "express";
import { ISettings } from "../../types/inventoryTypes/inventoryTypes";
import { ISettings } from "@/src/types/inventoryTypes/inventoryTypes";
interface ISaveSettingsRequest {
Settings: ISettings;

View File

@ -15,10 +15,11 @@ import { InventorySlot } from "@/src/types/inventoryTypes/inventoryTypes";
import { ExportDojoRecipes } from "warframe-public-export-plus";
import { IInventoryChanges } from "@/src/types/purchaseTypes";
import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel";
import { sendWsBroadcastTo } from "@/src/services/webService";
import { sendWsBroadcastTo } from "@/src/services/wsService";
export const sellController: RequestHandler = async (req, res) => {
const payload = JSON.parse(String(req.body)) as ISellRequest;
//console.log(JSON.stringify(payload, null, 2));
const accountId = await getAccountIdForRequest(req);
const requiredFields = new Set<keyof TInventoryDatabaseDocument>();
if (payload.SellCurrency == "SC_RegularCredits") {
@ -58,6 +59,9 @@ export const sellController: RequestHandler = async (req, res) => {
if (payload.Items.Hoverboards) {
requiredFields.add(InventorySlot.SPACESUITS);
}
if (payload.Items.CrewMembers) {
requiredFields.add(InventorySlot.CREWMEMBERS);
}
if (payload.Items.CrewShipWeapons || payload.Items.CrewShipWeaponSkins) {
requiredFields.add(InventorySlot.RJ_COMPONENT_AND_ARMAMENTS);
requiredFields.add("CrewShipRawSalvage");
@ -181,6 +185,17 @@ export const sellController: RequestHandler = async (req, res) => {
inventory.Drones.pull({ _id: sellItem.String });
});
}
if (payload.Items.KubrowPetPrints) {
payload.Items.KubrowPetPrints.forEach(sellItem => {
inventory.KubrowPetPrints.pull({ _id: sellItem.String });
});
}
if (payload.Items.CrewMembers) {
payload.Items.CrewMembers.forEach(sellItem => {
inventory.CrewMembers.pull({ _id: sellItem.String });
freeUpSlot(inventory, InventorySlot.CREWMEMBERS);
});
}
if (payload.Items.CrewShipWeapons) {
payload.Items.CrewShipWeapons.forEach(sellItem => {
if (sellItem.String[0] == "/") {
@ -303,6 +318,8 @@ interface ISellRequest {
OperatorAmps?: ISellItem[];
Hoverboards?: ISellItem[];
Drones?: ISellItem[];
KubrowPetPrints?: ISellItem[];
CrewMembers?: ISellItem[];
CrewShipWeapons?: ISellItem[];
CrewShipWeaponSkins?: ISellItem[];
};

View File

@ -1,7 +1,7 @@
import { RequestHandler } from "express";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { getPersonalRooms } from "@/src/services/personalRoomsService";
import { TBootLocation } from "@/src/types/shipTypes";
import { TBootLocation } from "@/src/types/personalRoomsTypes";
import { getInventory } from "@/src/services/inventoryService";
export const setBootLocationController: RequestHandler = async (req, res) => {

View File

@ -1,5 +1,5 @@
import { getAccountIdForRequest } from "@/src/services/loginService";
import { IPictureFrameInfo, ISetPlacedDecoInfoRequest } from "@/src/types/shipTypes";
import { IPictureFrameInfo, ISetPlacedDecoInfoRequest } from "@/src/types/personalRoomsTypes";
import { RequestHandler } from "express";
import { handleSetPlacedDecoInfo } from "@/src/services/shipCustomizationsService";

View File

@ -1,6 +1,6 @@
import { getAccountIdForRequest } from "@/src/services/loginService";
import { setShipCustomizations } from "@/src/services/shipCustomizationsService";
import { ISetShipCustomizationsRequest } from "@/src/types/shipTypes";
import { ISetShipCustomizationsRequest } from "@/src/types/personalRoomsTypes";
import { logger } from "@/src/utils/logger";
import { RequestHandler } from "express";

View File

@ -3,7 +3,7 @@ import { RequestHandler } from "express";
import { getPersonalRooms } from "@/src/services/personalRoomsService";
import { IOid } from "@/src/types/commonTypes";
import { Types } from "mongoose";
import { IFavouriteLoadoutDatabase, TBootLocation } from "@/src/types/shipTypes";
import { IFavouriteLoadoutDatabase, TBootLocation } from "@/src/types/personalRoomsTypes";
export const setShipFavouriteLoadoutController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);

View File

@ -2,7 +2,7 @@ import { fromMongoDate, fromOid } from "@/src/helpers/inventoryHelpers";
import { getJSONfromString } from "@/src/helpers/stringHelpers";
import { getInventory } from "@/src/services/inventoryService";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { IEquipmentClient } from "@/src/types/inventoryTypes/commonInventoryTypes";
import { IEquipmentClient } from "@/src/types/equipmentTypes";
import { RequestHandler } from "express";
export const setSuitInfectionController: RequestHandler = async (req, res) => {

View File

@ -1,5 +1,5 @@
import { getAccountIdForRequest } from "@/src/services/loginService";
import { IShipDecorationsRequest } from "@/src/types/shipTypes";
import { IShipDecorationsRequest } from "@/src/types/personalRoomsTypes";
import { logger } from "@/src/utils/logger";
import { RequestHandler } from "express";
import { handleSetShipDecorations } from "@/src/services/shipCustomizationsService";

View File

@ -6,7 +6,7 @@ import { IOid } from "@/src/types/commonTypes";
import { ExportSyndicates, ExportWeapons } from "warframe-public-export-plus";
import { logger } from "@/src/utils/logger";
import { IAffiliationMods, IInventoryChanges } from "@/src/types/purchaseTypes";
import { EquipmentFeatures } from "@/src/types/inventoryTypes/commonInventoryTypes";
import { EquipmentFeatures } from "@/src/types/equipmentTypes";
export const syndicateStandingBonusController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);

View File

@ -2,7 +2,7 @@ import { fromMongoDate, fromOid } from "@/src/helpers/inventoryHelpers";
import { getJSONfromString } from "@/src/helpers/stringHelpers";
import { addMiscItem, getInventory } from "@/src/services/inventoryService";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { IEquipmentClient } from "@/src/types/inventoryTypes/commonInventoryTypes";
import { IEquipmentClient } from "@/src/types/equipmentTypes";
import { RequestHandler } from "express";
export const umbraController: RequestHandler = async (req, res) => {

View File

@ -1,11 +1,6 @@
import { RequestHandler } from "express";
import { IUpgradesRequest } from "@/src/types/requestTypes";
import {
ArtifactPolarity,
IEquipmentDatabase,
EquipmentFeatures,
IAbilityOverride
} from "@/src/types/inventoryTypes/commonInventoryTypes";
import { ArtifactPolarity, IAbilityOverride } from "@/src/types/inventoryTypes/commonInventoryTypes";
import { IInventoryClient, IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { addMiscItems, addRecipes, getInventory, updateCurrency } from "@/src/services/inventoryService";
@ -13,6 +8,8 @@ import { getRecipeByResult } from "@/src/services/itemDataService";
import { IInventoryChanges } from "@/src/types/purchaseTypes";
import { addInfestedFoundryXP, applyCheatsToInfestedFoundry } from "@/src/services/infestedFoundryService";
import { config } from "@/src/services/configService";
import { sendWsBroadcastTo } from "@/src/services/wsService";
import { EquipmentFeatures, IEquipmentDatabase } from "@/src/types/equipmentTypes";
export const upgradesController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
@ -120,6 +117,7 @@ export const upgradesController: RequestHandler = async (req, res) => {
setSlotPolarity(item, operation.PolarizeSlot, operation.PolarizeValue);
item.Polarized ??= 0;
item.Polarized += 1;
sendWsBroadcastTo(accountId, { update_inventory: true }); // webui may need to to re-add "max rank" button
break;
}
case "/Lotus/Types/Items/MiscItems/ModSlotUnlocker": {

View File

@ -7,7 +7,7 @@ export const addItemsController: RequestHandler = async (req, res) => {
const requests = req.body as IAddItemRequest[];
const inventory = await getInventory(accountId);
for (const request of requests) {
await addItem(inventory, request.ItemType, request.ItemCount, true, undefined, undefined, true);
await addItem(inventory, request.ItemType, request.ItemCount, true, undefined, request.Fingerprint, true);
}
await inventory.save();
res.end();
@ -16,4 +16,5 @@ export const addItemsController: RequestHandler = async (req, res) => {
interface IAddItemRequest {
ItemType: string;
ItemCount: number;
Fingerprint?: string;
}

View File

@ -1,7 +1,7 @@
import { applyClientEquipmentUpdates, getInventory } from "@/src/services/inventoryService";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { IOid } from "@/src/types/commonTypes";
import { IEquipmentClient } from "@/src/types/inventoryTypes/commonInventoryTypes";
import { IEquipmentClient } from "@/src/types/equipmentTypes";
import { TEquipmentKey } from "@/src/types/inventoryTypes/inventoryTypes";
import { RequestHandler } from "express";
import { ExportMisc } from "warframe-public-export-plus";

View File

@ -1,8 +1,8 @@
import { RequestHandler } from "express";
import { config } from "@/src/services/configService";
import { getAccountForRequest, isAdministrator } from "@/src/services/loginService";
import { saveConfig } from "@/src/services/configWatcherService";
import { sendWsBroadcastExcept } from "@/src/services/webService";
import { saveConfig } from "@/src/services/configWriterService";
import { sendWsBroadcastExcept } from "@/src/services/wsService";
export const getConfigController: RequestHandler = async (req, res) => {
const account = await getAccountForRequest(req);
@ -37,6 +37,8 @@ const configIdToIndexable = (id: string): [Record<string, boolean | string | num
let obj = config as unknown as Record<string, never>;
const arr = id.split(".");
while (arr.length > 1) {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
obj[arr[0]] ??= {} as never;
obj = obj[arr[0]];
arr.splice(0, 1);
}

View File

@ -21,6 +21,7 @@ import {
TRelicQuality
} from "warframe-public-export-plus";
import allIncarnons from "@/static/fixed_responses/allIncarnonList.json";
import varzia from "@/static/fixed_responses/worldState/varzia.json";
interface ListedItem {
uniqueName: string;
@ -55,6 +56,7 @@ interface ItemLists {
EvolutionProgress: ListedItem[];
mods: ListedItem[];
Boosters: ListedItem[];
VarziaOffers: ListedItem[];
//circuitGameModes: ListedItem[];
}
@ -91,7 +93,8 @@ const getItemListsController: RequestHandler = (req, response) => {
KubrowPets: [],
EvolutionProgress: [],
mods: [],
Boosters: []
Boosters: [],
VarziaOffers: []
/*circuitGameModes: [
{
uniqueName: "Survival",
@ -338,6 +341,13 @@ const getItemListsController: RequestHandler = (req, response) => {
});
}
for (const item of Object.values(varzia.primeDualPacks)) {
res.VarziaOffers.push({
uniqueName: item.ItemType,
name: getString(getItemName(item.ItemType) || "", lang)
});
}
response.json(res);
};

View File

@ -1,7 +1,7 @@
import { RequestHandler } from "express";
import { getAccountForRequest, isAdministrator, isNameTaken } from "@/src/services/loginService";
import { config } from "@/src/services/configService";
import { saveConfig } from "@/src/services/configWatcherService";
import { saveConfig } from "@/src/services/configWriterService";
export const renameAccountController: RequestHandler = async (req, res) => {
const account = await getAccountForRequest(req);

View File

@ -1,5 +1,5 @@
import { args } from "@/src/helpers/commandLineArguments";
import { sendWsBroadcast } from "@/src/services/webService";
import { sendWsBroadcast } from "@/src/services/wsService";
import { RequestHandler } from "express";
export const webuiFileChangeDetectedController: RequestHandler = (req, res) => {

View File

@ -6,13 +6,11 @@ import { Account } from "@/src/models/loginModel";
import { Stats, TStatsDatabaseDocument } from "@/src/models/statsModel";
import { allDailyAffiliationKeys } from "@/src/services/inventoryService";
import { IMongoDate, IOid } from "@/src/types/commonTypes";
import { IEquipmentClient } from "@/src/types/inventoryTypes/commonInventoryTypes";
import {
IAffiliation,
IAlignment,
IChallengeProgress,
IDailyAffiliations,
ILoadoutConfigClient,
IMission,
IPlayerSkills,
ITypeXPItem
@ -23,6 +21,8 @@ import { ExportCustoms, ExportDojoRecipes } from "warframe-public-export-plus";
import { IStatsClient } from "@/src/types/statTypes";
import { toStoreItem } from "@/src/services/itemDataService";
import { FlattenMaps } from "mongoose";
import { IEquipmentClient } from "@/src/types/equipmentTypes";
import { ILoadoutConfigClient } from "@/src/types/saveLoadoutTypes";
const getProfileViewingDataByPlayerIdImpl = async (playerId: string): Promise<IProfileViewingData | undefined> => {
const account = await Account.findById(playerId, "DisplayName");

View File

@ -1,7 +1,7 @@
import { IAccountCreation } from "@/src/types/customTypes";
import { IDatabaseAccountRequiredFields } from "@/src/types/loginTypes";
import crypto from "crypto";
import { isString, parseEmail, parseString } from "../general";
import { isString, parseEmail, parseString } from "@/src/helpers/general";
const getWhirlpoolHash = (rawPassword: string): string => {
const whirlpool = crypto.createHash("whirlpool");

View File

@ -9,11 +9,11 @@ export const isEmptyObject = (obj: object): boolean => {
};
*/
const isString = (text: unknown): text is string => {
export const isString = (text: unknown): text is string => {
return typeof text === "string" || text instanceof String;
};
const parseString = (data: unknown): string => {
export const parseString = (data: unknown): string => {
if (!isString(data)) {
throw new Error("data is not a string");
}
@ -21,11 +21,11 @@ const parseString = (data: unknown): string => {
return data;
};
const isNumber = (number: unknown): number is number => {
export const isNumber = (number: unknown): number is number => {
return typeof number === "number" && !isNaN(number);
};
const parseNumber = (data: unknown): number => {
export const parseNumber = (data: unknown): number => {
if (!isNumber(data)) {
throw new Error("data is not a number");
}
@ -33,11 +33,11 @@ const parseNumber = (data: unknown): number => {
return Number(data);
};
const isDate = (date: string): boolean => {
export const isDate = (date: string): boolean => {
return Date.parse(date) != 0;
};
const parseDateNumber = (date: unknown): string => {
export const parseDateNumber = (date: unknown): string => {
if (!isString(date) || !isDate(date)) {
throw new Error("date could not be parsed");
}
@ -45,18 +45,18 @@ const parseDateNumber = (date: unknown): string => {
return date;
};
const parseEmail = (email: unknown): string => {
export const parseEmail = (email: unknown): string => {
if (!isString(email)) {
throw new Error("incorrect email");
}
return email;
};
const isBoolean = (booleanCandidate: unknown): booleanCandidate is boolean => {
export const isBoolean = (booleanCandidate: unknown): booleanCandidate is boolean => {
return typeof booleanCandidate === "boolean";
};
const parseBoolean = (booleanCandidate: unknown): boolean => {
export const parseBoolean = (booleanCandidate: unknown): boolean => {
if (!isBoolean(booleanCandidate)) {
throw new Error("argument was not a boolean");
}
@ -70,5 +70,3 @@ export const isObject = (objectCandidate: unknown): objectCandidate is Record<st
!Array.isArray(objectCandidate)
);
};
export { isString, isNumber, parseString, parseNumber, parseDateNumber, parseBoolean, parseEmail };

View File

@ -51,6 +51,11 @@ export const fromMongoDate = (date: IMongoDate): Date => {
return new Date(parseInt(date.$date.$numberLong));
};
export type TTraitsPool = Record<
"Colors" | "EyeColors" | "FurPatterns" | "BodyTypes" | "Heads" | "Tails",
{ type: string; rarity: TRarity }[]
>;
export const kubrowWeights: Record<TRarity, number> = {
COMMON: 6,
UNCOMMON: 4,
@ -65,126 +70,126 @@ export const kubrowFurPatternsWeights: Record<TRarity, number> = {
LEGENDARY: 1
};
export const catbrowDetails = {
export const catbrowDetails: TTraitsPool = {
Colors: [
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorBaseA", rarity: "COMMON" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorBaseB", rarity: "COMMON" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorBaseC", rarity: "COMMON" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorBaseD", rarity: "COMMON" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorBaseA", rarity: "COMMON" },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorBaseB", rarity: "COMMON" },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorBaseC", rarity: "COMMON" },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorBaseD", rarity: "COMMON" },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorSecondaryA", rarity: "UNCOMMON" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorSecondaryB", rarity: "UNCOMMON" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorSecondaryC", rarity: "UNCOMMON" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorSecondaryD", rarity: "UNCOMMON" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorSecondaryA", rarity: "UNCOMMON" },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorSecondaryB", rarity: "UNCOMMON" },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorSecondaryC", rarity: "UNCOMMON" },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorSecondaryD", rarity: "UNCOMMON" },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorTertiaryA", rarity: "RARE" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorTertiaryB", rarity: "RARE" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorTertiaryC", rarity: "RARE" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorTertiaryD", rarity: "RARE" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorTertiaryA", rarity: "RARE" },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorTertiaryB", rarity: "RARE" },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorTertiaryC", rarity: "RARE" },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorTertiaryD", rarity: "RARE" },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorAccentsA", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorAccentsB", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorAccentsC", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorAccentsD", rarity: "LEGENDARY" as TRarity }
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorAccentsA", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorAccentsB", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorAccentsC", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorAccentsD", rarity: "LEGENDARY" }
],
EyeColors: [
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorEyesA", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorEyesB", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorEyesC", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorEyesD", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorEyesE", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorEyesF", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorEyesG", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorEyesH", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorEyesI", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorEyesJ", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorEyesK", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorEyesL", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorEyesM", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorEyesN", rarity: "LEGENDARY" as TRarity }
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorEyesA", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorEyesB", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorEyesC", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorEyesD", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorEyesE", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorEyesF", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorEyesG", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorEyesH", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorEyesI", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorEyesJ", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorEyesK", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorEyesL", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorEyesM", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorEyesN", rarity: "LEGENDARY" }
],
FurPatterns: [{ type: "/Lotus/Types/Game/CatbrowPet/Patterns/CatbrowPetPatternA", rarity: "COMMON" as TRarity }],
FurPatterns: [{ type: "/Lotus/Types/Game/CatbrowPet/Patterns/CatbrowPetPatternA", rarity: "COMMON" }],
BodyTypes: [
{ type: "/Lotus/Types/Game/CatbrowPet/BodyTypes/CatbrowPetRegularBodyType", rarity: "UNCOMMON" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/BodyTypes/CatbrowPetRegularBodyType", rarity: "LEGENDARY" as TRarity }
{ type: "/Lotus/Types/Game/CatbrowPet/BodyTypes/CatbrowPetRegularBodyType", rarity: "UNCOMMON" },
{ type: "/Lotus/Types/Game/CatbrowPet/BodyTypes/CatbrowPetRegularBodyType", rarity: "LEGENDARY" }
],
Heads: [
{ type: "/Lotus/Types/Game/CatbrowPet/Heads/CatbrowHeadA", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Heads/CatbrowHeadB", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Heads/CatbrowHeadC", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Heads/CatbrowHeadD", rarity: "LEGENDARY" as TRarity }
{ type: "/Lotus/Types/Game/CatbrowPet/Heads/CatbrowHeadA", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/CatbrowPet/Heads/CatbrowHeadB", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/CatbrowPet/Heads/CatbrowHeadC", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/CatbrowPet/Heads/CatbrowHeadD", rarity: "LEGENDARY" }
],
Tails: [
{ type: "/Lotus/Types/Game/CatbrowPet/Tails/CatbrowTailA", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Tails/CatbrowTailB", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Tails/CatbrowTailC", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Tails/CatbrowTailD", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/CatbrowPet/Tails/CatbrowTailE", rarity: "LEGENDARY" as TRarity }
{ type: "/Lotus/Types/Game/CatbrowPet/Tails/CatbrowTailA", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/CatbrowPet/Tails/CatbrowTailB", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/CatbrowPet/Tails/CatbrowTailC", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/CatbrowPet/Tails/CatbrowTailD", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/CatbrowPet/Tails/CatbrowTailE", rarity: "LEGENDARY" }
]
};
export const kubrowDetails = {
export const kubrowDetails: TTraitsPool = {
Colors: [
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorMundaneA", rarity: "UNCOMMON" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorMundaneB", rarity: "UNCOMMON" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorMundaneC", rarity: "UNCOMMON" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorMundaneD", rarity: "UNCOMMON" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorMundaneE", rarity: "UNCOMMON" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorMundaneF", rarity: "UNCOMMON" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorMundaneG", rarity: "UNCOMMON" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorMundaneH", rarity: "UNCOMMON" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorMundaneA", rarity: "UNCOMMON" },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorMundaneB", rarity: "UNCOMMON" },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorMundaneC", rarity: "UNCOMMON" },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorMundaneD", rarity: "UNCOMMON" },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorMundaneE", rarity: "UNCOMMON" },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorMundaneF", rarity: "UNCOMMON" },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorMundaneG", rarity: "UNCOMMON" },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorMundaneH", rarity: "UNCOMMON" },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorMidA", rarity: "RARE" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorMidB", rarity: "RARE" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorMidC", rarity: "RARE" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorMidD", rarity: "RARE" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorMidE", rarity: "RARE" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorMidF", rarity: "RARE" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorMidG", rarity: "RARE" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorMidH", rarity: "RARE" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorMidA", rarity: "RARE" },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorMidB", rarity: "RARE" },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorMidC", rarity: "RARE" },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorMidD", rarity: "RARE" },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorMidE", rarity: "RARE" },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorMidF", rarity: "RARE" },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorMidG", rarity: "RARE" },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorMidH", rarity: "RARE" },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorVibrantA", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorVibrantB", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorVibrantC", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorVibrantD", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorVibrantE", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorVibrantF", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorVibrantG", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorVibrantH", rarity: "LEGENDARY" as TRarity }
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorVibrantA", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorVibrantB", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorVibrantC", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorVibrantD", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorVibrantE", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorVibrantF", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorVibrantG", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorVibrantH", rarity: "LEGENDARY" }
],
EyeColors: [
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorEyesA", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorEyesB", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorEyesC", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorEyesD", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorEyesE", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorEyesF", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorEyesG", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorEyesH", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorEyesI", rarity: "LEGENDARY" as TRarity }
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorEyesA", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorEyesB", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorEyesC", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorEyesD", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorEyesE", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorEyesF", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorEyesG", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorEyesH", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/KubrowPet/Colors/KubrowPetColorEyesI", rarity: "LEGENDARY" }
],
FurPatterns: [
{ type: "/Lotus/Types/Game/KubrowPet/Patterns/KubrowPetPatternB", rarity: "UNCOMMON" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Patterns/KubrowPetPatternA", rarity: "UNCOMMON" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Patterns/KubrowPetPatternB", rarity: "UNCOMMON" },
{ type: "/Lotus/Types/Game/KubrowPet/Patterns/KubrowPetPatternA", rarity: "UNCOMMON" },
{ type: "/Lotus/Types/Game/KubrowPet/Patterns/KubrowPetPatternC", rarity: "RARE" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Patterns/KubrowPetPatternD", rarity: "RARE" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Patterns/KubrowPetPatternC", rarity: "RARE" },
{ type: "/Lotus/Types/Game/KubrowPet/Patterns/KubrowPetPatternD", rarity: "RARE" },
{ type: "/Lotus/Types/Game/KubrowPet/Patterns/KubrowPetPatternE", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/Patterns/KubrowPetPatternF", rarity: "LEGENDARY" as TRarity }
{ type: "/Lotus/Types/Game/KubrowPet/Patterns/KubrowPetPatternE", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/KubrowPet/Patterns/KubrowPetPatternF", rarity: "LEGENDARY" }
],
BodyTypes: [
{ type: "/Lotus/Types/Game/KubrowPet/BodyTypes/KubrowPetRegularBodyType", rarity: "UNCOMMON" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/BodyTypes/KubrowPetHeavyBodyType", rarity: "LEGENDARY" as TRarity },
{ type: "/Lotus/Types/Game/KubrowPet/BodyTypes/KubrowPetThinBodyType", rarity: "LEGENDARY" as TRarity }
{ type: "/Lotus/Types/Game/KubrowPet/BodyTypes/KubrowPetRegularBodyType", rarity: "UNCOMMON" },
{ type: "/Lotus/Types/Game/KubrowPet/BodyTypes/KubrowPetHeavyBodyType", rarity: "LEGENDARY" },
{ type: "/Lotus/Types/Game/KubrowPet/BodyTypes/KubrowPetThinBodyType", rarity: "LEGENDARY" }
],
Heads: [],

View File

@ -1,4 +1,4 @@
import { TEquipmentKey } from "../types/inventoryTypes/inventoryTypes";
import { TEquipmentKey } from "@/src/types/inventoryTypes/inventoryTypes";
export const modularWeaponTypes: Record<string, TEquipmentKey> = {
"/Lotus/Weapons/SolarisUnited/Primary/LotusModularPrimary": "LongGuns",

View File

@ -1,12 +1,9 @@
import { ExportRegions, ExportWarframes } from "warframe-public-export-plus";
import { IInfNode, TNemesisFaction } from "@/src/types/inventoryTypes/inventoryTypes";
import { getRewardAtPercentage, SRng } from "@/src/services/rngService";
import { TInventoryDatabaseDocument } from "../models/inventoryModels/inventoryModel";
import { logger } from "../utils/logger";
import { IOid } from "../types/commonTypes";
import { Types } from "mongoose";
import { addMods, generateRewardSeed } from "../services/inventoryService";
import { isArchwingMission } from "../services/worldStateService";
import { generateRewardSeed, getRewardAtPercentage, SRng } from "@/src/services/rngService";
import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel";
import { IOid } from "@/src/types/commonTypes";
import { isArchwingMission } from "@/src/services/worldStateService";
type TInnateDamageTag =
| "InnateElectricityDamage"
@ -364,57 +361,6 @@ export const parseUpgrade = (
}
};
export const consumeModCharge = (
response: IKnifeResponse,
inventory: TInventoryDatabaseDocument,
upgrade: { ItemId: IOid; ItemType: string },
dataknifeUpgrades: string[]
): void => {
response.UpgradeIds ??= [];
response.UpgradeTypes ??= [];
response.UpgradeFingerprints ??= [];
response.UpgradeNew ??= [];
response.HasKnife = true;
if (upgrade.ItemId.$oid != "000000000000000000000000") {
const dbUpgrade = inventory.Upgrades.id(upgrade.ItemId.$oid)!;
const fingerprint = JSON.parse(dbUpgrade.UpgradeFingerprint!) as { lvl: number };
fingerprint.lvl += 1;
dbUpgrade.UpgradeFingerprint = JSON.stringify(fingerprint);
response.UpgradeIds.push(upgrade.ItemId.$oid);
response.UpgradeTypes.push(upgrade.ItemType);
response.UpgradeFingerprints.push(fingerprint);
response.UpgradeNew.push(false);
} else {
const id = new Types.ObjectId();
inventory.Upgrades.push({
_id: id,
ItemType: upgrade.ItemType,
UpgradeFingerprint: `{"lvl":1}`
});
addMods(inventory, [
{
ItemType: upgrade.ItemType,
ItemCount: -1
}
]);
const dataknifeRawUpgradeIndex = dataknifeUpgrades.indexOf(upgrade.ItemType);
if (dataknifeRawUpgradeIndex != -1) {
dataknifeUpgrades[dataknifeRawUpgradeIndex] = id.toString();
} else {
logger.warn(`${upgrade.ItemType} not found in dataknife config`);
}
response.UpgradeIds.push(id.toString());
response.UpgradeTypes.push(upgrade.ItemType);
response.UpgradeFingerprints.push({ lvl: 1 });
response.UpgradeNew.push(true);
}
};
export const getInnateDamageTag = (KillingSuit: string): TInnateDamageTag => {
return ExportWarframes[KillingSuit].nemesisUpgradeTag!;
};

View File

@ -5,7 +5,8 @@ import { getRandomWeightedReward, IRngResult } from "@/src/services/rngService";
import { logger } from "@/src/utils/logger";
import { addMiscItems, combineInventoryChanges } from "@/src/services/inventoryService";
import { handleStoreItemAcquisition } from "@/src/services/purchaseService";
import { IInventoryChanges } from "../types/purchaseTypes";
import { IInventoryChanges } from "@/src/types/purchaseTypes";
import { config } from "@/src/services/configService";
export const crackRelic = async (
inventory: TInventoryDatabaseDocument,
@ -13,12 +14,25 @@ export const crackRelic = async (
inventoryChanges: IInventoryChanges = {}
): Promise<IRngResult> => {
const relic = ExportRelics[participant.VoidProjection];
const weights = refinementToWeights[relic.quality];
let weights = refinementToWeights[relic.quality];
if (relic.quality == "VPQ_SILVER" && config.exceptionalRelicsAlwaysGiveBronzeReward) {
weights = { COMMON: 1, UNCOMMON: 0, RARE: 0, LEGENDARY: 0 };
} else if (relic.quality == "VPQ_GOLD" && config.flawlessRelicsAlwaysGiveSilverReward) {
weights = { COMMON: 0, UNCOMMON: 1, RARE: 0, LEGENDARY: 0 };
} else if (relic.quality == "VPQ_PLATINUM" && config.radiantRelicsAlwaysGiveGoldReward) {
weights = { COMMON: 0, UNCOMMON: 0, RARE: 1, LEGENDARY: 0 };
}
logger.debug(`opening a relic of quality ${relic.quality}; rarity weights are`, weights);
const reward = getRandomWeightedReward(
let reward = getRandomWeightedReward(
ExportRewards[relic.rewardManifest][0] as { type: string; itemCount: number; rarity: TRarity }[], // rarity is nullable in PE+ typings, but always present for relics
weights
)!;
if (config.relicRewardItemCountMultiplier !== undefined && (config.relicRewardItemCountMultiplier ?? 1) != 1) {
reward = {
...reward,
itemCount: reward.itemCount * config.relicRewardItemCountMultiplier
};
}
logger.debug(`relic rolled`, reward);
participant.Reward = reward.type;

View File

@ -1,5 +1,5 @@
import { IUpgrade } from "warframe-public-export-plus";
import { getRandomElement, getRandomInt, getRandomReward } from "../services/rngService";
import { getRandomElement, getRandomInt, getRandomReward } from "@/src/services/rngService";
export type RivenFingerprint = IVeiledRivenFingerprint | IUnveiledRivenFingerprint;

View File

@ -19,10 +19,10 @@ logger.info("Starting up...");
// Proceed with normal startup: bring up config watcher service, validate config, connect to MongoDB, and finally start listening for HTTP.
import mongoose from "mongoose";
import { JSONStringify } from "json-with-bigint";
import { startWebServer } from "./services/webService";
import { startWebServer } from "@/src/services/webService";
import { syncConfigWithDatabase, validateConfig } from "@/src/services/configWatcherService";
import { updateWorldStateCollections } from "./services/worldStateService";
import { updateWorldStateCollections } from "@/src/services/worldStateService";
// Patch JSON.stringify to work flawlessly with Bigints.
JSON.stringify = JSONStringify;

View File

@ -1,5 +1,5 @@
import { NextFunction, Request, Response } from "express";
import { logger } from "../utils/logger";
import { logger } from "@/src/utils/logger";
export const errorHandler = (err: Error, req: Request, res: Response, _next: NextFunction): void => {
if (err.message == "Invalid accountId-nonce pair") {

25
src/models/commonModel.ts Normal file
View File

@ -0,0 +1,25 @@
import { Schema } from "mongoose";
import { IColor, IShipCustomization } from "@/src/types/inventoryTypes/commonInventoryTypes";
export const colorSchema = new Schema<IColor>(
{
t0: Number,
t1: Number,
t2: Number,
t3: Number,
en: Number,
e1: Number,
m0: Number,
m1: Number
},
{ _id: false }
);
export const shipCustomizationSchema = new Schema<IShipCustomization>(
{
SkinFlavourItem: String,
Colors: colorSchema,
ShipAttachments: { HOOD_ORNAMENT: String }
},
{ _id: false }
);

View File

@ -17,8 +17,8 @@ import {
GuildPermission
} from "@/src/types/guildTypes";
import { Document, Model, model, Schema, Types } from "mongoose";
import { fusionTreasuresSchema, typeCountSchema } from "./inventoryModels/inventoryModel";
import { pictureFrameInfoSchema } from "./personalRoomsModel";
import { fusionTreasuresSchema, typeCountSchema } from "@/src/models/inventoryModels/inventoryModel";
import { pictureFrameInfoSchema } from "@/src/models/personalRoomsModel";
const dojoDecoSchema = new Schema<IDojoDecoDatabase>({
Type: String,

View File

@ -1,8 +1,7 @@
import { model, Schema, Types } from "mongoose";
import { toMongoDate, toOid } from "@/src/helpers/inventoryHelpers";
import { typeCountSchema } from "@/src/models/inventoryModels/inventoryModel";
import { IMongoDate, IOid } from "@/src/types/commonTypes";
import { ITypeCount } from "@/src/types/inventoryTypes/inventoryTypes";
import { IMongoDate, IOid, ITypeCount } from "@/src/types/commonTypes";
export interface IMessageClient
extends Omit<IMessageDatabase, "_id" | "date" | "startDate" | "endDate" | "ownerId" | "attVisualOnly" | "expiry"> {
@ -23,7 +22,9 @@ export interface IMessageDatabase extends IMessage {
export interface IMessage {
sndr: string;
msg: string;
cinematic?: string;
sub: string;
customData?: string;
icon?: string;
highPriority?: boolean;
lowPrioNewPlayers?: boolean;
@ -102,7 +103,9 @@ const messageSchema = new Schema<IMessageDatabase>(
ownerId: Schema.Types.ObjectId,
sndr: String,
msg: String,
cinematic: String,
sub: String,
customData: String,
icon: String,
highPriority: Boolean,
lowPrioNewPlayers: Boolean,

View File

@ -1,6 +1,5 @@
import { Document, Model, Schema, Types, model } from "mongoose";
import {
IFlavourItem,
IRawUpgrade,
IMiscItem,
IInventoryDatabase,
@ -10,7 +9,6 @@ import {
IDuviriInfo,
IPendingRecipeDatabase,
IPendingRecipeClient,
ITypeCount,
IFocusXP,
IFocusUpgrade,
ITypeXPItem,
@ -39,25 +37,15 @@ import {
IEvolutionProgress,
IEndlessXpProgressDatabase,
IEndlessXpProgressClient,
ICrewShipCustomization,
ICrewShipWeapon,
ICrewShipWeaponEmplacements,
IShipExterior,
IHelminthFoodRecord,
ICrewShipMembersDatabase,
IDialogueHistoryDatabase,
IDialogueDatabase,
IDialogueGift,
ICompletedDialogue,
IDialogueClient,
IUpgradeDatabase,
ICrewShipMemberDatabase,
ICrewShipMemberClient,
TEquipmentKey,
equipmentKeys,
IKubrowPetDetailsDatabase,
ITraits,
IKubrowPetDetailsClient,
IKubrowPetEggDatabase,
IKubrowPetEggClient,
ICustomMarkers,
@ -96,27 +84,39 @@ import {
IInvasionProgressClient,
IAccolades,
IHubNpcCustomization,
ILotusCustomization,
IEndlessXpReward,
IPersonalGoalProgressDatabase,
IPersonalGoalProgressClient,
IKubrowPetPrintClient,
IKubrowPetPrintDatabase
} from "../../types/inventoryTypes/inventoryTypes";
import { IOid } from "../../types/commonTypes";
} from "@/src/types/inventoryTypes/inventoryTypes";
import { IOid, ITypeCount } from "@/src/types/commonTypes";
import {
IAbilityOverride,
IColor,
ICrewShipCustomization,
IFlavourItem,
IItemConfig,
ILotusCustomization,
IOperatorConfigDatabase,
IPolarity,
IEquipmentDatabase,
IArchonCrystalUpgrade,
IEquipmentClient
IPolarity
} from "@/src/types/inventoryTypes/commonInventoryTypes";
import { toMongoDate, toOid } from "@/src/helpers/inventoryHelpers";
import { EquipmentSelectionSchema, oidSchema } from "./loadoutModel";
import { EquipmentSelectionSchema, oidSchema } from "@/src/models/inventoryModels/loadoutModel";
import { ICountedStoreItem } from "warframe-public-export-plus";
import { colorSchema, shipCustomizationSchema } from "@/src/models/commonModel";
import {
IArchonCrystalUpgrade,
ICrewShipMemberClient,
ICrewShipMemberDatabase,
ICrewShipMembersDatabase,
ICrewShipWeapon,
ICrewShipWeaponEmplacements,
IEquipmentClient,
IEquipmentDatabase,
IKubrowPetDetailsClient,
IKubrowPetDetailsDatabase,
ITraits
} from "@/src/types/equipmentTypes";
export const typeCountSchema = new Schema<ITypeCount>({ ItemType: String, ItemCount: Number }, { _id: false });
@ -166,20 +166,6 @@ const abilityOverrideSchema = new Schema<IAbilityOverride>(
{ _id: false }
);
export const colorSchema = new Schema<IColor>(
{
t0: Number,
t1: Number,
t2: Number,
t3: Number,
en: Number,
e1: Number,
m0: Number,
m1: Number
},
{ _id: false }
);
const operatorConfigSchema = new Schema<IOperatorConfigDatabase>(
{
Skins: [String],
@ -896,18 +882,9 @@ const crewShipWeaponSchema = new Schema<ICrewShipWeapon>(
{ _id: false }
);
const shipExteriorSchema = new Schema<IShipExterior>(
{
SkinFlavourItem: String,
Colors: colorSchema,
ShipAttachments: { HOOD_ORNAMENT: String }
},
{ _id: false }
);
const crewShipCustomizationSchema = new Schema<ICrewShipCustomization>(
{
CrewshipInterior: shipExteriorSchema
CrewshipInterior: shipCustomizationSchema
},
{ _id: false }
);
@ -1239,8 +1216,8 @@ const calenderProgressSchema = new Schema<ICalendarProgress>(
},
SeasonProgress: {
SeasonType: { type: String, required: true },
LastCompletedDayIdx: { type: Number, default: 0 },
LastCompletedChallengeDayIdx: { type: Number, default: 0 },
LastCompletedDayIdx: { type: Number, default: -1 },
LastCompletedChallengeDayIdx: { type: Number, default: -1 },
ActivatedChallenges: { type: [String], default: [] }
}
},

View File

@ -1,5 +1,5 @@
import { IOid } from "@/src/types/commonTypes";
import { IEquipmentSelection } from "@/src/types/inventoryTypes/commonInventoryTypes";
import { IEquipmentSelection } from "@/src/types/equipmentTypes";
import { ILoadoutConfigDatabase, ILoadoutDatabase } from "@/src/types/saveLoadoutTypes";
import { Document, Model, Schema, Types, model } from "mongoose";

View File

@ -1,5 +1,5 @@
import { Document, model, Schema, Types } from "mongoose";
import { ILeaderboardEntryDatabase } from "../types/leaderboardTypes";
import { ILeaderboardEntryDatabase } from "@/src/types/leaderboardTypes";
const leaderboardEntrySchema = new Schema<ILeaderboardEntryDatabase>(
{

View File

@ -1,19 +1,22 @@
import { toMongoDate, toOid } from "@/src/helpers/inventoryHelpers";
import { colorSchema } from "@/src/models/inventoryModels/inventoryModel";
import { IOrbiter, IPersonalRoomsDatabase, PersonalRoomsModelType } from "@/src/types/personalRoomsTypes";
import {
IApartmentDatabase,
IFavouriteLoadoutDatabase,
IGardeningDatabase,
IPlacedDecosDatabase,
IOrbiterClient,
IOrbiterDatabase,
IPersonalRoomsDatabase,
IPictureFrameInfo,
IPlacedDecosDatabase,
IPlantClient,
IPlantDatabase,
IPlanterDatabase,
IRoom,
ITailorShopDatabase,
IApartmentDatabase,
IPlanterDatabase,
IPlantDatabase,
IPlantClient
} from "@/src/types/shipTypes";
PersonalRoomsModelType
} from "@/src/types/personalRoomsTypes";
import { Schema, Types, model } from "mongoose";
import { colorSchema, shipCustomizationSchema } from "@/src/models/commonModel";
export const pictureFrameInfoSchema = new Schema<IPictureFrameInfo>(
{
@ -137,10 +140,11 @@ const apartmentDefault: IApartmentDatabase = {
}
};
const orbiterSchema = new Schema<IOrbiter>(
const orbiterSchema = new Schema<IOrbiterDatabase>(
{
Features: [String],
Rooms: [roomSchema],
ShipInterior: shipCustomizationSchema,
VignetteFish: { type: [String], default: undefined },
FavouriteLoadoutId: Schema.Types.ObjectId,
Wallpaper: String,
@ -150,7 +154,18 @@ const orbiterSchema = new Schema<IOrbiter>(
},
{ _id: false }
);
const orbiterDefault: IOrbiter = {
orbiterSchema.set("toJSON", {
virtuals: true,
transform(_doc, obj) {
const db = obj as IOrbiterDatabase;
const client = obj as IOrbiterClient;
if (db.FavouriteLoadoutId) {
client.FavouriteLoadoutId = toOid(db.FavouriteLoadoutId);
}
}
});
const orbiterDefault: IOrbiterDatabase = {
Features: ["/Lotus/Types/Items/ShipFeatureItems/EarthNavigationFeatureItem"], //TODO: potentially remove after missionstarting gear
Rooms: [
{ Name: "AlchemyRoom", MaxCapacity: 1600 },
@ -197,7 +212,6 @@ const tailorShopDefault: ITailorShopDatabase = {
export const personalRoomsSchema = new Schema<IPersonalRoomsDatabase>({
personalRoomsOwnerId: Schema.Types.ObjectId,
activeShipId: Schema.Types.ObjectId,
ShipInteriorColors: colorSchema,
Ship: { type: orbiterSchema, default: orbiterDefault },
Apartment: { type: apartmentSchema, default: apartmentDefault },
TailorShop: { type: tailorShopSchema, default: tailorShopDefault }

View File

@ -1,7 +1,7 @@
import { Document, Schema, Types, model } from "mongoose";
import { IShipDatabase } from "../types/shipTypes";
import { IShipDatabase } from "@/src/types/shipTypes";
import { toOid } from "@/src/helpers/inventoryHelpers";
import { colorSchema } from "@/src/models/inventoryModels/inventoryModel";
import { colorSchema } from "@/src/models/commonModel";
import { IShipInventory } from "@/src/types/inventoryTypes/inventoryTypes";
const shipSchema = new Schema<IShipDatabase>(

View File

@ -112,6 +112,7 @@ import { removeFromGuildController } from "@/src/controllers/api/removeFromGuild
import { removeIgnoredUserController } from "@/src/controllers/api/removeIgnoredUserController";
import { renamePetController } from "@/src/controllers/api/renamePetController";
import { rerollRandomModController } from "@/src/controllers/api/rerollRandomModController";
import { resetQuestProgressController } from "@/src/controllers/api/resetQuestProgressController";
import { retrievePetFromStasisController } from "@/src/controllers/api/retrievePetFromStasisController";
import { saveDialogueController } from "@/src/controllers/api/saveDialogueController";
import { saveLoadoutController } from "@/src/controllers/api/saveLoadoutController";
@ -209,6 +210,7 @@ apiRouter.get("/questControl.php", questControlController);
apiRouter.get("/queueDojoComponentDestruction.php", queueDojoComponentDestructionController);
apiRouter.get("/removeFriend.php", removeFriendGetController);
apiRouter.get("/removeFromAlliance.php", removeFromAllianceController);
apiRouter.get("/resetQuestProgress.php", resetQuestProgressController);
apiRouter.get("/setActiveQuest.php", setActiveQuestController);
apiRouter.get("/setActiveShip.php", setActiveShipController);
apiRouter.get("/setAllianceGuildPermissions.php", setAllianceGuildPermissionsController);

View File

@ -64,9 +64,13 @@ export interface IConfig {
noDojoResearchTime?: boolean;
fastClanAscension?: boolean;
missionsCanGiveAllRelics?: boolean;
exceptionalRelicsAlwaysGiveBronzeReward?: boolean;
flawlessRelicsAlwaysGiveSilverReward?: boolean;
radiantRelicsAlwaysGiveGoldReward?: boolean;
unlockAllSimarisResearchEntries?: boolean;
disableDailyTribute?: boolean;
spoofMasteryRank?: number;
relicRewardItemCountMultiplier?: number;
nightwaveStandingMultiplier?: number;
unfaithfulBugFixes?: {
ignore1999LastRegionPlayed?: boolean;
@ -85,6 +89,8 @@ export interface IConfig {
allTheFissures?: string;
circuitGameModes?: string[];
darvoStockMultiplier?: number;
varziaOverride?: string;
varziaFullyStocked?: boolean;
};
dev?: {
keepVendorsExpired?: boolean;

View File

@ -1,15 +1,14 @@
import chokidar from "chokidar";
import fsPromises from "fs/promises";
import { logger } from "../utils/logger";
import { config, configPath, loadConfig } from "./configService";
import { getWebPorts, sendWsBroadcast, startWebServer, stopWebServer } from "./webService";
import { Inbox } from "../models/inboxModel";
import { logger } from "@/src/utils/logger";
import { config, configPath, loadConfig } from "@/src/services/configService";
import { saveConfig, shouldReloadConfig } from "@/src/services/configWriterService";
import { getWebPorts, startWebServer, stopWebServer } from "@/src/services/webService";
import { sendWsBroadcast } from "@/src/services/wsService";
import { Inbox } from "@/src/models/inboxModel";
import varzia from "@/static/fixed_responses/worldState/varzia.json";
let amnesia = false;
chokidar.watch(configPath).on("change", () => {
if (amnesia) {
amnesia = false;
} else {
if (shouldReloadConfig()) {
logger.info("Detected a change to config file, reloading its contents.");
try {
loadConfig();
@ -57,17 +56,19 @@ export const validateConfig = (): void => {
config.worldState.galleonOfGhouls = 0;
modified = true;
}
if (
config.worldState?.varziaOverride &&
!varzia.primeDualPacks.some(p => p.ItemType === config.worldState?.varziaOverride)
) {
config.worldState.varziaOverride = "";
modified = true;
}
if (modified) {
logger.info(`Updating config file to fix some issues with it.`);
void saveConfig();
}
};
export const saveConfig = async (): Promise<void> => {
amnesia = true;
await fsPromises.writeFile(configPath, JSON.stringify(config, null, 2));
};
export const syncConfigWithDatabase = (): void => {
// Event messages are deleted after endDate. Since we don't use beginDate/endDate and instead have config toggles, we need to delete the messages once those bools are false.
if (!config.worldState?.galleonOfGhouls) {

View File

@ -0,0 +1,17 @@
import fsPromises from "fs/promises";
import { config, configPath } from "@/src/services/configService";
let amnesia = false;
export const saveConfig = async (): Promise<void> => {
amnesia = true;
await fsPromises.writeFile(configPath, JSON.stringify(config, null, 2));
};
export const shouldReloadConfig = (): boolean => {
if (amnesia) {
amnesia = false;
return false;
}
return true;
};

View File

@ -1,10 +1,10 @@
import { IFriendInfo } from "../types/friendTypes";
import { getInventory } from "./inventoryService";
import { config } from "./configService";
import { Account } from "../models/loginModel";
import { IFriendInfo } from "@/src/types/friendTypes";
import { getInventory } from "@/src/services/inventoryService";
import { config } from "@/src/services/configService";
import { Account } from "@/src/models/loginModel";
import { Types } from "mongoose";
import { Friendship } from "../models/friendModel";
import { fromOid, toMongoDate } from "../helpers/inventoryHelpers";
import { Friendship } from "@/src/models/friendModel";
import { fromOid, toMongoDate } from "@/src/helpers/inventoryHelpers";
export const addAccountDataToFriendInfo = async (info: IFriendInfo): Promise<void> => {
const account = (await Account.findById(fromOid(info._id), "DisplayName LastLogin"))!;

View File

@ -22,16 +22,17 @@ import {
import { toMongoDate, toOid, toOid2 } from "@/src/helpers/inventoryHelpers";
import { Types } from "mongoose";
import { ExportDojoRecipes, ExportResources, IDojoBuild, IDojoResearch } from "warframe-public-export-plus";
import { logger } from "../utils/logger";
import { config } from "./configService";
import { getRandomInt } from "./rngService";
import { Inbox } from "../models/inboxModel";
import { IFusionTreasure, ITypeCount } from "../types/inventoryTypes/inventoryTypes";
import { IInventoryChanges } from "../types/purchaseTypes";
import { parallelForeach } from "../utils/async-utils";
import { logger } from "@/src/utils/logger";
import { config } from "@/src/services/configService";
import { getRandomInt } from "@/src/services/rngService";
import { Inbox } from "@/src/models/inboxModel";
import { IFusionTreasure } from "@/src/types/inventoryTypes/inventoryTypes";
import { IInventoryChanges } from "@/src/types/purchaseTypes";
import { parallelForeach } from "@/src/utils/async-utils";
import allDecoRecipes from "@/static/fixed_responses/allDecoRecipes.json";
import { createMessage } from "./inboxService";
import { addAccountDataToFriendInfo, addInventoryDataToFriendInfo } from "./friendService";
import { createMessage } from "@/src/services/inboxService";
import { addAccountDataToFriendInfo, addInventoryDataToFriendInfo } from "@/src/services/friendService";
import { ITypeCount } from "@/src/types/commonTypes";
export const getGuildForRequest = async (req: Request): Promise<TGuildDatabaseDocument> => {
const accountId = await getAccountIdForRequest(req);
@ -550,6 +551,19 @@ export const processFundedGuildTechProject = (
guild.XP += recipe.guildXpValue;
}
setGuildTechLogState(guild, techProject.ItemType, config.noDojoResearchTime ? 4 : 3, techProject.CompletionDate);
if (config.noDojoResearchTime) {
processCompletedGuildTechProject(guild, techProject.ItemType);
}
};
export const processCompletedGuildTechProject = (guild: TGuildDatabaseDocument, type: string): void => {
if (type.startsWith("/Lotus/Levels/ClanDojo/ComponentPropRecipes/NpcPlaceables/")) {
guild.VaultDecoRecipes ??= [];
guild.VaultDecoRecipes.push({
ItemType: type,
ItemCount: 1
});
}
};
export const setGuildTechLogState = (

View File

@ -1,18 +1,12 @@
import { Types } from "mongoose";
import {
IEquipmentClient,
IEquipmentDatabase,
IItemConfig,
IOperatorConfigClient,
IOperatorConfigDatabase
} from "../types/inventoryTypes/commonInventoryTypes";
import { IMongoDate } from "../types/commonTypes";
} from "@/src/types/inventoryTypes/commonInventoryTypes";
import { IMongoDate } from "@/src/types/commonTypes";
import {
equipmentKeys,
ICrewShipMemberClient,
ICrewShipMemberDatabase,
ICrewShipMembersClient,
ICrewShipMembersDatabase,
IDialogueClient,
IDialogueDatabase,
IDialogueHistoryClient,
@ -20,10 +14,6 @@ import {
IInfestedFoundryClient,
IInfestedFoundryDatabase,
IInventoryClient,
IKubrowPetDetailsClient,
IKubrowPetDetailsDatabase,
ILoadoutConfigClient,
ILoadOutPresets,
INemesisClient,
INemesisDatabase,
IPendingRecipeClient,
@ -35,10 +25,25 @@ import {
IUpgradeDatabase,
IWeaponSkinClient,
IWeaponSkinDatabase
} from "../types/inventoryTypes/inventoryTypes";
import { TInventoryDatabaseDocument } from "../models/inventoryModels/inventoryModel";
import { ILoadoutConfigDatabase, ILoadoutDatabase } from "../types/saveLoadoutTypes";
import { slotNames } from "../types/purchaseTypes";
} from "@/src/types/inventoryTypes/inventoryTypes";
import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel";
import {
ILoadoutConfigClient,
ILoadoutConfigDatabase,
ILoadoutDatabase,
ILoadOutPresets
} from "@/src/types/saveLoadoutTypes";
import { slotNames } from "@/src/types/purchaseTypes";
import {
ICrewShipMemberClient,
ICrewShipMemberDatabase,
ICrewShipMembersClient,
ICrewShipMembersDatabase,
IEquipmentClient,
IEquipmentDatabase,
IKubrowPetDetailsClient,
IKubrowPetDetailsDatabase
} from "@/src/types/equipmentTypes";
const convertDate = (value: IMongoDate): Date => {
return new Date(parseInt(value.$date.$numberLong));

View File

@ -2,8 +2,8 @@ import { IMessageDatabase, Inbox } from "@/src/models/inboxModel";
import { getAccountForRequest } from "@/src/services/loginService";
import { HydratedDocument, Types } from "mongoose";
import { Request } from "express";
import { unixTimesInMs } from "../constants/timeConstants";
import { config } from "./configService";
import { unixTimesInMs } from "@/src/constants/timeConstants";
import { config } from "@/src/services/configService";
export const getAllMessagesSorted = async (accountId: string): Promise<HydratedDocument<IMessageDatabase>[]> => {
const inbox = await Inbox.find({ ownerId: accountId }).sort({ date: -1 });

View File

@ -1,8 +1,9 @@
import { ExportRecipes } from "warframe-public-export-plus";
import { TInventoryDatabaseDocument } from "../models/inventoryModels/inventoryModel";
import { IInfestedFoundryClient, IInfestedFoundryDatabase, ITypeCount } from "../types/inventoryTypes/inventoryTypes";
import { addRecipes } from "./inventoryService";
import { config } from "./configService";
import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel";
import { IInfestedFoundryClient, IInfestedFoundryDatabase } from "@/src/types/inventoryTypes/inventoryTypes";
import { addRecipes } from "@/src/services/inventoryService";
import { config } from "@/src/services/configService";
import { ITypeCount } from "@/src/types/commonTypes";
export const addInfestedFoundryXP = (infestedFoundry: IInfestedFoundryDatabase, delta: number): ITypeCount[] => {
const recipeChanges: ITypeCount[] = [];

View File

@ -4,12 +4,10 @@ import { Types } from "mongoose";
import { SlotNames, IInventoryChanges, IBinChanges, slotNames, IAffiliationMods } from "@/src/types/purchaseTypes";
import {
IChallengeProgress,
IFlavourItem,
IMiscItem,
IMission,
IRawUpgrade,
ISeasonChallenge,
ITypeCount,
InventorySlot,
IWeaponSkinClient,
TEquipmentKey,
@ -23,25 +21,17 @@ import {
TPartialStartingGear,
ILoreFragmentScan,
ICrewMemberClient,
Status,
IKubrowPetDetailsDatabase,
ITraits,
ICalendarProgress,
INemesisWeaponTargetFingerprint,
INemesisPetTargetFingerprint,
IDialogueDatabase,
IKubrowPetPrintClient
} from "@/src/types/inventoryTypes/inventoryTypes";
import { IGenericUpdate, IUpdateNodeIntrosResponse } from "../types/genericUpdate";
import { IKeyChainRequest, IMissionInventoryUpdateRequest } from "../types/requestTypes";
import { IGenericUpdate, IUpdateNodeIntrosResponse } from "@/src/types/genericUpdate";
import { IKeyChainRequest, IMissionInventoryUpdateRequest } from "@/src/types/requestTypes";
import { logger } from "@/src/utils/logger";
import { convertInboxMessage, fromStoreItem, getKeyChainItems } from "@/src/services/itemDataService";
import {
EquipmentFeatures,
IEquipmentClient,
IEquipmentDatabase,
IItemConfig
} from "../types/inventoryTypes/commonInventoryTypes";
import { IFlavourItem, IItemConfig } from "@/src/types/inventoryTypes/commonInventoryTypes";
import {
ExportArcanes,
ExportBoosters,
@ -69,7 +59,7 @@ import {
ISentinel,
TStandingLimitBin
} from "warframe-public-export-plus";
import { createShip } from "./shipService";
import { createShip } from "@/src/services/shipService";
import {
catbrowDetails,
fromMongoDate,
@ -77,20 +67,36 @@ import {
kubrowDetails,
kubrowFurPatternsWeights,
kubrowWeights,
toOid
} from "../helpers/inventoryHelpers";
toOid,
TTraitsPool
} from "@/src/helpers/inventoryHelpers";
import { addQuestKey, completeQuest } from "@/src/services/questService";
import { handleBundleAcqusition } from "./purchaseService";
import { handleBundleAcqusition } from "@/src/services/purchaseService";
import libraryDailyTasks from "@/static/fixed_responses/libraryDailyTasks.json";
import { getRandomElement, getRandomInt, getRandomWeightedReward, SRng } from "./rngService";
import { createMessage } from "./inboxService";
import {
generateRewardSeed,
getRandomElement,
getRandomInt,
getRandomWeightedReward,
SRng
} from "@/src/services/rngService";
import { createMessage, IMessageCreationTemplate } from "@/src/services/inboxService";
import { getMaxStanding, getMinStanding } from "@/src/helpers/syndicateStandingHelper";
import { getNightwaveSyndicateTag, getWorldState } from "./worldStateService";
import { getNightwaveSyndicateTag, getWorldState } from "@/src/services/worldStateService";
import { ICalendarSeason } from "@/src/types/worldStateTypes";
import { generateNemesisProfile, INemesisProfile } from "../helpers/nemesisHelpers";
import { TAccountDocument } from "./loginService";
import { unixTimesInMs } from "../constants/timeConstants";
import { addString } from "../helpers/stringHelpers";
import { generateNemesisProfile, INemesisProfile } from "@/src/helpers/nemesisHelpers";
import { TAccountDocument } from "@/src/services/loginService";
import { unixTimesInMs } from "@/src/constants/timeConstants";
import { addString } from "@/src/helpers/stringHelpers";
import {
EquipmentFeatures,
IEquipmentClient,
IEquipmentDatabase,
IKubrowPetDetailsDatabase,
ITraits,
Status
} from "@/src/types/equipmentTypes";
import { ITypeCount } from "@/src/types/commonTypes";
export const createInventory = async (
accountOwnerId: Types.ObjectId,
@ -132,17 +138,6 @@ export const createInventory = async (
}
};
export const generateRewardSeed = (): bigint => {
const hiDword = getRandomInt(0, 0x7fffffff);
const loDword = getRandomInt(0, 0xffffffff);
let seed = (BigInt(hiDword) << 32n) | BigInt(loDword);
if (Math.random() < 0.5) {
seed *= -1n;
seed -= 1n;
}
return seed;
};
//TODO: RawUpgrades might need to return a LastAdded
const awakeningRewards = [
"/Lotus/Types/StoreItems/AvatarImages/AvatarImageItem1",
@ -483,6 +478,19 @@ export const addItem = async (
return addCustomization(inventory, typeName);
}
if (typeName in ExportUpgrades || typeName in ExportArcanes) {
if (targetFingerprint) {
if (quantity != 1) {
logger.warn(`adding 1 of ${typeName} ${targetFingerprint} even tho quantity ${quantity} was requested`);
}
const upgrade =
inventory.Upgrades[
inventory.Upgrades.push({
ItemType: typeName,
UpgradeFingerprint: targetFingerprint
}) - 1
];
return { Upgrades: [upgrade.toJSON<IUpgradeClient>()] };
}
const changes = [
{
ItemType: typeName,
@ -807,7 +815,7 @@ export const addItem = async (
if (!seed) {
throw new Error(`Expected crew member to have a seed`);
}
seed |= 0x33b81en << 32n;
seed |= BigInt(Math.trunc(inventory.Created.getTime() / 1000) & 0xffffff) << 32n;
return {
...addCrewMember(inventory, typeName, seed),
...occupySlot(inventory, InventorySlot.CREWMEMBERS, premiumPurchase)
@ -1044,6 +1052,21 @@ export const addSpaceSuit = (
return inventoryChanges;
};
const createRandomTraits = (kubrowPetName: string, traitsPool: TTraitsPool): ITraits => {
return {
BaseColor: getRandomWeightedReward(traitsPool.Colors, kubrowWeights)!.type,
SecondaryColor: getRandomWeightedReward(traitsPool.Colors, kubrowWeights)!.type,
TertiaryColor: getRandomWeightedReward(traitsPool.Colors, kubrowWeights)!.type,
AccentColor: getRandomWeightedReward(traitsPool.Colors, kubrowWeights)!.type,
EyeColor: getRandomWeightedReward(traitsPool.EyeColors, kubrowWeights)!.type,
FurPattern: getRandomWeightedReward(traitsPool.FurPatterns, kubrowFurPatternsWeights)!.type,
Personality: kubrowPetName,
BodyType: getRandomWeightedReward(traitsPool.BodyTypes, kubrowWeights)!.type,
Head: traitsPool.Heads.length ? getRandomWeightedReward(traitsPool.Heads, kubrowWeights)!.type : undefined,
Tail: traitsPool.Tails.length ? getRandomWeightedReward(traitsPool.Tails, kubrowWeights)!.type : undefined
};
};
export const addKubrowPet = (
inventory: TInventoryDatabaseDocument,
kubrowPetName: string,
@ -1060,7 +1083,6 @@ export const addKubrowPet = (
addSpecialItem(inventory, specialItem, inventoryChanges);
}
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
const configs: IItemConfig[] = applyDefaultUpgrades(inventory, kubrowPet?.defaultUpgrades);
if (!details) {
@ -1070,9 +1092,10 @@ export const addKubrowPet = (
"/Lotus/Types/Game/CatbrowPet/VampireCatbrowPetPowerSuit"
].includes(kubrowPetName);
let traits: ITraits;
const traitsPool = isCatbrow ? catbrowDetails : kubrowDetails;
let dominantTraits: ITraits;
if (kubrowPetName == "/Lotus/Types/Game/CatbrowPet/VampireCatbrowPetPowerSuit") {
traits = {
dominantTraits = {
BaseColor: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorBaseVampire",
SecondaryColor: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorSecondaryVampire",
TertiaryColor: "/Lotus/Types/Game/CatbrowPet/Colors/CatbrowPetColorTertiaryVampire",
@ -1085,19 +1108,35 @@ export const addKubrowPet = (
Tail: "/Lotus/Types/Game/CatbrowPet/Tails/CatbrowTailVampire"
};
} else {
const traitsPool = isCatbrow ? catbrowDetails : kubrowDetails;
traits = {
BaseColor: getRandomWeightedReward(traitsPool.Colors, kubrowWeights)!.type,
SecondaryColor: getRandomWeightedReward(traitsPool.Colors, kubrowWeights)!.type,
TertiaryColor: getRandomWeightedReward(traitsPool.Colors, kubrowWeights)!.type,
AccentColor: getRandomWeightedReward(traitsPool.Colors, kubrowWeights)!.type,
EyeColor: getRandomWeightedReward(traitsPool.EyeColors, kubrowWeights)!.type,
FurPattern: getRandomWeightedReward(traitsPool.FurPatterns, kubrowFurPatternsWeights)!.type,
Personality: kubrowPetName,
BodyType: getRandomWeightedReward(traitsPool.BodyTypes, kubrowWeights)!.type,
Head: isCatbrow ? getRandomWeightedReward(traitsPool.Heads, kubrowWeights)!.type : undefined,
Tail: isCatbrow ? getRandomWeightedReward(traitsPool.Tails, kubrowWeights)!.type : undefined
};
dominantTraits = createRandomTraits(kubrowPetName, traitsPool);
if (kubrowPetName == "/Lotus/Types/Game/KubrowPet/ChargerKubrowPetPowerSuit") {
dominantTraits.BodyType = "/Lotus/Types/Game/KubrowPet/BodyTypes/ChargerKubrowPetBodyType";
dominantTraits.FurPattern = "/Lotus/Types/Game/KubrowPet/Patterns/KubrowPetPatternInfested";
}
}
const recessiveTraits: ITraits = createRandomTraits(
getRandomElement(
isCatbrow
? [
"/Lotus/Types/Game/CatbrowPet/MirrorCatbrowPetPowerSuit",
"/Lotus/Types/Game/CatbrowPet/CheshireCatbrowPetPowerSuit"
]
: [
"/Lotus/Types/Game/KubrowPet/AdventurerKubrowPetPowerSuit",
"/Lotus/Types/Game/KubrowPet/FurtiveKubrowPetPowerSuit",
"/Lotus/Types/Game/KubrowPet/GuardKubrowPetPowerSuit",
"/Lotus/Types/Game/KubrowPet/HunterKubrowPetPowerSuit",
"/Lotus/Types/Game/KubrowPet/RetrieverKubrowPetPowerSuit"
]
)!,
traitsPool
);
for (const key of Object.keys(recessiveTraits) as (keyof ITraits)[]) {
// My heurstic approximation is a 20% chance for a dominant trait to be copied into the recessive traits. TODO: A more scientific statistical analysis maybe?
if (Math.random() < 0.2) {
recessiveTraits[key] = dominantTraits[key]!;
}
}
details = {
@ -1109,8 +1148,8 @@ export const addKubrowPet = (
HatchDate: premiumPurchase ? new Date() : new Date(Date.now() + 10 * unixTimesInMs.hour), // On live, this seems to be somewhat randomised so that the pet hatches 9~11 hours after start.
IsMale: !!getRandomInt(0, 1),
Size: getRandomInt(70, 100) / 100,
DominantTraits: traits,
RecessiveTraits: traits
DominantTraits: dominantTraits,
RecessiveTraits: recessiveTraits
};
}
@ -1256,8 +1295,8 @@ export const addStanding = (
const max = getMaxStanding(syndicateMeta, syndicate.Title ?? 0);
if (syndicate.Standing + gainedStanding > max) gainedStanding = max - syndicate.Standing;
if (syndicate.Title == -2 && syndicate.Standing + gainedStanding < -71000) {
gainedStanding = -71000 + syndicate.Standing;
if (syndicate.Standing + gainedStanding < -71000) {
gainedStanding = -71000 - syndicate.Standing;
}
if (!isMedallion || syndicateMeta.medallionsCappedByDailyLimit) {
@ -1385,7 +1424,11 @@ export const addSkin = (
if (inventory.WeaponSkins.some(x => x.ItemType == typeName)) {
logger.debug(`refusing to add WeaponSkin ${typeName} because account already owns it`);
} else {
const index = inventory.WeaponSkins.push({ ItemType: typeName, IsNew: true }) - 1;
const index =
inventory.WeaponSkins.push({
ItemType: typeName,
IsNew: typeName.startsWith("/Lotus/Upgrades/Skins/RailJack/") ? undefined : true // railjack skins are incompatible with this flag
}) - 1;
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
inventoryChanges.WeaponSkins ??= [];
(inventoryChanges.WeaponSkins as IWeaponSkinClient[]).push(
@ -1563,7 +1606,22 @@ export const addEmailItem = async (
const meta = ExportEmailItems[typeName];
const emailItem = inventory.EmailItems.find(x => x.ItemType == typeName);
if (!emailItem || !meta.sendOnlyOnce) {
await createMessage(inventory.accountOwnerId, [convertInboxMessage(meta.message)]);
const msg: IMessageCreationTemplate = convertInboxMessage(meta.message);
if (msg.cinematic == "/Lotus/Levels/1999/PlayerHomeBalconyCinematics.level") {
msg.customData = JSON.stringify({
Tag: msg.customData + "KissCin",
CinLoadout: {
Skins: inventory.AdultOperatorLoadOuts[0].Skins,
Upgrades: inventory.AdultOperatorLoadOuts[0].Upgrades,
attcol: inventory.AdultOperatorLoadOuts[0].attcol,
cloth: inventory.AdultOperatorLoadOuts[0].cloth,
eyecol: inventory.AdultOperatorLoadOuts[0].eyecol,
pricol: inventory.AdultOperatorLoadOuts[0].pricol,
syancol: inventory.AdultOperatorLoadOuts[0].syancol
}
});
}
await createMessage(inventory.accountOwnerId, [msg]);
if (emailItem) {
emailItem.ItemCount += 1;
@ -1577,6 +1635,15 @@ export const addEmailItem = async (
return inventoryChanges;
};
const xpEarningParts: readonly string[] = [
"LWPT_BLADE",
"LWPT_GUN_BARREL",
"LWPT_AMP_OCULUS",
"LWPT_MOA_HEAD",
"LWPT_ZANUKA_HEAD",
"LWPT_HB_DECK"
];
export const applyClientEquipmentUpdates = (
inventory: TInventoryDatabaseDocument,
gearArray: IEquipmentClient[],
@ -1595,13 +1662,26 @@ export const applyClientEquipmentUpdates = (
item.XP ??= 0;
item.XP += XP;
const xpinfoIndex = inventory.XPInfo.findIndex(x => x.ItemType == item.ItemType);
let xpItemType = item.ItemType;
if (item.ModularParts) {
for (const part of item.ModularParts) {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
const partType = ExportWeapons[part]?.partType;
if (partType !== undefined && xpEarningParts.indexOf(partType) != -1) {
xpItemType = part;
break;
}
}
logger.debug(`adding xp to ${xpItemType} for modular item ${fromOid(ItemId)} (${item.ItemType})`);
}
const xpinfoIndex = inventory.XPInfo.findIndex(x => x.ItemType == xpItemType);
if (xpinfoIndex !== -1) {
const xpinfo = inventory.XPInfo[xpinfoIndex];
xpinfo.XP += XP;
} else {
inventory.XPInfo.push({
ItemType: item.ItemType,
ItemType: xpItemType,
XP: XP
});
}
@ -1874,7 +1954,7 @@ export const addCalendarProgress = (inventory: TInventoryDatabaseDocument, value
calendarProgress.SeasonProgress.LastCompletedChallengeDayIdx = currentSeason.Days.findIndex(
day => day.events.length != 0 && day.events[0].challenge == value[value.length - 1].challenge
);
checkCalendarChallengeCompletion(calendarProgress, currentSeason);
checkCalendarAutoAdvance(inventory, currentSeason);
};
export const addMissionComplete = (inventory: TInventoryDatabaseDocument, { Tag, Completes, Tier }: IMission): void => {
@ -2059,8 +2139,8 @@ export const getCalendarProgress = (inventory: TInventoryDatabaseDocument): ICal
},
SeasonProgress: {
SeasonType: currentSeason.Season,
LastCompletedDayIdx: 0,
LastCompletedChallengeDayIdx: 0,
LastCompletedDayIdx: -1,
LastCompletedChallengeDayIdx: -1,
ActivatedChallenges: []
}
};
@ -2081,16 +2161,44 @@ export const getCalendarProgress = (inventory: TInventoryDatabaseDocument): ICal
return inventory.CalendarProgress;
};
export const checkCalendarChallengeCompletion = (
calendarProgress: ICalendarProgress,
export const checkCalendarAutoAdvance = (
inventory: TInventoryDatabaseDocument,
currentSeason: ICalendarSeason
): void => {
const dayIndex = calendarProgress.SeasonProgress.LastCompletedDayIdx + 1;
if (calendarProgress.SeasonProgress.LastCompletedChallengeDayIdx >= dayIndex) {
const calendarProgress = inventory.CalendarProgress!;
for (
let dayIndex = calendarProgress.SeasonProgress.LastCompletedDayIdx + 1;
dayIndex != currentSeason.Days.length;
++dayIndex
) {
const day = currentSeason.Days[dayIndex];
if (day.events.length != 0 && day.events[0].type == "CET_CHALLENGE") {
if (day.events.length == 0) {
// birthday
if (day.day == 1) {
// kaya
if ((inventory.Affiliations.find(x => x.Tag == "HexSyndicate")?.Title || 0) >= 4) {
break;
}
logger.debug(`cannot talk to kaya, skipping birthday`);
calendarProgress.SeasonProgress.LastCompletedDayIdx++;
} else if (day.day == 74 || day.day == 355) {
// minerva, velimir
if ((inventory.Affiliations.find(x => x.Tag == "HexSyndicate")?.Title || 0) >= 5) {
break;
}
logger.debug(`cannot talk to minerva/velimir, skipping birthday`);
calendarProgress.SeasonProgress.LastCompletedDayIdx++;
} else {
break;
}
} else if (day.events[0].type == "CET_CHALLENGE") {
if (calendarProgress.SeasonProgress.LastCompletedChallengeDayIdx < dayIndex) {
break;
}
//logger.debug(`already completed the challenge, skipping ahead`);
calendarProgress.SeasonProgress.LastCompletedDayIdx++;
} else {
break;
}
}
};

View File

@ -17,6 +17,7 @@ import {
dict_zh,
ExportArcanes,
ExportBoosters,
ExportBundles,
ExportCustoms,
ExportDrones,
ExportGear,
@ -32,7 +33,7 @@ import {
IRecipe,
TReward
} from "warframe-public-export-plus";
import { IMessage } from "../models/inboxModel";
import { IMessage } from "@/src/models/inboxModel";
export type WeaponTypeInternal =
| "LongGuns"
@ -45,6 +46,39 @@ export type WeaponTypeInternal =
| "SpecialItems";
export const getRecipe = (uniqueName: string): IRecipe | undefined => {
// Handle crafting of archwing summon for versions prior to 39.0.0 as this blueprint was removed then.
if (uniqueName == "/Lotus/Types/Recipes/EidolonRecipes/OpenArchwingSummonBlueprint") {
return {
resultType: "/Lotus/Types/Restoratives/OpenArchwingSummon",
buildPrice: 7500,
buildTime: 1800,
skipBuildTimePrice: 10,
consumeOnUse: false,
num: 1,
codexSecret: false,
alwaysAvailable: true,
ingredients: [
{
ItemType: "/Lotus/Types/Gameplay/Eidolon/Resources/IraditeItem",
ItemCount: 50
},
{
ItemType: "/Lotus/Types/Gameplay/Eidolon/Resources/GrokdrulItem",
ItemCount: 50
},
{
ItemType: "/Lotus/Types/Items/Fish/Eidolon/FishParts/EidolonFishOilItem",
ItemCount: 30
},
{
ItemType: "/Lotus/Types/Items/MiscItems/Circuits",
ItemCount: 600
}
],
excludeFromMarket: true
};
}
return ExportRecipes[uniqueName];
};
@ -84,6 +118,9 @@ export const getItemName = (uniqueName: string): string | undefined => {
if (uniqueName in ExportArcanes) {
return ExportArcanes[uniqueName].name;
}
if (uniqueName in ExportBundles) {
return ExportBundles[uniqueName].name;
}
if (uniqueName in ExportCustoms) {
return ExportCustoms[uniqueName].name;
}
@ -218,7 +255,9 @@ export const convertInboxMessage = (message: IInboxMessage): IMessage => {
return {
sndr: message.sender,
msg: message.body,
cinematic: message.cinematic,
sub: message.title,
customData: message.customData,
att: message.attachments.length > 0 ? message.attachments : undefined,
countedAtt: message.countedAttachments.length > 0 ? message.countedAttachments : undefined,
icon: message.icon ?? "",

View File

@ -1,6 +1,6 @@
import { Guild } from "../models/guildModel";
import { Leaderboard, TLeaderboardEntryDocument } from "../models/leaderboardModel";
import { ILeaderboardEntryClient } from "../types/leaderboardTypes";
import { Guild } from "@/src/models/guildModel";
import { Leaderboard, TLeaderboardEntryDocument } from "@/src/models/leaderboardModel";
import { ILeaderboardEntryClient } from "@/src/types/leaderboardTypes";
export const submitLeaderboardScore = async (
schedule: "weekly" | "daily",

View File

@ -1,10 +1,10 @@
import randomRewards from "@/static/fixed_responses/loginRewards/randomRewards.json";
import { IInventoryChanges } from "../types/purchaseTypes";
import { TAccountDocument } from "./loginService";
import { mixSeeds, SRng } from "./rngService";
import { TInventoryDatabaseDocument } from "../models/inventoryModels/inventoryModel";
import { addBooster, updateCurrency } from "./inventoryService";
import { handleStoreItemAcquisition } from "./purchaseService";
import { IInventoryChanges } from "@/src/types/purchaseTypes";
import { TAccountDocument } from "@/src/services/loginService";
import { mixSeeds, SRng } from "@/src/services/rngService";
import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel";
import { addBooster, updateCurrency } from "@/src/services/inventoryService";
import { handleStoreItemAcquisition } from "@/src/services/purchaseService";
import {
ExportBoosterPacks,
ExportBoosters,
@ -12,7 +12,7 @@ import {
ExportWarframes,
ExportWeapons
} from "warframe-public-export-plus";
import { toStoreItem } from "./itemDataService";
import { toStoreItem } from "@/src/services/itemDataService";
export interface ILoginRewardsReponse {
DailyTributeInfo: {

View File

@ -1,7 +1,7 @@
import { Account } from "@/src/models/loginModel";
import { createInventory } from "@/src/services/inventoryService";
import { IDatabaseAccountJson, IDatabaseAccountRequiredFields } from "@/src/types/loginTypes";
import { createShip } from "./shipService";
import { createShip } from "@/src/services/shipService";
import { Document, Types } from "mongoose";
import { Loadout } from "@/src/models/inventoryModels/loadoutModel";
import { PersonalRooms } from "@/src/models/personalRoomsModel";

View File

@ -8,10 +8,10 @@ import {
IRegion,
IReward
} from "warframe-public-export-plus";
import { IMissionInventoryUpdateRequest, IRewardInfo } from "../types/requestTypes";
import { IMissionInventoryUpdateRequest, IRewardInfo } from "@/src/types/requestTypes";
import { logger } from "@/src/utils/logger";
import { IRngResult, SRng, getRandomElement, getRandomReward } from "@/src/services/rngService";
import { equipmentKeys, IMission, ITypeCount, TEquipmentKey } from "@/src/types/inventoryTypes/inventoryTypes";
import { IRngResult, SRng, generateRewardSeed, getRandomElement, getRandomReward } from "@/src/services/rngService";
import { equipmentKeys, IMission, TEquipmentKey } from "@/src/types/inventoryTypes/inventoryTypes";
import {
addBooster,
addCalendarProgress,
@ -35,7 +35,6 @@ import {
addStanding,
applyClientEquipmentUpdates,
combineInventoryChanges,
generateRewardSeed,
getDialogue,
giveNemesisPetRecipe,
giveNemesisWeaponRecipe,
@ -48,11 +47,10 @@ import { IAffiliationMods, IInventoryChanges } from "@/src/types/purchaseTypes";
import { fromStoreItem, getLevelKeyRewards, isStoreItem, toStoreItem } from "@/src/services/itemDataService";
import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel";
import { getEntriesUnsafe } from "@/src/utils/ts-utils";
import { IEquipmentClient } from "@/src/types/inventoryTypes/commonInventoryTypes";
import { handleStoreItemAcquisition } from "./purchaseService";
import { IMissionCredits, IMissionReward } from "../types/missionTypes";
import { handleStoreItemAcquisition } from "@/src/services/purchaseService";
import { IMissionCredits, IMissionReward } from "@/src/types/missionTypes";
import { crackRelic } from "@/src/helpers/relicHelper";
import { createMessage } from "./inboxService";
import { createMessage } from "@/src/services/inboxService";
import kuriaMessage50 from "@/static/fixed_responses/kuriaMessages/fiftyPercent.json";
import kuriaMessage75 from "@/static/fixed_responses/kuriaMessages/seventyFivePercent.json";
import kuriaMessage100 from "@/static/fixed_responses/kuriaMessages/oneHundredPercent.json";
@ -65,8 +63,8 @@ import {
getNemesisManifest,
getNemesisPasscode
} from "@/src/helpers/nemesisHelpers";
import { Loadout } from "../models/inventoryModels/loadoutModel";
import { ILoadoutConfigDatabase } from "../types/saveLoadoutTypes";
import { Loadout } from "@/src/models/inventoryModels/loadoutModel";
import { ILoadoutConfigDatabase } from "@/src/types/saveLoadoutTypes";
import {
getLiteSortie,
getSortie,
@ -75,12 +73,14 @@ import {
idToDay,
idToWeek,
pushClassicBounties
} from "./worldStateService";
import { config } from "./configService";
} from "@/src/services/worldStateService";
import { config } from "@/src/services/configService";
import libraryDailyTasks from "@/static/fixed_responses/libraryDailyTasks.json";
import { ISyndicateMissionInfo } from "../types/worldStateTypes";
import { fromOid } from "../helpers/inventoryHelpers";
import { TAccountDocument } from "./loginService";
import { ISyndicateMissionInfo } from "@/src/types/worldStateTypes";
import { fromOid } from "@/src/helpers/inventoryHelpers";
import { TAccountDocument } from "@/src/services/loginService";
import { ITypeCount } from "@/src/types/commonTypes";
import { IEquipmentClient } from "@/src/types/equipmentTypes";
const getRotations = (rewardInfo: IRewardInfo, tierOverride?: number): number[] => {
// For Spy missions, e.g. 3 vaults cracked = A, B, C
@ -558,6 +558,7 @@ export const addMissionInventoryUpdates = async (
}
]);
}
inventory.DeathSquadable = false;
break;
}
case "LockedWeaponGroup": {
@ -576,7 +577,7 @@ export const addMissionInventoryUpdates = async (
break;
}
case "IncHarvester": {
inventory.Harvestable = true;
// Unsure what to do with this
break;
}
case "CurrentLoadOutIds": {

View File

@ -1,8 +1,7 @@
import { PersonalRooms } from "@/src/models/personalRoomsModel";
import { addItem, getInventory } from "@/src/services/inventoryService";
import { TPersonalRoomsDatabaseDocument } from "../types/personalRoomsTypes";
import { IGardeningDatabase } from "../types/shipTypes";
import { getRandomElement } from "./rngService";
import { IGardeningDatabase, TPersonalRoomsDatabaseDocument } from "@/src/types/personalRoomsTypes";
import { getRandomElement } from "@/src/services/rngService";
export const getPersonalRooms = async (
accountId: string,

View File

@ -20,8 +20,7 @@ import {
IPurchaseParams
} from "@/src/types/purchaseTypes";
import { logger } from "@/src/utils/logger";
import { getWorldState } from "./worldStateService";
import staticWorldState from "@/static/fixed_responses/worldState/worldState.json";
import { getWorldState } from "@/src/services/worldStateService";
import {
ExportBoosterPacks,
ExportBoosters,
@ -33,11 +32,11 @@ import {
ExportVendors,
TRarity
} from "warframe-public-export-plus";
import { config } from "./configService";
import { TInventoryDatabaseDocument } from "../models/inventoryModels/inventoryModel";
import { fromStoreItem, toStoreItem } from "./itemDataService";
import { DailyDeal } from "../models/worldStateModel";
import { fromMongoDate, toMongoDate } from "../helpers/inventoryHelpers";
import { config } from "@/src/services/configService";
import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel";
import { fromStoreItem, toStoreItem } from "@/src/services/itemDataService";
import { DailyDeal } from "@/src/models/worldStateModel";
import { fromMongoDate, toMongoDate } from "@/src/helpers/inventoryHelpers";
export const getStoreItemCategory = (storeItem: string): string => {
const storeItemString = getSubstringFromKeyword(storeItem, "StoreItems/");
@ -305,14 +304,15 @@ export const handlePurchase = async (
}
break;
case PurchaseSource.PrimeVaultTrader: {
if (purchaseRequest.PurchaseParams.SourceId! != staticWorldState.PrimeVaultTraders[0]._id.$oid) {
const worldState = getWorldState();
if (purchaseRequest.PurchaseParams.SourceId! != worldState.PrimeVaultTraders[0]._id.$oid) {
throw new Error("invalid request source");
}
const offer =
staticWorldState.PrimeVaultTraders[0].Manifest.find(
worldState.PrimeVaultTraders[0].Manifest.find(
x => x.ItemType == purchaseRequest.PurchaseParams.StoreItem
) ??
staticWorldState.PrimeVaultTraders[0].EvergreenManifest.find(
worldState.PrimeVaultTraders[0].EvergreenManifest.find(
x => x.ItemType == purchaseRequest.PurchaseParams.StoreItem
);
if (offer) {

View File

@ -4,13 +4,14 @@ import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/invento
import { createMessage } from "@/src/services/inboxService";
import { addItem, addItems, addKeyChainItems, setupKahlSyndicate } from "@/src/services/inventoryService";
import { fromStoreItem, getKeyChainMessage, getLevelKeyRewards } from "@/src/services/itemDataService";
import { IQuestKeyClient, IQuestKeyDatabase, IQuestStage, ITypeCount } from "@/src/types/inventoryTypes/inventoryTypes";
import { IQuestKeyClient, IQuestKeyDatabase, IQuestStage } from "@/src/types/inventoryTypes/inventoryTypes";
import { logger } from "@/src/utils/logger";
import { Types } from "mongoose";
import { ExportKeys } from "warframe-public-export-plus";
import { addFixedLevelRewards } from "./missionInventoryUpdateService";
import { IInventoryChanges } from "../types/purchaseTypes";
import { addFixedLevelRewards } from "@/src/services/missionInventoryUpdateService";
import { IInventoryChanges } from "@/src/types/purchaseTypes";
import questCompletionItems from "@/static/fixed_responses/questCompletionRewards.json";
import { ITypeCount } from "@/src/types/commonTypes";
export interface IUpdateQuestRequest {
QuestKeys: Omit<IQuestKeyDatabase, "CompletionDate">[];
@ -235,7 +236,7 @@ const handleQuestCompletion = async (
setupKahlSyndicate(inventory);
}
// Whispers in the Walls is unlocked once The New + Heart of Deimos are completed.
// Whispers in the Walls is unlocked once The New War + Heart of Deimos are completed.
if (
doesQuestCompletionFinishSet(inventory, questKey, [
"/Lotus/Types/Keys/NewWarQuest/NewWarQuestKeyChain",

View File

@ -18,6 +18,17 @@ export const getRandomInt = (min: number, max: number): number => {
return Math.floor(Math.random() * (max - min + 1)) + min;
};
export const generateRewardSeed = (): bigint => {
const hiDword = getRandomInt(0, 0x7fffffff);
const loDword = getRandomInt(0, 0xffffffff);
let seed = (BigInt(hiDword) << 32n) | BigInt(loDword);
if (Math.random() < 0.5) {
seed *= -1n;
seed -= 1n;
}
return seed;
};
export const getRewardAtPercentage = <T extends { probability: number }>(
pool: T[],
percentage: number
@ -140,4 +151,57 @@ export class SRng {
arr[lastIdx] = tmp;
}
}
shuffledArray<T>(inarr: readonly T[]): T[] {
const arr = [...inarr];
this.shuffleArray(arr);
return arr;
}
}
export const sequentiallyUniqueRandomElement = <T>(
deck: readonly T[],
idx: number,
lookbehind: number,
seed: number = 0
): T | undefined => {
// This algorithm may modify a shuffle up to index `lookbehind + 1`. It assumes that the last `lookbehind` cards are not adjusted.
if (lookbehind + 1 >= deck.length - lookbehind) {
throw new Error(
`this algorithm cannot guarantee ${lookbehind} unique cards in a row with a deck of size ${deck.length}`
);
}
const iteration = Math.trunc(idx / deck.length);
const card = idx % deck.length;
const currentShuffle = new SRng(mixSeeds(new SRng(iteration).randomInt(0, 100_000), seed)).shuffledArray(deck);
if (card < currentShuffle.length - lookbehind) {
// We are indexing before the end of the deck, so adjustments may be needed to achieve uniqueness.
const window: T[] = [];
{
const previousShuffle = new SRng(
mixSeeds(new SRng(iteration - 1).randomInt(0, 100_000), seed)
).shuffledArray(deck);
for (let i = previousShuffle.length - lookbehind; i != previousShuffle.length; ++i) {
window.push(previousShuffle[i]);
}
}
// From this point on, `window.length == lookbehind` should hold.
for (let i = 0; i != lookbehind; ++i) {
if (window.indexOf(currentShuffle[i]) != -1) {
for (let j = i; ; ++j) {
// `j < currentShuffle.length - lookbehind` should hold.
if (window.indexOf(currentShuffle[j]) == -1) {
const tmp = currentShuffle[j];
currentShuffle[j] = currentShuffle[i];
currentShuffle[i] = tmp;
break;
}
}
}
window.splice(0, 1);
window.push(currentShuffle[i]);
}
}
return currentShuffle[card];
};

View File

@ -13,8 +13,8 @@ import { Types } from "mongoose";
import { isEmptyObject } from "@/src/helpers/general";
import { logger } from "@/src/utils/logger";
import { equipmentKeys, TEquipmentKey } from "@/src/types/inventoryTypes/inventoryTypes";
import { IItemConfig } from "../types/inventoryTypes/commonInventoryTypes";
import { importCrewMemberId } from "./importService";
import { IItemConfig } from "@/src/types/inventoryTypes/commonInventoryTypes";
import { importCrewMemberId } from "@/src/services/importService";
//TODO: setup default items on account creation or like originally in giveStartingItems.php
@ -167,8 +167,23 @@ export const handleInventoryItemConfigChange = async (
inventory.LotusCustomization = equipmentChanges.LotusCustomization;
break;
}
case "ValidNewLoadoutId": {
logger.debug(`ignoring ValidNewLoadoutId (${equipmentChanges.ValidNewLoadoutId})`);
// seems always equal to the id of loadout config NORMAL[0], likely has no purpose and we're free to ignore it
break;
}
case "ActiveCrewShip": {
if (inventory.CrewShips.length != 1) {
logger.warn(`saving railjack changes with broken inventory?`);
} else if (!inventory.CrewShips[0]._id.equals(equipmentChanges.ActiveCrewShip.$oid)) {
logger.warn(
`client provided CrewShip id ${equipmentChanges.ActiveCrewShip.$oid} but id in inventory is ${inventory.CrewShips[0]._id.toString()}`
);
}
break;
}
default: {
if (equipmentKeys.includes(equipmentName as TEquipmentKey) && equipmentName != "ValidNewLoadoutId") {
if (equipmentKeys.includes(equipmentName as TEquipmentKey)) {
logger.debug(`general Item config saved of type ${equipmentName}`, {
config: equipment
});
@ -216,7 +231,7 @@ export const handleInventoryItemConfigChange = async (
}
break;
} else {
logger.warn(`loadout category not implemented, changes may be lost: ${equipmentName}`, {
logger.warn(`unknown saveLoadout field: ${equipmentName}`, {
config: equipment
});
}

View File

@ -6,7 +6,7 @@ import { mixSeeds, SRng } from "@/src/services/rngService";
import { IItemManifest, IVendorInfo, IVendorManifest } from "@/src/types/vendorTypes";
import { logger } from "@/src/utils/logger";
import { ExportVendors, IRange, IVendor, IVendorOffer } from "warframe-public-export-plus";
import { config } from "./configService";
import { config } from "@/src/services/configService";
interface IGeneratableVendorInfo extends Omit<IVendorInfo, "ItemManifest" | "Expiry"> {
cycleOffset?: number;
@ -299,9 +299,12 @@ const generateVendorManifest = (
? numUncountedOffers + numCountedOffers
: manifest.numItems
? numUncountedOffers +
(useRng
? rng.randomInt(manifest.numItems.minValue, manifest.numItems.maxValue)
: manifest.numItems.minValue)
Math.min(
Object.values(remainingItemCapacity).reduce((a, b) => a + b, 0),
useRng
? rng.randomInt(manifest.numItems.minValue, manifest.numItems.maxValue)
: manifest.numItems.minValue
)
: manifest.items.length;
let i = 0;
const rollableOffers = manifest.items.filter(x => x.probability !== undefined) as (Omit<
@ -495,4 +498,13 @@ if (args.dev) {
) {
logger.warn(`self test failed for /Lotus/Types/Game/VendorManifests/Ostron/MaskSalesmanManifest`);
}
// strange case where numItems is 5 even tho only 3 offers can possibly be generated
const loid = getVendorManifestByTypeName(
"/Lotus/Types/Game/VendorManifests/EntratiLabs/EntratiLabsCommisionsManifest",
false
)!.VendorInfo.ItemManifest;
if (loid.length != 3) {
logger.warn(`self test failed for /Lotus/Types/Game/VendorManifests/EntratiLabs/EntratiLabsCommisionsManifest`);
}
}

View File

@ -1,21 +1,22 @@
import { getPersonalRooms } from "@/src/services/personalRoomsService";
import { getShip } from "@/src/services/shipService";
import {
ISetPlacedDecoInfoRequest,
ISetShipCustomizationsRequest,
IShipDecorationsRequest,
IShipDecorationsResponse,
ISetPlacedDecoInfoRequest,
TBootLocation
} from "@/src/types/shipTypes";
RoomsType,
TBootLocation,
TPersonalRoomsDatabaseDocument
} from "@/src/types/personalRoomsTypes";
import { logger } from "@/src/utils/logger";
import { Types } from "mongoose";
import { addFusionTreasures, addShipDecorations, getInventory } from "./inventoryService";
import { config } from "./configService";
import { Guild } from "../models/guildModel";
import { hasGuildPermission } from "./guildService";
import { GuildPermission } from "../types/guildTypes";
import { addFusionTreasures, addShipDecorations, getInventory } from "@/src/services/inventoryService";
import { config } from "@/src/services/configService";
import { Guild } from "@/src/models/guildModel";
import { hasGuildPermission } from "@/src/services/guildService";
import { GuildPermission } from "@/src/types/guildTypes";
import { ExportResources } from "warframe-public-export-plus";
import { RoomsType, TPersonalRoomsDatabaseDocument } from "../types/personalRoomsTypes";
export const setShipCustomizations = async (
accountId: string,
@ -39,7 +40,7 @@ export const setShipCustomizations = async (
personalRooms.TailorShop.LevelDecosVisible = shipCustomization.Customization.LevelDecosVisible;
personalRooms.TailorShop.CustomJson = shipCustomization.Customization.CustomJson;
} else {
personalRooms.ShipInteriorColors = shipCustomization.Customization.Colors;
personalRooms.Ship.ShipInterior = shipCustomization.Customization;
}
await personalRooms.save();
}
@ -64,8 +65,12 @@ export const handleSetShipDecorations = async (
throw new Error(`unknown room: ${placedDecoration.Room}`);
}
const [itemType, meta] = Object.entries(ExportResources).find(arr => arr[1].deco == placedDecoration.Type)!;
if (!itemType || meta.capacityCost === undefined) {
const entry = Object.entries(ExportResources).find(arr => arr[1].deco == placedDecoration.Type);
if (!entry) {
throw new Error(`unknown deco type: ${placedDecoration.Type}`);
}
const [itemType, meta] = entry;
if (meta.capacityCost === undefined) {
throw new Error(`unknown deco type: ${placedDecoration.Type}`);
}

View File

@ -10,7 +10,7 @@ import {
} from "@/src/types/statTypes";
import { logger } from "@/src/utils/logger";
import { addEmailItem, getInventory } from "@/src/services/inventoryService";
import { submitLeaderboardScore } from "./leaderboardService";
import { submitLeaderboardScore } from "@/src/services/leaderboardService";
export const createStats = async (accountId: string): Promise<TStatsDatabaseDocument> => {
const stats = new Stats({ accountOwnerId: accountId });

View File

@ -1,21 +1,15 @@
import http from "http";
import https from "https";
import fs from "node:fs";
import { config } from "./configService";
import { logger } from "../utils/logger";
import { app } from "../app";
import { config } from "@/src/services/configService";
import { logger } from "@/src/utils/logger";
import { app } from "@/src/app";
import { AddressInfo } from "node:net";
import ws from "ws";
import { Account } from "../models/loginModel";
import { createAccount, createNonce, getUsernameFromEmail, isCorrectPassword } from "./loginService";
import { IDatabaseAccountJson } from "../types/loginTypes";
import { HydratedDocument } from "mongoose";
import { Agent, WebSocket as UnidiciWebSocket } from "undici";
import { startWsServer, startWssServer, stopWsServers } from "@/src/services/wsService";
let httpServer: http.Server | undefined;
let httpsServer: https.Server | undefined;
let wsServer: ws.Server | undefined;
let wssServer: ws.Server | undefined;
const tlsOptions = {
key: fs.readFileSync("static/certs/key.pem"),
@ -29,16 +23,14 @@ export const startWebServer = (): void => {
// eslint-disable-next-line @typescript-eslint/no-misused-promises
httpServer = http.createServer(app);
httpServer.listen(httpPort, () => {
wsServer = new ws.Server({ server: httpServer });
wsServer.on("connection", wsOnConnect);
startWsServer(httpServer!);
logger.info("HTTP server started on port " + httpPort);
// eslint-disable-next-line @typescript-eslint/no-misused-promises
httpsServer = https.createServer(tlsOptions, app);
httpsServer.listen(httpsPort, () => {
wssServer = new ws.Server({ server: httpsServer });
wssServer.on("connection", wsOnConnect);
startWssServer(httpsServer!);
logger.info("HTTPS server started on port " + httpsPort);
@ -115,182 +107,6 @@ export const stopWebServer = async (): Promise<void> => {
})
);
}
if (wsServer) {
promises.push(
new Promise(resolve => {
wsServer!.close(() => {
resolve();
});
})
);
}
if (wssServer) {
promises.push(
new Promise(resolve => {
wssServer!.close(() => {
resolve();
});
})
);
}
stopWsServers(promises);
await Promise.all(promises);
};
let lastWsid: number = 0;
interface IWsCustomData extends ws {
id?: number;
accountId?: string;
}
interface IWsMsgFromClient {
auth?: {
email: string;
password: string;
isRegister: boolean;
};
logout?: boolean;
}
interface IWsMsgToClient {
//wsid?: number;
reload?: boolean;
ports?: {
http: number | undefined;
https: number | undefined;
};
config_reloaded?: boolean;
auth_succ?: {
id: string;
DisplayName: string;
Nonce: number;
};
auth_fail?: {
isRegister: boolean;
};
logged_out?: boolean;
update_inventory?: boolean;
}
const wsOnConnect = (ws: ws, req: http.IncomingMessage): void => {
if (req.url == "/custom/selftest") {
ws.send("SpaceNinjaServer");
ws.close();
return;
}
(ws as IWsCustomData).id = ++lastWsid;
ws.send(JSON.stringify({ wsid: lastWsid }));
// eslint-disable-next-line @typescript-eslint/no-misused-promises
ws.on("message", async msg => {
const data = JSON.parse(String(msg)) as IWsMsgFromClient;
if (data.auth) {
let account: IDatabaseAccountJson | null = await Account.findOne({ email: data.auth.email });
if (account) {
if (isCorrectPassword(data.auth.password, account.password)) {
if (!account.Nonce) {
account.ClientType = "webui";
account.Nonce = createNonce();
await (account as HydratedDocument<IDatabaseAccountJson>).save();
}
} else {
account = null;
}
} else if (data.auth.isRegister) {
const name = await getUsernameFromEmail(data.auth.email);
account = await createAccount({
email: data.auth.email,
password: data.auth.password,
ClientType: "webui",
LastLogin: new Date(),
DisplayName: name,
Nonce: createNonce()
});
}
if (account) {
(ws as IWsCustomData).accountId = account.id;
ws.send(
JSON.stringify({
auth_succ: {
id: account.id,
DisplayName: account.DisplayName,
Nonce: account.Nonce
}
} satisfies IWsMsgToClient)
);
} else {
ws.send(
JSON.stringify({
auth_fail: {
isRegister: data.auth.isRegister
}
} satisfies IWsMsgToClient)
);
}
}
if (data.logout) {
const accountId = (ws as IWsCustomData).accountId;
(ws as IWsCustomData).accountId = undefined;
await Account.updateOne(
{
_id: accountId,
ClientType: "webui"
},
{
Nonce: 0
}
);
}
});
};
export const sendWsBroadcast = (data: IWsMsgToClient): void => {
const msg = JSON.stringify(data);
if (wsServer) {
for (const client of wsServer.clients) {
client.send(msg);
}
}
if (wssServer) {
for (const client of wssServer.clients) {
client.send(msg);
}
}
};
export const sendWsBroadcastTo = (accountId: string, data: IWsMsgToClient): void => {
const msg = JSON.stringify(data);
if (wsServer) {
for (const client of wsServer.clients) {
if ((client as IWsCustomData).accountId == accountId) {
client.send(msg);
}
}
}
if (wssServer) {
for (const client of wssServer.clients) {
if ((client as IWsCustomData).accountId == accountId) {
client.send(msg);
}
}
}
};
export const sendWsBroadcastExcept = (wsid: number | undefined, data: IWsMsgToClient): void => {
const msg = JSON.stringify(data);
if (wsServer) {
for (const client of wsServer.clients) {
if ((client as IWsCustomData).id != wsid) {
client.send(msg);
}
}
}
if (wssServer) {
for (const client of wssServer.clients) {
if ((client as IWsCustomData).id != wsid) {
client.send(msg);
}
}
}
};

View File

@ -1,20 +1,26 @@
import staticWorldState from "@/static/fixed_responses/worldState/worldState.json";
import baro from "@/static/fixed_responses/worldState/baro.json";
import varzia from "@/static/fixed_responses/worldState/varzia.json";
import fissureMissions from "@/static/fixed_responses/worldState/fissureMissions.json";
import sortieTilesets from "@/static/fixed_responses/worldState/sortieTilesets.json";
import sortieTilesetMissions from "@/static/fixed_responses/worldState/sortieTilesetMissions.json";
import syndicateMissions from "@/static/fixed_responses/worldState/syndicateMissions.json";
import darvoDeals from "@/static/fixed_responses/worldState/darvoDeals.json";
import invasionNodes from "@/static/fixed_responses/worldState/invasionNodes.json";
import invasionRewards from "@/static/fixed_responses/worldState/invasionRewards.json";
import { buildConfig } from "@/src/services/buildConfigService";
import { unixTimesInMs } from "@/src/constants/timeConstants";
import { config } from "@/src/services/configService";
import { getRandomElement, getRandomInt, SRng } from "@/src/services/rngService";
import { eMissionType, ExportRegions, ExportSyndicates, IRegion } from "warframe-public-export-plus";
import { getRandomElement, getRandomInt, sequentiallyUniqueRandomElement, SRng } from "@/src/services/rngService";
import { eMissionType, ExportRegions, ExportSyndicates, IMissionReward, IRegion } from "warframe-public-export-plus";
import {
ICalendarDay,
ICalendarEvent,
ICalendarSeason,
IInvasion,
ILiteSortie,
IPrimeVaultTrader,
IPrimeVaultTraderOffer,
ISeasonChallenge,
ISortie,
ISortieMission,
@ -25,10 +31,10 @@ import {
IVoidTraderOffer,
IWorldState,
TCircuitGameMode
} from "../types/worldStateTypes";
import { toMongoDate, toOid, version_compare } from "../helpers/inventoryHelpers";
import { logger } from "../utils/logger";
import { DailyDeal, Fissure } from "../models/worldStateModel";
} from "@/src/types/worldStateTypes";
import { toMongoDate, toOid, version_compare } from "@/src/helpers/inventoryHelpers";
import { logger } from "@/src/utils/logger";
import { DailyDeal, Fissure } from "@/src/models/worldStateModel";
const sortieBosses = [
"SORTIE_BOSS_HYENA",
@ -382,44 +388,35 @@ const getSeasonChallengePools = (syndicateTag: string): IRotatingSeasonChallenge
const getSeasonDailyChallenge = (pools: IRotatingSeasonChallengePools, day: number): ISeasonChallenge => {
const dayStart = EPOCH + day * 86400000;
const dayEnd = EPOCH + (day + 3) * 86400000;
const rng = new SRng(new SRng(day).randomInt(0, 100_000));
return {
_id: { $oid: "67e1b5ca9d00cb47" + day.toString().padStart(8, "0") },
Daily: true,
Activation: { $date: { $numberLong: dayStart.toString() } },
Expiry: { $date: { $numberLong: dayEnd.toString() } },
Challenge: rng.randomElement(pools.daily)!
Challenge: sequentiallyUniqueRandomElement(pools.daily, day, 2, 605732938)!
};
};
const getSeasonWeeklyChallenge = (pools: IRotatingSeasonChallengePools, week: number, id: number): ISeasonChallenge => {
const weekStart = EPOCH + week * 604800000;
const weekEnd = weekStart + 604800000;
const challengeId = week * 7 + id;
const rng = new SRng(new SRng(challengeId).randomInt(0, 100_000));
return {
_id: { $oid: "67e1bb2d9d00cb47" + challengeId.toString().padStart(8, "0") },
Activation: { $date: { $numberLong: weekStart.toString() } },
Expiry: { $date: { $numberLong: weekEnd.toString() } },
Challenge: rng.randomElement(pools.weekly)!
};
};
const getSeasonWeeklyHardChallenge = (
pools: IRotatingSeasonChallengePools,
const pushSeasonWeeklyChallenge = (
activeChallenges: ISeasonChallenge[],
pool: string[],
week: number,
id: number
): ISeasonChallenge => {
): void => {
const weekStart = EPOCH + week * 604800000;
const weekEnd = weekStart + 604800000;
const challengeId = week * 7 + id;
const rng = new SRng(new SRng(challengeId).randomInt(0, 100_000));
return {
let challenge: string;
do {
challenge = rng.randomElement(pool)!;
} while (activeChallenges.some(x => x.Challenge == challenge));
activeChallenges.push({
_id: { $oid: "67e1bb2d9d00cb47" + challengeId.toString().padStart(8, "0") },
Activation: { $date: { $numberLong: weekStart.toString() } },
Expiry: { $date: { $numberLong: weekEnd.toString() } },
Challenge: rng.randomElement(pools.hardWeekly)!
};
Challenge: challenge
});
};
const pushWeeklyActs = (
@ -430,8 +427,8 @@ const pushWeeklyActs = (
const weekStart = EPOCH + week * 604800000;
const weekEnd = weekStart + 604800000;
activeChallenges.push(getSeasonWeeklyChallenge(pools, week, 0));
activeChallenges.push(getSeasonWeeklyChallenge(pools, week, 1));
pushSeasonWeeklyChallenge(activeChallenges, pools.weekly, week, 0);
pushSeasonWeeklyChallenge(activeChallenges, pools.weekly, week, 1);
if (pools.hasWeeklyPermanent) {
activeChallenges.push({
_id: { $oid: "67e1b96e9d00cb47" + (week * 7 + 0).toString().padStart(8, "0") },
@ -451,14 +448,14 @@ const pushWeeklyActs = (
Expiry: { $date: { $numberLong: weekEnd.toString() } },
Challenge: "/Lotus/Types/Challenges/Seasons/Weekly/SeasonWeeklyPermanentKillEnemies"
});
activeChallenges.push(getSeasonWeeklyHardChallenge(pools, week, 2));
activeChallenges.push(getSeasonWeeklyHardChallenge(pools, week, 3));
pushSeasonWeeklyChallenge(activeChallenges, pools.hardWeekly, week, 2);
pushSeasonWeeklyChallenge(activeChallenges, pools.hardWeekly, week, 3);
} else {
activeChallenges.push(getSeasonWeeklyChallenge(pools, week, 2));
activeChallenges.push(getSeasonWeeklyChallenge(pools, week, 3));
activeChallenges.push(getSeasonWeeklyChallenge(pools, week, 4));
activeChallenges.push(getSeasonWeeklyHardChallenge(pools, week, 5));
activeChallenges.push(getSeasonWeeklyHardChallenge(pools, week, 6));
pushSeasonWeeklyChallenge(activeChallenges, pools.weekly, week, 2);
pushSeasonWeeklyChallenge(activeChallenges, pools.weekly, week, 3);
pushSeasonWeeklyChallenge(activeChallenges, pools.weekly, week, 4);
pushSeasonWeeklyChallenge(activeChallenges, pools.hardWeekly, week, 5);
pushSeasonWeeklyChallenge(activeChallenges, pools.hardWeekly, week, 6);
}
};
@ -977,25 +974,26 @@ const getCalendarSeason = (week: number): ICalendarSeason => {
// Not very faithful, but to avoid the same node coming up back-to-back (which is not valid), I've split these into 2 arrays which we're alternating between.
const voidStormMissionsA = {
VoidT1: ["CrewBattleNode519", "CrewBattleNode518", "CrewBattleNode515", "CrewBattleNode503"],
VoidT2: ["CrewBattleNode501", "CrewBattleNode534", "CrewBattleNode530"],
VoidT3: ["CrewBattleNode521", "CrewBattleNode516"],
const voidStormMissions = {
VoidT1: [
"CrewBattleNode519",
"CrewBattleNode518",
"CrewBattleNode515",
"CrewBattleNode503",
"CrewBattleNode509",
"CrewBattleNode522",
"CrewBattleNode511",
"CrewBattleNode512"
],
VoidT2: ["CrewBattleNode501", "CrewBattleNode534", "CrewBattleNode530", "CrewBattleNode535", "CrewBattleNode533"],
VoidT3: ["CrewBattleNode521", "CrewBattleNode516", "CrewBattleNode524", "CrewBattleNode525"],
VoidT4: [
"CrewBattleNode555",
"CrewBattleNode553",
"CrewBattleNode554",
"CrewBattleNode539",
"CrewBattleNode531",
"CrewBattleNode527"
]
};
const voidStormMissionsB = {
VoidT1: ["CrewBattleNode509", "CrewBattleNode522", "CrewBattleNode511", "CrewBattleNode512"],
VoidT2: ["CrewBattleNode535", "CrewBattleNode533"],
VoidT3: ["CrewBattleNode524", "CrewBattleNode525"],
VoidT4: [
"CrewBattleNode527",
"CrewBattleNode542",
"CrewBattleNode538",
"CrewBattleNode543",
@ -1003,18 +1001,21 @@ const voidStormMissionsB = {
"CrewBattleNode550",
"CrewBattleNode529"
]
};
} as const;
const voidStormLookbehind = {
VoidT1: 3,
VoidT2: 1,
VoidT3: 1,
VoidT4: 3
} as const;
const pushVoidStorms = (arr: IVoidStorm[], hour: number): void => {
const activation = hour * unixTimesInMs.hour + 40 * unixTimesInMs.minute;
const expiry = activation + 90 * unixTimesInMs.minute;
let accum = 0;
const rng = new SRng(new SRng(hour).randomInt(0, 100_000));
const voidStormMissions = structuredClone(hour & 1 ? voidStormMissionsA : voidStormMissionsB);
const tierIdx = { VoidT1: hour * 2, VoidT2: hour, VoidT3: hour, VoidT4: hour * 2 };
for (const tier of ["VoidT1", "VoidT1", "VoidT2", "VoidT3", "VoidT4", "VoidT4"] as const) {
const idx = rng.randomInt(0, voidStormMissions[tier].length - 1);
const node = voidStormMissions[tier][idx];
voidStormMissions[tier].splice(idx, 1);
arr.push({
_id: {
$oid:
@ -1022,7 +1023,12 @@ const pushVoidStorms = (arr: IVoidStorm[], hour: number): void => {
"0321e89b" +
(accum++).toString().padStart(8, "0")
},
Node: node,
Node: sequentiallyUniqueRandomElement(
voidStormMissions[tier],
tierIdx[tier]++,
voidStormLookbehind[tier],
2051969264
)!,
Activation: { $date: { $numberLong: activation.toString() } },
Expiry: { $date: { $numberLong: expiry.toString() } },
ActiveMissionTier: tier
@ -1030,53 +1036,280 @@ const pushVoidStorms = (arr: IVoidStorm[], hour: number): void => {
}
};
const doesTimeSatsifyConstraints = (timeSecs: number): boolean => {
if (config.worldState?.eidolonOverride) {
interface ITimeConstraint {
//name: string;
isValidTime: (timeSecs: number) => boolean;
getIdealTimeBefore: (timeSecs: number) => number;
}
const eidolonDayConstraint: ITimeConstraint = {
//name: "eidolon day",
isValidTime: (timeSecs: number): boolean => {
const eidolonEpoch = 1391992660;
const eidolonCycle = Math.trunc((timeSecs - eidolonEpoch) / 9000);
const eidolonCycleStart = eidolonEpoch + eidolonCycle * 9000;
const eidolonCycleEnd = eidolonCycleStart + 9000;
const eidolonCycleNightStart = eidolonCycleEnd - 3000;
if (config.worldState.eidolonOverride == "day") {
if (
//timeSecs < eidolonCycleStart ||
isBeforeNextExpectedWorldStateRefresh(timeSecs * 1000, eidolonCycleNightStart * 1000)
) {
return false;
}
} else {
if (
timeSecs < eidolonCycleNightStart ||
isBeforeNextExpectedWorldStateRefresh(timeSecs * 1000, eidolonCycleEnd * 1000)
) {
return false;
}
}
return !isBeforeNextExpectedWorldStateRefresh(timeSecs * 1000, eidolonCycleNightStart * 1000);
},
getIdealTimeBefore: (timeSecs: number): number => {
const eidolonEpoch = 1391992660;
const eidolonCycle = Math.trunc((timeSecs - eidolonEpoch) / 9000);
const eidolonCycleStart = eidolonEpoch + eidolonCycle * 9000;
return eidolonCycleStart;
}
};
if (config.worldState?.vallisOverride) {
const eidolonNightConstraint: ITimeConstraint = {
//name: "eidolon night",
isValidTime: (timeSecs: number): boolean => {
const eidolonEpoch = 1391992660;
const eidolonCycle = Math.trunc((timeSecs - eidolonEpoch) / 9000);
const eidolonCycleStart = eidolonEpoch + eidolonCycle * 9000;
const eidolonCycleEnd = eidolonCycleStart + 9000;
const eidolonCycleNightStart = eidolonCycleEnd - 3000;
return (
timeSecs >= eidolonCycleNightStart &&
!isBeforeNextExpectedWorldStateRefresh(timeSecs * 1000, eidolonCycleEnd * 1000)
);
},
getIdealTimeBefore: (timeSecs: number): number => {
const eidolonEpoch = 1391992660;
const eidolonCycle = Math.trunc((timeSecs - eidolonEpoch) / 9000);
const eidolonCycleStart = eidolonEpoch + eidolonCycle * 9000;
const eidolonCycleEnd = eidolonCycleStart + 9000;
const eidolonCycleNightStart = eidolonCycleEnd - 3000;
if (eidolonCycleNightStart > timeSecs) {
// Night hasn't started yet, but we need to return a time in the past.
return eidolonCycleNightStart - 9000;
}
return eidolonCycleNightStart;
}
};
const venusColdConstraint: ITimeConstraint = {
//name: "venus cold",
isValidTime: (timeSecs: number): boolean => {
const vallisEpoch = 1541837628;
const vallisCycle = Math.trunc((timeSecs - vallisEpoch) / 1600);
const vallisCycleStart = vallisEpoch + vallisCycle * 1600;
const vallisCycleEnd = vallisCycleStart + 1600;
const vallisCycleColdStart = vallisCycleStart + 400;
if (config.worldState.vallisOverride == "cold") {
if (
timeSecs < vallisCycleColdStart ||
isBeforeNextExpectedWorldStateRefresh(timeSecs * 1000, vallisCycleEnd * 1000)
) {
return false;
}
} else {
if (
//timeSecs < vallisCycleStart ||
isBeforeNextExpectedWorldStateRefresh(timeSecs * 1000, vallisCycleColdStart * 1000)
) {
return false;
return (
timeSecs >= vallisCycleColdStart &&
!isBeforeNextExpectedWorldStateRefresh(timeSecs * 1000, vallisCycleEnd * 1000)
);
},
getIdealTimeBefore: (timeSecs: number): number => {
const vallisEpoch = 1541837628;
const vallisCycle = Math.trunc((timeSecs - vallisEpoch) / 1600);
const vallisCycleStart = vallisEpoch + vallisCycle * 1600;
const vallisCycleColdStart = vallisCycleStart + 400;
if (vallisCycleColdStart > timeSecs) {
// Cold hasn't started yet, but we need to return a time in the past.
return vallisCycleColdStart - 1600;
}
return vallisCycleColdStart;
}
};
const venusWarmConstraint: ITimeConstraint = {
//name: "venus warm",
isValidTime: (timeSecs: number): boolean => {
const vallisEpoch = 1541837628;
const vallisCycle = Math.trunc((timeSecs - vallisEpoch) / 1600);
const vallisCycleStart = vallisEpoch + vallisCycle * 1600;
const vallisCycleColdStart = vallisCycleStart + 400;
return !isBeforeNextExpectedWorldStateRefresh(timeSecs * 1000, vallisCycleColdStart * 1000);
},
getIdealTimeBefore: (timeSecs: number): number => {
const vallisEpoch = 1541837628;
const vallisCycle = Math.trunc((timeSecs - vallisEpoch) / 1600);
const vallisCycleStart = vallisEpoch + vallisCycle * 1600;
return vallisCycleStart;
}
};
const getIdealTimeSatsifyingConstraints = (constraints: ITimeConstraint[]): number => {
let timeSecs = Math.trunc(Date.now() / 1000);
let allGood;
do {
allGood = true;
for (const constraint of constraints) {
if (!constraint.isValidTime(timeSecs)) {
//logger.debug(`${constraint.name} is not happy with ${timeSecs}`);
const prevTimeSecs = timeSecs;
const suggestion = constraint.getIdealTimeBefore(timeSecs);
timeSecs = suggestion;
do {
timeSecs += 60;
if (timeSecs >= prevTimeSecs || !constraint.isValidTime(timeSecs)) {
timeSecs = suggestion; // Can't find a compromise; just take the suggestion and try to compromise on another constraint.
break;
}
} while (!constraints.every(constraint => constraint.isValidTime(timeSecs)));
allGood = false;
break;
}
}
} while (!allGood);
return timeSecs;
};
const getVarziaRotation = (week: number): string => {
const seed = new SRng(week).randomInt(0, 100_000);
const rng = new SRng(seed);
return rng.randomElement(varzia.primeDualPacks)!.ItemType;
};
const getVarziaManifest = (dualPack: string): IPrimeVaultTraderOffer[] => {
const rotrationManifest = varzia.primeDualPacks.find(pack => pack.ItemType === dualPack);
if (!rotrationManifest) return [];
const mainPack = [{ ItemType: rotrationManifest.ItemType, PrimePrice: 10 }];
const singlePacks: IPrimeVaultTraderOffer[] = [];
const items: IPrimeVaultTraderOffer[] = [];
const bobbleHeads: IPrimeVaultTraderOffer[] = [];
for (const singlePackType of rotrationManifest.SinglePacks) {
singlePacks.push({ ItemType: singlePackType, PrimePrice: 6 });
const sp = varzia.primeSinglePacks.find(pack => pack.ItemType === singlePackType);
if (sp) {
items.push(...sp.Items);
sp.BobbleHeads.forEach(bobbleHead => {
bobbleHeads.push({ ItemType: bobbleHead, PrimePrice: 1 });
});
}
}
const relics = rotrationManifest.Relics.map(relic => ({ ItemType: relic, RegularPrice: 1 }));
return [singlePacks[0], ...mainPack, singlePacks[1], ...items, ...bobbleHeads, ...relics];
};
const getAllVarziaManifests = (): IPrimeVaultTraderOffer[] => {
const dualPacks: IPrimeVaultTraderOffer[] = [];
const singlePacks: IPrimeVaultTraderOffer[] = [];
const items: IPrimeVaultTraderOffer[] = [];
const bobbleHeads: IPrimeVaultTraderOffer[] = [];
const relics: IPrimeVaultTraderOffer[] = [];
const singlePackSet = new Set<string>();
const itemsSet = new Set<string>();
const bobbleHeadsSet = new Set<string>();
varzia.primeDualPacks.forEach(dualPack => {
dualPacks.push({ ItemType: dualPack.ItemType, PrimePrice: 10 });
dualPack.SinglePacks.forEach(singlePackType => {
if (!singlePackSet.has(singlePackType)) {
singlePackSet.add(singlePackType);
singlePacks.push({ ItemType: singlePackType, PrimePrice: 6 });
}
const sp = varzia.primeSinglePacks.find(pack => pack.ItemType === singlePackType)!;
sp.Items.forEach(item => {
if (!itemsSet.has(item.ItemType)) {
itemsSet.add(item.ItemType);
items.push(item);
}
});
sp.BobbleHeads.forEach(bobbleHead => {
if (!bobbleHeadsSet.has(bobbleHead)) {
bobbleHeadsSet.add(bobbleHead);
bobbleHeads.push({ ItemType: bobbleHead, PrimePrice: 1 });
}
});
});
relics.push(...dualPack.Relics.map(relic => ({ ItemType: relic, RegularPrice: 1 })));
});
return [...dualPacks, ...singlePacks, ...items, ...bobbleHeads, ...relics];
};
const createInvasion = (day: number, idx: number): IInvasion => {
const id = day * 3 + idx;
const defender = (["FC_GRINEER", "FC_CORPUS", day % 2 ? "FC_GRINEER" : "FC_CORPUS"] as const)[idx];
const rng = new SRng(new SRng(id).randomInt(0, 1_000_000));
const isInfestationOutbreak = rng.randomInt(0, 1) == 0;
const attacker = isInfestationOutbreak ? "FC_INFESTATION" : defender == "FC_GRINEER" ? "FC_CORPUS" : "FC_GRINEER";
const startMs = EPOCH + day * 86400_000;
const oid =
((startMs / 1000) & 0xffffffff).toString(16).padStart(8, "0") +
"fd148cb8" +
(idx & 0xffffffff).toString(16).padStart(8, "0");
const node = sequentiallyUniqueRandomElement(invasionNodes[defender], id, 5, 690175)!; // Can't repeat the other 2 on this day nor the last 3
const progress = (Date.now() - startMs) / 86400_000;
const countMultiplier = isInfestationOutbreak || rng.randomInt(0, 1) ? -1 : 1; // if defender is winning, count is negative
const fiftyPercent = rng.randomInt(1000, 29000); // introduce some 'yitter' for the percentages
const rewardFloat = rng.randomFloat();
const rewardTier = rewardFloat < 0.201 ? "RARE" : rewardFloat < 0.7788 ? "COMMON" : "UNCOMMON";
const attackerReward: IMissionReward = {};
const defenderReward: IMissionReward = {};
if (isInfestationOutbreak) {
defenderReward.countedItems = [
rng.randomElement(invasionRewards[rng.randomInt(0, 1) ? "FC_INFESTATION" : defender][rewardTier])!
];
} else {
attackerReward.countedItems = [rng.randomElement(invasionRewards[attacker][rewardTier])!];
defenderReward.countedItems = [rng.randomElement(invasionRewards[defender][rewardTier])!];
}
return {
_id: { $oid: oid },
Faction: attacker,
DefenderFaction: defender,
Node: node,
Count: Math.round(
(progress < 0.5 ? progress * 2 * fiftyPercent : fiftyPercent + (30_000 - fiftyPercent) * (progress - 0.5)) *
countMultiplier
),
Goal: 30000, // Value seems to range from 30000 to 98000 in intervals of 1000. Higher values are increasingly rare. I don't think this is relevant for the frontend besides dividing count by it.
LocTag: isInfestationOutbreak
? ExportRegions[node].missionIndex == 0
? "/Lotus/Language/Menu/InfestedInvasionBoss"
: "/Lotus/Language/Menu/InfestedInvasionGeneric"
: attacker == "FC_CORPUS"
? "/Lotus/Language/Menu/CorpusInvasionGeneric"
: "/Lotus/Language/Menu/GrineerInvasionGeneric",
Completed: startMs + 86400_000 < Date.now(), // Sorta unfaithful. Invasions on live are (at least in part) in fluenced by people completing them. And otherwise also probably not hardcoded to last 24 hours.
ChainID: { $oid: oid },
AttackerReward: attackerReward,
AttackerMissionInfo: {
seed: rng.randomInt(0, 1_000_000),
faction: defender
},
DefenderReward: defenderReward,
DefenderMissionInfo: {
seed: rng.randomInt(0, 1_000_000),
faction: attacker
},
Activation: {
$date: {
$numberLong: startMs.toString()
}
}
};
};
export const getInvasionByOid = (oid: string): IInvasion | undefined => {
const arr = oid.split("fd148cb8");
if (arr.length == 2 && arr[0].length == 8 && arr[1].length == 8) {
return createInvasion(idToDay(oid), parseInt(arr[1], 16));
}
return undefined;
};
export const getWorldState = (buildLabel?: string): IWorldState => {
const constraints: ITimeConstraint[] = [];
if (config.worldState?.eidolonOverride) {
constraints.push(config.worldState.eidolonOverride == "day" ? eidolonDayConstraint : eidolonNightConstraint);
}
if (config.worldState?.vallisOverride) {
constraints.push(config.worldState.vallisOverride == "cold" ? venusColdConstraint : venusWarmConstraint);
}
if (config.worldState?.duviriOverride) {
const duviriMoods = ["sorrow", "fear", "joy", "anger", "envy"];
const desiredMood = duviriMoods.indexOf(config.worldState.duviriOverride);
@ -1086,26 +1319,22 @@ const doesTimeSatsifyConstraints = (timeSecs: number): boolean => {
valid_values: duviriMoods
});
} else {
const moodIndex = Math.trunc(timeSecs / 7200);
const moodStart = moodIndex * 7200;
const moodEnd = moodStart + 7200;
if (
moodIndex % 5 != desiredMood ||
isBeforeNextExpectedWorldStateRefresh(timeSecs * 1000, moodEnd * 1000)
) {
return false;
}
constraints.push({
//name: `duviri ${config.worldState.duviriOverride}`,
isValidTime: (timeSecs: number): boolean => {
const moodIndex = Math.trunc(timeSecs / 7200);
return moodIndex % 5 == desiredMood;
},
getIdealTimeBefore: (timeSecs: number): number => {
let moodIndex = Math.trunc(timeSecs / 7200);
moodIndex -= ((moodIndex % 5) - desiredMood + 5) % 5; // while (moodIndex % 5 != desiredMood) --moodIndex;
const moodStart = moodIndex * 7200;
return moodStart;
}
});
}
}
return true;
};
export const getWorldState = (buildLabel?: string): IWorldState => {
let timeSecs = Math.round(Date.now() / 1000);
while (!doesTimeSatsifyConstraints(timeSecs)) {
timeSecs -= 60;
}
const timeSecs = getIdealTimeSatsifyingConstraints(constraints);
const timeMs = timeSecs * 1000;
const day = Math.trunc((timeMs - EPOCH) / 86400000);
const week = Math.trunc(day / 7);
@ -1121,7 +1350,9 @@ export const getWorldState = (buildLabel?: string): IWorldState => {
LiteSorties: [],
ActiveMissions: [],
GlobalUpgrades: [],
Invasions: [],
VoidTraders: [],
PrimeVaultTraders: [],
VoidStorms: [],
DailyDeals: [],
EndlessXpChoices: [],
@ -1322,6 +1553,20 @@ export const getWorldState = (buildLabel?: string): IWorldState => {
});
}
// Rough outline of dynamic invasions.
// TODO: Invasions chains, e.g. an infestation mission would soon lead to other nodes on that planet also having an infestation invasion.
// TODO: Grineer/Corpus to fund their death stars with each invasion win.
{
worldState.Invasions.push(createInvasion(day, 0));
worldState.Invasions.push(createInvasion(day, 1));
worldState.Invasions.push(createInvasion(day, 2));
// Completed invasions stay for up to 24 hours as the winner 'occupies' that node
worldState.Invasions.push(createInvasion(day - 1, 0));
worldState.Invasions.push(createInvasion(day - 1, 1));
worldState.Invasions.push(createInvasion(day - 1, 2));
}
// Baro
{
const baroIndex = Math.trunc((Date.now() - 910800000) / (unixTimesInMs.day * 14));
@ -1393,6 +1638,31 @@ export const getWorldState = (buildLabel?: string): IWorldState => {
}
}
// Varzia
{
const pt: IPrimeVaultTrader = {
_id: { $oid: ((weekStart / 1000) & 0xffffffff).toString(16).padStart(8, "0") + "c36af423770eaa97" },
Activation: { $date: { $numberLong: weekStart.toString() } },
InitialStartDate: { $date: { $numberLong: "1662738144266" } },
Node: "TradeHUB1",
Manifest: [],
Expiry: { $date: { $numberLong: weekEnd.toString() } },
EvergreenManifest: varzia.evergreen,
ScheduleInfo: []
};
worldState.PrimeVaultTraders.push(pt);
const rotation = config.worldState?.varziaOverride || getVarziaRotation(week);
pt.Manifest = config.worldState?.varziaFullyStocked ? getAllVarziaManifests() : getVarziaManifest(rotation);
if (config.worldState?.varziaOverride || config.worldState?.varziaFullyStocked) {
pt.Expiry = { $date: { $numberLong: "2000000000000" } };
} else {
pt.ScheduleInfo.push({
Expiry: { $date: { $numberLong: (weekEnd + unixTimesInMs.week).toString() } },
FeaturedItem: getVarziaRotation(week + 1)
});
}
}
// Sortie & syndicate missions cycling every day (at 16:00 or 17:00 UTC depending on if London, OT is observing DST)
{
const rollover = getSortieTime(day);

200
src/services/wsService.ts Normal file
View File

@ -0,0 +1,200 @@
import http from "http";
import https from "https";
import ws from "ws";
import { Account } from "@/src/models/loginModel";
import { createAccount, createNonce, getUsernameFromEmail, isCorrectPassword } from "@/src/services/loginService";
import { IDatabaseAccountJson } from "@/src/types/loginTypes";
import { HydratedDocument } from "mongoose";
let wsServer: ws.Server | undefined;
let wssServer: ws.Server | undefined;
export const startWsServer = (httpServer: http.Server): void => {
wsServer = new ws.Server({ server: httpServer });
wsServer.on("connection", wsOnConnect);
};
export const startWssServer = (httpsServer: https.Server): void => {
wssServer = new ws.Server({ server: httpsServer });
wssServer.on("connection", wsOnConnect);
};
export const stopWsServers = (promises: Promise<void>[]): void => {
if (wsServer) {
promises.push(
new Promise(resolve => {
wsServer!.close(() => {
resolve();
});
})
);
}
if (wssServer) {
promises.push(
new Promise(resolve => {
wssServer!.close(() => {
resolve();
});
})
);
}
};
let lastWsid: number = 0;
interface IWsCustomData extends ws {
id?: number;
accountId?: string;
}
interface IWsMsgFromClient {
auth?: {
email: string;
password: string;
isRegister: boolean;
};
logout?: boolean;
}
interface IWsMsgToClient {
//wsid?: number;
reload?: boolean;
ports?: {
http: number | undefined;
https: number | undefined;
};
config_reloaded?: boolean;
auth_succ?: {
id: string;
DisplayName: string;
Nonce: number;
};
auth_fail?: {
isRegister: boolean;
};
logged_out?: boolean;
update_inventory?: boolean;
}
const wsOnConnect = (ws: ws, req: http.IncomingMessage): void => {
if (req.url == "/custom/selftest") {
ws.send("SpaceNinjaServer");
ws.close();
return;
}
(ws as IWsCustomData).id = ++lastWsid;
ws.send(JSON.stringify({ wsid: lastWsid }));
// eslint-disable-next-line @typescript-eslint/no-misused-promises
ws.on("message", async msg => {
const data = JSON.parse(String(msg)) as IWsMsgFromClient;
if (data.auth) {
let account: IDatabaseAccountJson | null = await Account.findOne({ email: data.auth.email });
if (account) {
if (isCorrectPassword(data.auth.password, account.password)) {
if (!account.Nonce) {
account.ClientType = "webui";
account.Nonce = createNonce();
await (account as HydratedDocument<IDatabaseAccountJson>).save();
}
} else {
account = null;
}
} else if (data.auth.isRegister) {
const name = await getUsernameFromEmail(data.auth.email);
account = await createAccount({
email: data.auth.email,
password: data.auth.password,
ClientType: "webui",
LastLogin: new Date(),
DisplayName: name,
Nonce: createNonce()
});
}
if (account) {
(ws as IWsCustomData).accountId = account.id;
ws.send(
JSON.stringify({
auth_succ: {
id: account.id,
DisplayName: account.DisplayName,
Nonce: account.Nonce
}
} satisfies IWsMsgToClient)
);
} else {
ws.send(
JSON.stringify({
auth_fail: {
isRegister: data.auth.isRegister
}
} satisfies IWsMsgToClient)
);
}
}
if (data.logout) {
const accountId = (ws as IWsCustomData).accountId;
(ws as IWsCustomData).accountId = undefined;
await Account.updateOne(
{
_id: accountId,
ClientType: "webui"
},
{
Nonce: 0
}
);
}
});
};
export const sendWsBroadcast = (data: IWsMsgToClient): void => {
const msg = JSON.stringify(data);
if (wsServer) {
for (const client of wsServer.clients) {
client.send(msg);
}
}
if (wssServer) {
for (const client of wssServer.clients) {
client.send(msg);
}
}
};
export const sendWsBroadcastTo = (accountId: string, data: IWsMsgToClient): void => {
const msg = JSON.stringify(data);
if (wsServer) {
for (const client of wsServer.clients) {
if ((client as IWsCustomData).accountId == accountId) {
client.send(msg);
}
}
}
if (wssServer) {
for (const client of wssServer.clients) {
if ((client as IWsCustomData).accountId == accountId) {
client.send(msg);
}
}
}
};
export const sendWsBroadcastExcept = (wsid: number | undefined, data: IWsMsgToClient): void => {
const msg = JSON.stringify(data);
if (wsServer) {
for (const client of wsServer.clients) {
if ((client as IWsCustomData).id != wsid) {
client.send(msg);
}
}
}
if (wssServer) {
for (const client of wssServer.clients) {
if ((client as IWsCustomData).id != wsid) {
client.send(msg);
}
}
}
};

Some files were not shown because too many files have changed in this diff Show More