XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

SpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 1 Star 0
返回提交历史

XFEstudio/SpaceNinjaServer

feat: infiniteHelminthMaterials cheat (#985)

Closes #728 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/985 Co-authored-by: Sainan <sainan@calamity.inc> Co-committed-by: Sainan <sainan@calamity.inc>

9203e0bf
Sainan <sainan@calamity.inc>
提交于

代码差异

8 个文件 +73 -20
Modified config.json.example +1 -0
@@ -20,6 +20,7 @@
20 20 "infinitePlatinum": true,
21 21 "infiniteEndo": true,
22 22 "infiniteRegalAya": true,
23 "infiniteHelminthMaterials": false,
23 24 "unlockAllShipFeatures": true,
24 25 "unlockAllShipDecorations": true,
25 26 "unlockAllFlavourItems": true,
Modified src/controllers/api/infestedFoundryController.ts +55 -17
@@ -6,7 +6,9 @@ import { IOid } from "@/src/types/commonTypes";
6 6 import {
7 7 IConsumedSuit,
8 8 IHelminthFoodRecord,
9 IInfestedFoundryClient,
9 10 IInfestedFoundryDatabase,
11 IInventoryClient,
10 12 IMiscItem,
11 13 ITypeCount
12 14 } from "@/src/types/inventoryTypes/inventoryTypes";
@@ -16,6 +18,7 @@ import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/invento
16 18 import { toMongoDate } from "@/src/helpers/inventoryHelpers";
17 19 import { logger } from "@/src/utils/logger";
18 20 import { colorToShard } from "@/src/helpers/shardHelper";
21 import { config } from "@/src/services/configService";
19 22
20 23 export const infestedFoundryController: RequestHandler = async (req, res) => {
21 24 const accountId = await getAccountIdForRequest(req);
@@ -69,18 +72,22 @@ export const infestedFoundryController: RequestHandler = async (req, res) => {
69 72 // remove from suit
70 73 suit.ArchonCrystalUpgrades![request.Slot] = {};
71 74
72 // remove bile
73 const bile = inventory.InfestedFoundry!.Resources!.find(
74 x => x.ItemType == "/Lotus/Types/Items/InfestedFoundry/HelminthBile"
75 )!;
76 bile.Count -= 300;
75 if (!config.infiniteHelminthMaterials) {
76 // remove bile
77 const bile = inventory.InfestedFoundry!.Resources!.find(
78 x => x.ItemType == "/Lotus/Types/Items/InfestedFoundry/HelminthBile"
79 )!;
80 bile.Count -= 300;
81 }
77 82
78 83 await inventory.save();
79 84
85 const infestedFoundry = inventory.toJSON<IInventoryClient>().InfestedFoundry!;
86 applyCheatsToInfestedFoundry(infestedFoundry);
80 87 res.json({
81 88 InventoryChanges: {
82 89 MiscItems: miscItemChanges,
83 InfestedFoundry: inventory.toJSON().InfestedFoundry
90 InfestedFoundry: infestedFoundry
84 91 }
85 92 });
86 93 break;
@@ -105,6 +112,12 @@ export const infestedFoundryController: RequestHandler = async (req, res) => {
105 112
106 113 case "c": {
107 114 // consume items
115
116 if (config.infiniteHelminthMaterials) {
117 res.status(400).end();
118 return;
119 }
120
108 121 const request = getJSONfromString<IHelminthFeedRequest>(String(req.body));
109 122 const inventory = await getInventory(accountId);
110 123 inventory.InfestedFoundry ??= {};
@@ -210,9 +223,11 @@ export const infestedFoundryController: RequestHandler = async (req, res) => {
210 223 inventory.InfestedFoundry.InvigorationsApplied = 0;
211 224 }
212 225 await inventory.save();
226 const infestedFoundry = inventory.toJSON<IInventoryClient>().InfestedFoundry!;
227 applyCheatsToInfestedFoundry(infestedFoundry);
213 228 res.json({
214 229 InventoryChanges: {
215 InfestedFoundry: inventory.toJSON().InfestedFoundry
230 InfestedFoundry: infestedFoundry
216 231 }
217 232 });
218 233 break;
@@ -223,10 +238,12 @@ export const infestedFoundryController: RequestHandler = async (req, res) => {
223 238 const request = getJSONfromString<IHelminthSubsumeRequest>(String(req.body));
224 239 const inventory = await getInventory(accountId);
225 240 const recipe = getRecipe(request.Recipe)!;
226 for (const ingredient of recipe.secretIngredients!) {
227 const resource = inventory.InfestedFoundry!.Resources!.find(x => x.ItemType == ingredient.ItemType);
228 if (resource) {
229 resource.Count -= ingredient.ItemCount;
241 if (!config.infiniteHelminthMaterials) {
242 for (const ingredient of recipe.secretIngredients!) {
243 const resource = inventory.InfestedFoundry!.Resources!.find(x => x.ItemType == ingredient.ItemType);
244 if (resource) {
245 resource.Count -= ingredient.ItemCount;
246 }
230 247 }
231 248 }
232 249 const suit = inventory.Suits.id(request.SuitId.$oid)!;
@@ -247,6 +264,8 @@ export const infestedFoundryController: RequestHandler = async (req, res) => {
247 264 const recipeChanges = addInfestedFoundryXP(inventory.InfestedFoundry!, 1600_00);
248 265 addRecipes(inventory, recipeChanges);
249 266 await inventory.save();
267 const infestedFoundry = inventory.toJSON<IInventoryClient>().InfestedFoundry!;
268 applyCheatsToInfestedFoundry(infestedFoundry);
250 269 res.json({
251 270 InventoryChanges: {
252 271 Recipes: recipeChanges,
@@ -260,7 +279,7 @@ export const infestedFoundryController: RequestHandler = async (req, res) => {
260 279 platinum: 0,
261 280 Slots: 1
262 281 },
263 InfestedFoundry: inventory.toJSON().InfestedFoundry
282 InfestedFoundry: infestedFoundry
264 283 }
265 284 });
266 285 break;
@@ -272,11 +291,13 @@ export const infestedFoundryController: RequestHandler = async (req, res) => {
272 291 const currencyChanges = updateCurrency(inventory, 50, true);
273 292 const recipeChanges = handleSubsumeCompletion(inventory);
274 293 await inventory.save();
294 const infestedFoundry = inventory.toJSON<IInventoryClient>().InfestedFoundry!;
295 applyCheatsToInfestedFoundry(infestedFoundry);
275 296 res.json({
276 297 InventoryChanges: {
277 298 ...currencyChanges,
278 299 Recipes: recipeChanges,
279 InfestedFoundry: inventory.toJSON().InfestedFoundry
300 InfestedFoundry: infestedFoundry
280 301 }
281 302 });
282 303 break;
@@ -292,13 +313,17 @@ export const infestedFoundryController: RequestHandler = async (req, res) => {
292 313 suit.UpgradesExpiry = upgradesExpiry;
293 314 const recipeChanges = addInfestedFoundryXP(inventory.InfestedFoundry!, 4800_00);
294 315 addRecipes(inventory, recipeChanges);
295 for (let i = 0; i != request.ResourceTypes.length; ++i) {
296 inventory.InfestedFoundry!.Resources!.find(x => x.ItemType == request.ResourceTypes[i])!.Count -=
297 request.ResourceCosts[i];
316 if (!config.infiniteHelminthMaterials) {
317 for (let i = 0; i != request.ResourceTypes.length; ++i) {
318 inventory.InfestedFoundry!.Resources!.find(x => x.ItemType == request.ResourceTypes[i])!.Count -=
319 request.ResourceCosts[i];
320 }
298 321 }
299 322 inventory.InfestedFoundry!.InvigorationsApplied ??= 0;
300 323 inventory.InfestedFoundry!.InvigorationsApplied += 1;
301 324 await inventory.save();
325 const infestedFoundry = inventory.toJSON<IInventoryClient>().InfestedFoundry!;
326 applyCheatsToInfestedFoundry(infestedFoundry);
302 327 res.json({
303 328 SuitId: request.SuitId,
304 329 OffensiveUpgrade: request.OffensiveUpgradeType,
@@ -306,7 +331,7 @@ export const infestedFoundryController: RequestHandler = async (req, res) => {
306 331 UpgradesExpiry: toMongoDate(upgradesExpiry),
307 332 InventoryChanges: {
308 333 Recipes: recipeChanges,
309 InfestedFoundry: inventory.toJSON().InfestedFoundry
334 InfestedFoundry: infestedFoundry
310 335 }
311 336 });
312 337 break;
@@ -453,6 +478,19 @@ export const handleSubsumeCompletion = (inventory: TInventoryDatabaseDocument):
453 478 return recipeChanges;
454 479 };
455 480
481 export const applyCheatsToInfestedFoundry = (infestedFoundry: IInfestedFoundryClient): void => {
482 if (config.infiniteHelminthMaterials) {
483 infestedFoundry.Resources = [
484 { ItemType: "/Lotus/Types/Items/InfestedFoundry/HelminthCalx", Count: 1000 },
485 { ItemType: "/Lotus/Types/Items/InfestedFoundry/HelminthBiotics", Count: 1000 },
486 { ItemType: "/Lotus/Types/Items/InfestedFoundry/HelminthSynthetics", Count: 1000 },
487 { ItemType: "/Lotus/Types/Items/InfestedFoundry/HelminthPheromones", Count: 1000 },
488 { ItemType: "/Lotus/Types/Items/InfestedFoundry/HelminthBile", Count: 1000 },
489 { ItemType: "/Lotus/Types/Items/InfestedFoundry/HelminthOxides", Count: 1000 }
490 ];
491 }
492 };
493
456 494 interface IHelminthOfferingsUpdate {
457 495 OfferingsIndex: number;
458 496 SuitTypes: string[];
Modified src/controllers/api/inventoryController.ts +5 -1
@@ -13,7 +13,7 @@ import {
13 13 ExportResources,
14 14 ExportVirtuals
15 15 } from "warframe-public-export-plus";
16 import { handleSubsumeCompletion } from "./infestedFoundryController";
16 import { applyCheatsToInfestedFoundry, handleSubsumeCompletion } from "./infestedFoundryController";
17 17 import { allDailyAffiliationKeys } from "@/src/services/inventoryService";
18 18
19 19 export const inventoryController: RequestHandler = async (request, response) => {
@@ -212,6 +212,10 @@ export const getInventoryResponse = async (
212 212 }
213 213 }
214 214
215 if (inventoryResponse.InfestedFoundry) {
216 applyCheatsToInfestedFoundry(inventoryResponse.InfestedFoundry);
217 }
218
215 219 // Fix for #380
216 220 inventoryResponse.NextRefill = { $date: { $numberLong: "9999999999999" } };
217 221
Modified src/controllers/api/upgradesController.ts +5 -2
@@ -12,6 +12,7 @@ import { addMiscItems, addRecipes, getInventory, updateCurrency } from "@/src/se
12 12 import { getRecipeByResult } from "@/src/services/itemDataService";
13 13 import { IInventoryChanges } from "@/src/types/purchaseTypes";
14 14 import { addInfestedFoundryXP } from "./infestedFoundryController";
15 import { config } from "@/src/services/configService";
15 16
16 17 export const upgradesController: RequestHandler = async (req, res) => {
17 18 const accountId = await getAccountIdForRequest(req);
@@ -48,8 +49,10 @@ export const upgradesController: RequestHandler = async (req, res) => {
48 49 const recipe = getRecipeByResult(operation.UpgradeRequirement)!;
49 50 for (const ingredient of recipe.ingredients) {
50 51 totalPercentagePointsConsumed += ingredient.ItemCount / 10;
51 inventory.InfestedFoundry!.Resources!.find(x => x.ItemType == ingredient.ItemType)!.Count -=
52 ingredient.ItemCount;
52 if (!config.infiniteHelminthMaterials) {
53 inventory.InfestedFoundry!.Resources!.find(x => x.ItemType == ingredient.ItemType)!.Count -=
54 ingredient.ItemCount;
55 }
53 56 }
54 57 }
55 58
Modified src/services/configService.ts +1 -0
@@ -46,6 +46,7 @@ interface IConfig {
46 46 infinitePlatinum?: boolean;
47 47 infiniteEndo?: boolean;
48 48 infiniteRegalAya?: boolean;
49 infiniteHelminthMaterials?: boolean;
49 50 unlockAllShipFeatures?: boolean;
50 51 unlockAllShipDecorations?: boolean;
51 52 unlockAllFlavourItems?: boolean;
Modified static/webui/index.html +4 -0
@@ -473,6 +473,10 @@
473 473 <input class="form-check-input" type="checkbox" id="infiniteRegalAya" />
474 474 <label class="form-check-label" for="infiniteRegalAya" data-loc="cheats_infiniteRegalAya"></label>
475 475 </div>
476 <div class="form-check">
477 <input class="form-check-input" type="checkbox" id="infiniteHelminthMaterials" />
478 <label class="form-check-label" for="infiniteHelminthMaterials" data-loc="cheats_infiniteHelminthMaterials"></label>
479 </div>
476 480 <div class="form-check">
477 481 <input class="form-check-input" type="checkbox" id="unlockAllShipFeatures" />
478 482 <label class="form-check-label" for="unlockAllShipFeatures" data-loc="cheats_unlockAllShipFeatures"></label>
Modified static/webui/translations/en.js +1 -0
@@ -99,6 +99,7 @@ dict = {
99 99 cheats_infinitePlatinum: `Infinite Platinum`,
100 100 cheats_infiniteEndo: `Infinite Endo`,
101 101 cheats_infiniteRegalAya: `Infinite Regal Aya`,
102 cheats_infiniteHelminthMaterials: `Infinite Helminth Materials`,
102 103 cheats_unlockAllShipFeatures: `Unlock All Ship Features`,
103 104 cheats_unlockAllShipDecorations: `Unlock All Ship Decorations`,
104 105 cheats_unlockAllFlavourItems: `Unlock All <abbr title=\"Animation Sets, Glyphs, Plattes, etc.\">Flavor Items</abbr>`,
Modified static/webui/translations/ru.js +1 -0
@@ -100,6 +100,7 @@ dict = {
100 100 cheats_infinitePlatinum: `Бесконечная платина`,
101 101 cheats_infiniteEndo: `Бесконечное эндо`,
102 102 cheats_infiniteRegalAya: `Бесконечная Королевская Айя`,
103 cheats_infiniteHelminthMaterials: `[UNTRANSLATED] Infinite Helminth Materials`,
103 104 cheats_unlockAllShipFeatures: `Разблокировать все функции корабля`,
104 105 cheats_unlockAllShipDecorations: `Разблокировать все украшения корабля`,
105 106 cheats_unlockAllFlavourItems: `Разблокировать все <abbr title=\"Наборы анимаций, глифы, палитры и т. д.\">уникальные предметы</abbr>`,