From 2e8c94d34b3bde755920684f0971d2ca5f597a2d Mon Sep 17 00:00:00 2001 From: Sainan Date: Tue, 28 May 2024 13:28:35 +0200 Subject: [PATCH] feat: add spoofMasteryRank config (#229) Co-authored-by: Sainan --- config.json.example | 3 ++- src/controllers/api/inventoryController.ts | 23 ++++++++++++++++++++++ src/services/configService.ts | 1 + 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/config.json.example b/config.json.example index fa7c3449..651d971b 100644 --- a/config.json.example +++ b/config.json.example @@ -17,5 +17,6 @@ "infiniteResources": true, "unlockallShipFeatures": true, "unlockAllShipDecorations": true, - "unlockAllFlavourItems": true + "unlockAllFlavourItems": true, + "spoofMasteryRank": -1 } diff --git a/src/controllers/api/inventoryController.ts b/src/controllers/api/inventoryController.ts index d3dddd2a..4f64314a 100644 --- a/src/controllers/api/inventoryController.ts +++ b/src/controllers/api/inventoryController.ts @@ -51,7 +51,30 @@ const inventoryController: RequestHandler = async (request: Request, response: R if (config.unlockAllShipDecorations) inventoryResponse.ShipDecorations = allShipDecorations; if (config.unlockAllFlavourItems) inventoryResponse.FlavourItems = allFlavourItems satisfies IFlavourItem[]; + if ( + typeof config.spoofMasteryRank === "number" && + config.spoofMasteryRank >= 0 && + config.spoofMasteryRank <= 5030 + ) { + inventoryResponse.PlayerLevel = config.spoofMasteryRank; + inventoryResponse.XPInfo = []; + let numFrames = getExpRequiredForMr(config.spoofMasteryRank) / 6000; + while (numFrames-- > 0) { + inventoryResponse.XPInfo.push({ + ItemType: "/Lotus/Powersuits/Mag/Mag", + XP: 1_600_000 + }); + } + } + response.json(inventoryResponse); }; +const getExpRequiredForMr = (rank: number): number => { + if (rank <= 30) { + return 2500 * rank * rank; + } + return 2_250_000 + 147_500 * (rank - 30); +}; + export { inventoryController }; diff --git a/src/services/configService.ts b/src/services/configService.ts index a5787c30..f6f7509a 100644 --- a/src/services/configService.ts +++ b/src/services/configService.ts @@ -16,6 +16,7 @@ interface IConfig { unlockallShipFeatures?: boolean; unlockAllShipDecorations?: boolean; unlockAllFlavourItems?: boolean; + spoofMasteryRank?: number; } interface ILoggerConfig {