From 509f7f0d9b6b9eeedc69a4980c3aab4ccb8e80b9 Mon Sep 17 00:00:00 2001 From: azdful Date: Wed, 23 Jul 2025 11:09:44 -0700 Subject: [PATCH] feat: selling for Dirac (CrewShipFusionPoints) (#2540) Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2540 Reviewed-by: Sainan <63328889+sainan@users.noreply.github.com> Co-authored-by: azdful Co-committed-by: azdful --- src/controllers/api/sellController.ts | 10 ++++++++-- src/models/inventoryModels/inventoryModel.ts | 2 ++ src/services/inventoryService.ts | 9 +++++++++ src/types/inventoryTypes/inventoryTypes.ts | 1 + 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/controllers/api/sellController.ts b/src/controllers/api/sellController.ts index 0dd52bf6b..461d83bda 100644 --- a/src/controllers/api/sellController.ts +++ b/src/controllers/api/sellController.ts @@ -9,7 +9,8 @@ import { freeUpSlot, combineInventoryChanges, addCrewShipRawSalvage, - addFusionPoints + addFusionPoints, + addCrewShipFusionPoints } from "@/src/services/inventoryService"; import { InventorySlot } from "@/src/types/inventoryTypes/inventoryTypes"; import { ExportDojoRecipes } from "warframe-public-export-plus"; @@ -26,6 +27,8 @@ export const sellController: RequestHandler = async (req, res) => { requiredFields.add("RegularCredits"); } else if (payload.SellCurrency == "SC_FusionPoints") { requiredFields.add("FusionPoints"); + } else if (payload.SellCurrency == "SC_CrewShipFusionPoints") { + requiredFields.add("CrewShipFusionPoints"); } else { requiredFields.add("MiscItems"); } @@ -79,6 +82,8 @@ export const sellController: RequestHandler = async (req, res) => { inventory.RegularCredits += payload.SellPrice; } else if (payload.SellCurrency == "SC_FusionPoints") { addFusionPoints(inventory, payload.SellPrice); + } else if (payload.SellCurrency == "SC_CrewShipFusionPoints") { + addCrewShipFusionPoints(inventory, payload.SellPrice); } else if (payload.SellCurrency == "SC_PrimeBucks") { addMiscItems(inventory, [ { @@ -330,7 +335,8 @@ interface ISellRequest { | "SC_FusionPoints" | "SC_DistillPoints" | "SC_CrewShipFusionPoints" - | "SC_Resources"; + | "SC_Resources" + | "somethingelsewemightnotknowabout"; buildLabel: string; } diff --git a/src/models/inventoryModels/inventoryModel.ts b/src/models/inventoryModels/inventoryModel.ts index 4fb863a6c..fcd7f08e0 100644 --- a/src/models/inventoryModels/inventoryModel.ts +++ b/src/models/inventoryModels/inventoryModel.ts @@ -1437,6 +1437,8 @@ const inventorySchema = new Schema( PremiumCreditsFree: { type: Number, default: 0 }, //Endo FusionPoints: { type: Number, default: 0 }, + //Dirac + CrewShipFusionPoints: { type: Number, default: 0 }, //Regal Aya PrimeTokens: { type: Number, default: 0 }, diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts index 94736a08e..681ed578d 100644 --- a/src/services/inventoryService.ts +++ b/src/services/inventoryService.ts @@ -1241,6 +1241,15 @@ export const addFusionPoints = (inventory: TInventoryDatabaseDocument, add: numb return add; }; +export const addCrewShipFusionPoints = (inventory: TInventoryDatabaseDocument, add: number): number => { + if (inventory.CrewShipFusionPoints + add > 2147483647) { + logger.warn(`capping CrewShipFusionPoints balance at 2147483647`); + add = 2147483647 - inventory.CrewShipFusionPoints; + } + inventory.CrewShipFusionPoints += add; + return add; +}; + const standingLimitBinToInventoryKey: Record< Exclude, keyof IDailyAffiliations diff --git a/src/types/inventoryTypes/inventoryTypes.ts b/src/types/inventoryTypes/inventoryTypes.ts index 9df4e4ba6..1da1eaff0 100644 --- a/src/types/inventoryTypes/inventoryTypes.ts +++ b/src/types/inventoryTypes/inventoryTypes.ts @@ -215,6 +215,7 @@ export interface IInventoryClient extends IDailyAffiliations, InventoryClientEqu PremiumCredits: number; PremiumCreditsFree: number; FusionPoints: number; + CrewShipFusionPoints: number; //Dirac (pre-rework Railjack) PrimeTokens: number; SuitBin: ISlots; WeaponBin: ISlots;