From 9203e0bf4d0947895093c0b0f5925ecf73181e1b Mon Sep 17 00:00:00 2001 From: Sainan Date: Sat, 22 Feb 2025 11:09:17 -0800 Subject: [PATCH] feat: infiniteHelminthMaterials cheat (#985) Closes #728 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/985 Co-authored-by: Sainan Co-committed-by: Sainan --- config.json.example | 1 + .../api/infestedFoundryController.ts | 72 ++++++++++++++----- src/controllers/api/inventoryController.ts | 6 +- src/controllers/api/upgradesController.ts | 7 +- src/services/configService.ts | 1 + static/webui/index.html | 4 ++ static/webui/translations/en.js | 1 + static/webui/translations/ru.js | 1 + 8 files changed, 73 insertions(+), 20 deletions(-) diff --git a/config.json.example b/config.json.example index ec776374..1bd3b1c1 100644 --- a/config.json.example +++ b/config.json.example @@ -20,6 +20,7 @@ "infinitePlatinum": true, "infiniteEndo": true, "infiniteRegalAya": true, + "infiniteHelminthMaterials": false, "unlockAllShipFeatures": true, "unlockAllShipDecorations": true, "unlockAllFlavourItems": true, diff --git a/src/controllers/api/infestedFoundryController.ts b/src/controllers/api/infestedFoundryController.ts index 5e27f1c9..f79587b5 100644 --- a/src/controllers/api/infestedFoundryController.ts +++ b/src/controllers/api/infestedFoundryController.ts @@ -6,7 +6,9 @@ import { IOid } from "@/src/types/commonTypes"; import { IConsumedSuit, IHelminthFoodRecord, + IInfestedFoundryClient, IInfestedFoundryDatabase, + IInventoryClient, IMiscItem, ITypeCount } from "@/src/types/inventoryTypes/inventoryTypes"; @@ -16,6 +18,7 @@ import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/invento import { toMongoDate } from "@/src/helpers/inventoryHelpers"; import { logger } from "@/src/utils/logger"; import { colorToShard } from "@/src/helpers/shardHelper"; +import { config } from "@/src/services/configService"; export const infestedFoundryController: RequestHandler = async (req, res) => { const accountId = await getAccountIdForRequest(req); @@ -69,18 +72,22 @@ export const infestedFoundryController: RequestHandler = async (req, res) => { // remove from suit suit.ArchonCrystalUpgrades![request.Slot] = {}; - // remove bile - const bile = inventory.InfestedFoundry!.Resources!.find( - x => x.ItemType == "/Lotus/Types/Items/InfestedFoundry/HelminthBile" - )!; - bile.Count -= 300; + if (!config.infiniteHelminthMaterials) { + // remove bile + const bile = inventory.InfestedFoundry!.Resources!.find( + x => x.ItemType == "/Lotus/Types/Items/InfestedFoundry/HelminthBile" + )!; + bile.Count -= 300; + } await inventory.save(); + const infestedFoundry = inventory.toJSON().InfestedFoundry!; + applyCheatsToInfestedFoundry(infestedFoundry); res.json({ InventoryChanges: { MiscItems: miscItemChanges, - InfestedFoundry: inventory.toJSON().InfestedFoundry + InfestedFoundry: infestedFoundry } }); break; @@ -105,6 +112,12 @@ export const infestedFoundryController: RequestHandler = async (req, res) => { case "c": { // consume items + + if (config.infiniteHelminthMaterials) { + res.status(400).end(); + return; + } + const request = getJSONfromString(String(req.body)); const inventory = await getInventory(accountId); inventory.InfestedFoundry ??= {}; @@ -210,9 +223,11 @@ export const infestedFoundryController: RequestHandler = async (req, res) => { inventory.InfestedFoundry.InvigorationsApplied = 0; } await inventory.save(); + const infestedFoundry = inventory.toJSON().InfestedFoundry!; + applyCheatsToInfestedFoundry(infestedFoundry); res.json({ InventoryChanges: { - InfestedFoundry: inventory.toJSON().InfestedFoundry + InfestedFoundry: infestedFoundry } }); break; @@ -223,10 +238,12 @@ export const infestedFoundryController: RequestHandler = async (req, res) => { const request = getJSONfromString(String(req.body)); const inventory = await getInventory(accountId); const recipe = getRecipe(request.Recipe)!; - for (const ingredient of recipe.secretIngredients!) { - const resource = inventory.InfestedFoundry!.Resources!.find(x => x.ItemType == ingredient.ItemType); - if (resource) { - resource.Count -= ingredient.ItemCount; + if (!config.infiniteHelminthMaterials) { + for (const ingredient of recipe.secretIngredients!) { + const resource = inventory.InfestedFoundry!.Resources!.find(x => x.ItemType == ingredient.ItemType); + if (resource) { + resource.Count -= ingredient.ItemCount; + } } } const suit = inventory.Suits.id(request.SuitId.$oid)!; @@ -247,6 +264,8 @@ export const infestedFoundryController: RequestHandler = async (req, res) => { const recipeChanges = addInfestedFoundryXP(inventory.InfestedFoundry!, 1600_00); addRecipes(inventory, recipeChanges); await inventory.save(); + const infestedFoundry = inventory.toJSON().InfestedFoundry!; + applyCheatsToInfestedFoundry(infestedFoundry); res.json({ InventoryChanges: { Recipes: recipeChanges, @@ -260,7 +279,7 @@ export const infestedFoundryController: RequestHandler = async (req, res) => { platinum: 0, Slots: 1 }, - InfestedFoundry: inventory.toJSON().InfestedFoundry + InfestedFoundry: infestedFoundry } }); break; @@ -272,11 +291,13 @@ export const infestedFoundryController: RequestHandler = async (req, res) => { const currencyChanges = updateCurrency(inventory, 50, true); const recipeChanges = handleSubsumeCompletion(inventory); await inventory.save(); + const infestedFoundry = inventory.toJSON().InfestedFoundry!; + applyCheatsToInfestedFoundry(infestedFoundry); res.json({ InventoryChanges: { ...currencyChanges, Recipes: recipeChanges, - InfestedFoundry: inventory.toJSON().InfestedFoundry + InfestedFoundry: infestedFoundry } }); break; @@ -292,13 +313,17 @@ export const infestedFoundryController: RequestHandler = async (req, res) => { suit.UpgradesExpiry = upgradesExpiry; const recipeChanges = addInfestedFoundryXP(inventory.InfestedFoundry!, 4800_00); addRecipes(inventory, recipeChanges); - for (let i = 0; i != request.ResourceTypes.length; ++i) { - inventory.InfestedFoundry!.Resources!.find(x => x.ItemType == request.ResourceTypes[i])!.Count -= - request.ResourceCosts[i]; + if (!config.infiniteHelminthMaterials) { + for (let i = 0; i != request.ResourceTypes.length; ++i) { + inventory.InfestedFoundry!.Resources!.find(x => x.ItemType == request.ResourceTypes[i])!.Count -= + request.ResourceCosts[i]; + } } inventory.InfestedFoundry!.InvigorationsApplied ??= 0; inventory.InfestedFoundry!.InvigorationsApplied += 1; await inventory.save(); + const infestedFoundry = inventory.toJSON().InfestedFoundry!; + applyCheatsToInfestedFoundry(infestedFoundry); res.json({ SuitId: request.SuitId, OffensiveUpgrade: request.OffensiveUpgradeType, @@ -306,7 +331,7 @@ export const infestedFoundryController: RequestHandler = async (req, res) => { UpgradesExpiry: toMongoDate(upgradesExpiry), InventoryChanges: { Recipes: recipeChanges, - InfestedFoundry: inventory.toJSON().InfestedFoundry + InfestedFoundry: infestedFoundry } }); break; @@ -453,6 +478,19 @@ export const handleSubsumeCompletion = (inventory: TInventoryDatabaseDocument): return recipeChanges; }; +export const applyCheatsToInfestedFoundry = (infestedFoundry: IInfestedFoundryClient): void => { + if (config.infiniteHelminthMaterials) { + infestedFoundry.Resources = [ + { ItemType: "/Lotus/Types/Items/InfestedFoundry/HelminthCalx", Count: 1000 }, + { ItemType: "/Lotus/Types/Items/InfestedFoundry/HelminthBiotics", Count: 1000 }, + { ItemType: "/Lotus/Types/Items/InfestedFoundry/HelminthSynthetics", Count: 1000 }, + { ItemType: "/Lotus/Types/Items/InfestedFoundry/HelminthPheromones", Count: 1000 }, + { ItemType: "/Lotus/Types/Items/InfestedFoundry/HelminthBile", Count: 1000 }, + { ItemType: "/Lotus/Types/Items/InfestedFoundry/HelminthOxides", Count: 1000 } + ]; + } +}; + interface IHelminthOfferingsUpdate { OfferingsIndex: number; SuitTypes: string[]; diff --git a/src/controllers/api/inventoryController.ts b/src/controllers/api/inventoryController.ts index df7cebcf..82b55ff5 100644 --- a/src/controllers/api/inventoryController.ts +++ b/src/controllers/api/inventoryController.ts @@ -13,7 +13,7 @@ import { ExportResources, ExportVirtuals } from "warframe-public-export-plus"; -import { handleSubsumeCompletion } from "./infestedFoundryController"; +import { applyCheatsToInfestedFoundry, handleSubsumeCompletion } from "./infestedFoundryController"; import { allDailyAffiliationKeys } from "@/src/services/inventoryService"; export const inventoryController: RequestHandler = async (request, response) => { @@ -212,6 +212,10 @@ export const getInventoryResponse = async ( } } + if (inventoryResponse.InfestedFoundry) { + applyCheatsToInfestedFoundry(inventoryResponse.InfestedFoundry); + } + // Fix for #380 inventoryResponse.NextRefill = { $date: { $numberLong: "9999999999999" } }; diff --git a/src/controllers/api/upgradesController.ts b/src/controllers/api/upgradesController.ts index d295a462..c29e20fa 100644 --- a/src/controllers/api/upgradesController.ts +++ b/src/controllers/api/upgradesController.ts @@ -12,6 +12,7 @@ import { addMiscItems, addRecipes, getInventory, updateCurrency } from "@/src/se import { getRecipeByResult } from "@/src/services/itemDataService"; import { IInventoryChanges } from "@/src/types/purchaseTypes"; import { addInfestedFoundryXP } from "./infestedFoundryController"; +import { config } from "@/src/services/configService"; export const upgradesController: RequestHandler = async (req, res) => { const accountId = await getAccountIdForRequest(req); @@ -48,8 +49,10 @@ export const upgradesController: RequestHandler = async (req, res) => { const recipe = getRecipeByResult(operation.UpgradeRequirement)!; for (const ingredient of recipe.ingredients) { totalPercentagePointsConsumed += ingredient.ItemCount / 10; - inventory.InfestedFoundry!.Resources!.find(x => x.ItemType == ingredient.ItemType)!.Count -= - ingredient.ItemCount; + if (!config.infiniteHelminthMaterials) { + inventory.InfestedFoundry!.Resources!.find(x => x.ItemType == ingredient.ItemType)!.Count -= + ingredient.ItemCount; + } } } diff --git a/src/services/configService.ts b/src/services/configService.ts index bb4d5c96..e1b9c984 100644 --- a/src/services/configService.ts +++ b/src/services/configService.ts @@ -46,6 +46,7 @@ interface IConfig { infinitePlatinum?: boolean; infiniteEndo?: boolean; infiniteRegalAya?: boolean; + infiniteHelminthMaterials?: boolean; unlockAllShipFeatures?: boolean; unlockAllShipDecorations?: boolean; unlockAllFlavourItems?: boolean; diff --git a/static/webui/index.html b/static/webui/index.html index 081ca3d2..0d4b3e95 100644 --- a/static/webui/index.html +++ b/static/webui/index.html @@ -473,6 +473,10 @@ +
+ + +
diff --git a/static/webui/translations/en.js b/static/webui/translations/en.js index 77cadccc..3251cd63 100644 --- a/static/webui/translations/en.js +++ b/static/webui/translations/en.js @@ -99,6 +99,7 @@ dict = { cheats_infinitePlatinum: `Infinite Platinum`, cheats_infiniteEndo: `Infinite Endo`, cheats_infiniteRegalAya: `Infinite Regal Aya`, + cheats_infiniteHelminthMaterials: `Infinite Helminth Materials`, cheats_unlockAllShipFeatures: `Unlock All Ship Features`, cheats_unlockAllShipDecorations: `Unlock All Ship Decorations`, cheats_unlockAllFlavourItems: `Unlock All Flavor Items`, diff --git a/static/webui/translations/ru.js b/static/webui/translations/ru.js index 408743d8..781046b9 100644 --- a/static/webui/translations/ru.js +++ b/static/webui/translations/ru.js @@ -100,6 +100,7 @@ dict = { cheats_infinitePlatinum: `Бесконечная платина`, cheats_infiniteEndo: `Бесконечное эндо`, cheats_infiniteRegalAya: `Бесконечная Королевская Айя`, + cheats_infiniteHelminthMaterials: `[UNTRANSLATED] Infinite Helminth Materials`, cheats_unlockAllShipFeatures: `Разблокировать все функции корабля`, cheats_unlockAllShipDecorations: `Разблокировать все украшения корабля`, cheats_unlockAllFlavourItems: `Разблокировать все уникальные предметы`,