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

XFESpaceNinjaServer

A simple server for a small space ninja game

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

XFEstudio/XFESpaceNinjaServer

chore: fix infiniteCredits & infiniteEndo being ignored in a few places (#3455)

Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3455 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

ac3f2ef0
Sainan <63328889+Sainan@users.noreply.github.com>
提交于

代码差异

4 个文件 +29 -15
Modified src/controllers/api/artifactTransmutationController.ts +10 -3
@@ -1,6 +1,13 @@
1 1 import { fromOid, toOid2 } from "../../helpers/inventoryHelpers.ts";
2 2 import { createVeiledRivenFingerprint, rivenRawToRealWeighted } from "../../helpers/rivenHelper.ts";
3 import { addMiscItems, addMods, getInventory } from "../../services/inventoryService.ts";
3 import {
4 addFusionPoints,
5 addMiscItems,
6 addMods,
7 CurrencyType,
8 getInventory,
9 updateCurrency
10 } from "../../services/inventoryService.ts";
4 11 import { getAccountForRequest } from "../../services/loginService.ts";
5 12 import { getRandomElement, getRandomWeightedRewardUc } from "../../services/rngService.ts";
6 13 import type { IUpgradeFromClient } from "../../types/inventoryTypes/inventoryTypes.ts";
@@ -14,9 +21,9 @@ export const artifactTransmutationController: RequestHandler = async (req, res)
14 21 const inventory = await getInventory(accountId);
15 22 const payload = JSON.parse(String(req.body)) as IArtifactTransmutationRequest;
16 23
17 inventory.RegularCredits -= payload.Cost;
24 updateCurrency(inventory, payload.Cost, CurrencyType.CREDITS);
18 25 if (payload.FusionPointCost) {
19 inventory.FusionPoints -= payload.FusionPointCost;
26 addFusionPoints(inventory, -payload.FusionPointCost);
20 27 }
21 28
22 29 if (payload.RivenTransmute) {
Modified src/controllers/api/artifactsController.ts +9 -5
@@ -6,7 +6,13 @@ import type {
6 6 IUpgradeClient,
7 7 IUpgradeFromClient
8 8 } from "../../types/inventoryTypes/inventoryTypes.ts";
9 import { addMods, getInventory } from "../../services/inventoryService.ts";
9 import {
10 addFusionPoints,
11 addMods,
12 CurrencyType,
13 getInventory,
14 updateCurrency
15 } from "../../services/inventoryService.ts";
10 16 import { broadcastInventoryUpdate } from "../../services/wsService.ts";
11 17 import { fromOid, version_compare } from "../../helpers/inventoryHelpers.ts";
12 18 import gameToBuildVersion from "../../constants/gameToBuildVersion.ts";
@@ -46,11 +52,9 @@ export const artifactsController: RequestHandler = async (req, res) => {
46 52 addMods(inventory, [{ ItemType, ItemCount: -1 }]);
47 53 }
48 54
49 if (!inventory.infiniteCredits) {
50 inventory.RegularCredits -= Cost;
51 }
55 updateCurrency(inventory, Cost, CurrencyType.CREDITS);
52 56 if (!inventory.infiniteEndo) {
53 inventory.FusionPoints -= FusionPointCost;
57 addFusionPoints(inventory, -FusionPointCost);
54 58 }
55 59
56 60 if (artifactsData.LegendaryFusion) {
Modified src/services/inventoryService.ts +8 -4
@@ -1640,11 +1640,15 @@ export const updateCurrency = (
1640 1640 };
1641 1641
1642 1642 export const addFusionPoints = (inventory: TInventoryDatabaseDocument, add: number): number => {
1643 if (inventory.FusionPoints + add > 2147483647) {
1644 logger.warn(`capping FusionPoints balance at 2147483647`);
1645 add = 2147483647 - inventory.FusionPoints;
1643 if (inventory.infiniteEndo) {
1644 add = 0;
1645 } else {
1646 if (inventory.FusionPoints + add > 2147483647) {
1647 logger.warn(`capping FusionPoints balance at 2147483647`);
1648 add = 2147483647 - inventory.FusionPoints;
1649 }
1650 inventory.FusionPoints += add;
1646 1651 }
1647 inventory.FusionPoints += add;
1648 1652 return add;
1649 1653 };
1650 1654
Modified src/services/missionInventoryUpdateService.ts +2 -3
@@ -43,6 +43,7 @@ import {
43 43 addStanding,
44 44 applyClientEquipmentUpdates,
45 45 combineInventoryChanges,
46 CurrencyType,
46 47 getDialogue,
47 48 giveNemesisPetRecipe,
48 49 giveNemesisWeaponRecipe,
@@ -683,9 +684,7 @@ export const addMissionInventoryUpdates = async (
683 684 break;
684 685 }
685 686 case "creditsFee": {
686 updateCurrency(inventory, value, false);
687 inventoryChanges.RegularCredits ??= 0;
688 inventoryChanges.RegularCredits -= value;
687 updateCurrency(inventory, value, CurrencyType.CREDITS, inventoryChanges);
689 688 break;
690 689 }
691 690 case "GoalProgress": {