返回提交历史
Modified
config.json.example
+1
-0
Modified
src/controllers/api/claimCompletedRecipeController.ts
+42
-29
Modified
src/services/configService.ts
+1
-0
Modified
src/services/inventoryService.ts
+15
-10
Modified
static/webui/index.html
+4
-0
Modified
static/webui/translations/de.js
+1
-0
Modified
static/webui/translations/en.js
+1
-0
Modified
static/webui/translations/es.js
+1
-0
Modified
static/webui/translations/fr.js
+1
-0
Modified
static/webui/translations/ru.js
+1
-0
Modified
static/webui/translations/zh.js
+1
-0
XFEstudio/XFESpaceNinjaServer
feat: claimingBlueprintRefundsIngredients cheat (#2034)
Closes #1922 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2034 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
3d13ec31
代码差异
11 个文件
+69
-39
@@ -19,6 +19,7 @@
19
19
"infiniteEndo": false,
20
20
"infiniteRegalAya": false,
21
21
"infiniteHelminthMaterials": false,
22
"claimingBlueprintRefundsIngredients": false,
22
23
"dontSubtractConsumables": false,
23
24
"unlockAllShipFeatures": false,
24
25
"unlockAllShipDecorations": false,
@@ -17,8 +17,11 @@ import {
17
17
} from "@/src/services/inventoryService";
18
18
import { IInventoryChanges } from "@/src/types/purchaseTypes";
19
19
import { IEquipmentClient } from "@/src/types/inventoryTypes/commonInventoryTypes";
20
import { InventorySlot } from "@/src/types/inventoryTypes/inventoryTypes";
20
import { InventorySlot, IPendingRecipeDatabase } from "@/src/types/inventoryTypes/inventoryTypes";
21
21
import { toOid2 } from "@/src/helpers/inventoryHelpers";
22
import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel";
23
import { IRecipe } from "warframe-public-export-plus";
24
import { config } from "@/src/services/configService";
22
25
23
26
interface IClaimCompletedRecipeRequest {
24
27
RecipeIds: IOid[];
@@ -46,34 +49,8 @@ export const claimCompletedRecipeController: RequestHandler = async (req, res) =
46
49
}
47
50
48
51
if (req.query.cancel) {
49
const inventoryChanges: IInventoryChanges = {
50
...updateCurrency(inventory, recipe.buildPrice * -1, false)
51
};
52
53
const equipmentIngredients = new Set();
54
for (const category of ["LongGuns", "Pistols", "Melee"] as const) {
55
if (pendingRecipe[category]) {
56
pendingRecipe[category].forEach(item => {
57
const index = inventory[category].push(item) - 1;
58
inventoryChanges[category] ??= [];
59
inventoryChanges[category].push(inventory[category][index].toJSON<IEquipmentClient>());
60
equipmentIngredients.add(item.ItemType);
61
62
occupySlot(inventory, InventorySlot.WEAPONS, false);
63
inventoryChanges.WeaponBin ??= { Slots: 0 };
64
inventoryChanges.WeaponBin.Slots -= 1;
65
});
66
}
67
}
68
for (const ingredient of recipe.ingredients) {
69
if (!equipmentIngredients.has(ingredient.ItemType)) {
70
combineInventoryChanges(
71
inventoryChanges,
72
await addItem(inventory, ingredient.ItemType, ingredient.ItemCount)
73
);
74
}
75
}
76
52
const inventoryChanges: IInventoryChanges = {};
53
await refundRecipeIngredients(inventory, inventoryChanges, recipe, pendingRecipe);
77
54
await inventory.save();
78
55
res.json(inventoryChanges); // Not a bug: In the specific case of cancelling a recipe, InventoryChanges are expected to be the root.
79
56
} else {
@@ -141,7 +118,43 @@ export const claimCompletedRecipeController: RequestHandler = async (req, res) =
141
118
))
142
119
};
143
120
}
121
if (config.claimingBlueprintRefundsIngredients) {
122
await refundRecipeIngredients(inventory, InventoryChanges, recipe, pendingRecipe);
123
}
144
124
await inventory.save();
145
125
res.json({ InventoryChanges, BrandedSuits });
146
126
}
147
127
};
128
129
const refundRecipeIngredients = async (
130
inventory: TInventoryDatabaseDocument,
131
inventoryChanges: IInventoryChanges,
132
recipe: IRecipe,
133
pendingRecipe: IPendingRecipeDatabase
134
): Promise<void> => {
135
updateCurrency(inventory, recipe.buildPrice * -1, false, inventoryChanges);
136
137
const equipmentIngredients = new Set();
138
for (const category of ["LongGuns", "Pistols", "Melee"] as const) {
139
if (pendingRecipe[category]) {
140
pendingRecipe[category].forEach(item => {
141
const index = inventory[category].push(item) - 1;
142
inventoryChanges[category] ??= [];
143
inventoryChanges[category].push(inventory[category][index].toJSON<IEquipmentClient>());
144
equipmentIngredients.add(item.ItemType);
145
146
occupySlot(inventory, InventorySlot.WEAPONS, false);
147
inventoryChanges.WeaponBin ??= { Slots: 0 };
148
inventoryChanges.WeaponBin.Slots -= 1;
149
});
150
}
151
}
152
for (const ingredient of recipe.ingredients) {
153
if (!equipmentIngredients.has(ingredient.ItemType)) {
154
combineInventoryChanges(
155
inventoryChanges,
156
await addItem(inventory, ingredient.ItemType, ingredient.ItemCount)
157
);
158
}
159
}
160
};
@@ -24,6 +24,7 @@ interface IConfig {
24
24
infiniteEndo?: boolean;
25
25
infiniteRegalAya?: boolean;
26
26
infiniteHelminthMaterials?: boolean;
27
claimingBlueprintRefundsIngredients?: boolean;
27
28
dontSubtractConsumables?: boolean;
28
29
unlockAllShipFeatures?: boolean;
29
30
unlockAllShipDecorations?: boolean;
@@ -1113,24 +1113,29 @@ const isCurrencyTracked = (usePremium: boolean): boolean => {
1113
1113
export const updateCurrency = (
1114
1114
inventory: TInventoryDatabaseDocument,
1115
1115
price: number,
1116
usePremium: boolean
1116
usePremium: boolean,
1117
inventoryChanges: IInventoryChanges = {}
1117
1118
): IInventoryChanges => {
1118
const currencyChanges: IInventoryChanges = {};
1119
1119
if (price != 0 && isCurrencyTracked(usePremium)) {
1120
1120
if (usePremium) {
1121
1121
if (inventory.PremiumCreditsFree > 0) {
1122
currencyChanges.PremiumCreditsFree = Math.min(price, inventory.PremiumCreditsFree) * -1;
1123
inventory.PremiumCreditsFree += currencyChanges.PremiumCreditsFree;
1122
const premiumCreditsFreeDelta = Math.min(price, inventory.PremiumCreditsFree) * -1;
1123
inventoryChanges.PremiumCreditsFree ??= 0;
1124
inventoryChanges.PremiumCreditsFree += premiumCreditsFreeDelta;
1125
inventory.PremiumCreditsFree += premiumCreditsFreeDelta;
1124
1126
}
1125
currencyChanges.PremiumCredits = -price;
1126
inventory.PremiumCredits += currencyChanges.PremiumCredits;
1127
inventoryChanges.PremiumCredits ??= 0;
1128
inventoryChanges.PremiumCredits -= price;
1129
inventory.PremiumCredits -= price;
1130
logger.debug(`currency changes `, { PremiumCredits: -price });
1127
1131
} else {
1128
currencyChanges.RegularCredits = -price;
1129
inventory.RegularCredits += currencyChanges.RegularCredits;
1132
inventoryChanges.RegularCredits ??= 0;
1133
inventoryChanges.RegularCredits -= price;
1134
inventory.RegularCredits -= price;
1135
logger.debug(`currency changes `, { RegularCredits: -price });
1130
1136
}
1131
logger.debug(`currency changes `, currencyChanges);
1132
1137
}
1133
return currencyChanges;
1138
return inventoryChanges;
1134
1139
};
1135
1140
1136
1141
export const addFusionPoints = (inventory: TInventoryDatabaseDocument, add: number): number => {
@@ -590,6 +590,10 @@
590
590
<input class="form-check-input" type="checkbox" id="infiniteRegalAya" />
591
591
<label class="form-check-label" for="infiniteRegalAya" data-loc="cheats_infiniteRegalAya"></label>
592
592
</div>
593
<div class="form-check">
594
<input class="form-check-input" type="checkbox" id="claimingBlueprintRefundsIngredients" />
595
<label class="form-check-label" for="claimingBlueprintRefundsIngredients" data-loc="cheats_claimingBlueprintRefundsIngredients"></label>
596
</div>
593
597
<div class="form-check">
594
598
<input class="form-check-input" type="checkbox" id="infiniteHelminthMaterials" />
595
599
<label class="form-check-label" for="infiniteHelminthMaterials" data-loc="cheats_infiniteHelminthMaterials"></label>
@@ -131,6 +131,7 @@ dict = {
131
131
cheats_infiniteEndo: `Unendlich Endo`,
132
132
cheats_infiniteRegalAya: `Unendlich Reines Aya`,
133
133
cheats_infiniteHelminthMaterials: `Unendlich Helminth-Materialien`,
134
cheats_claimingBlueprintRefundsIngredients: `[UNTRANSLATED] Claiming Blueprint Refunds Ingredients`,
134
135
cheats_dontSubtractConsumables: `Verbrauchsgegenstände (Ausrüstung) nicht verbrauchen`,
135
136
cheats_unlockAllShipFeatures: `Alle Schiffs-Funktionen freischalten`,
136
137
cheats_unlockAllShipDecorations: `Alle Schiffsdekorationen freischalten`,
@@ -130,6 +130,7 @@ dict = {
130
130
cheats_infiniteEndo: `Infinite Endo`,
131
131
cheats_infiniteRegalAya: `Infinite Regal Aya`,
132
132
cheats_infiniteHelminthMaterials: `Infinite Helminth Materials`,
133
cheats_claimingBlueprintRefundsIngredients: `Claiming Blueprint Refunds Ingredients`,
133
134
cheats_dontSubtractConsumables: `Don't Subtract Consumables`,
134
135
cheats_unlockAllShipFeatures: `Unlock All Ship Features`,
135
136
cheats_unlockAllShipDecorations: `Unlock All Ship Decorations`,
@@ -131,6 +131,7 @@ dict = {
131
131
cheats_infiniteEndo: `Endo infinito`,
132
132
cheats_infiniteRegalAya: `Aya Real infinita`,
133
133
cheats_infiniteHelminthMaterials: `Materiales Helminto infinitos`,
134
cheats_claimingBlueprintRefundsIngredients: `[UNTRANSLATED] Claiming Blueprint Refunds Ingredients`,
134
135
cheats_dontSubtractConsumables: `No restar consumibles`,
135
136
cheats_unlockAllShipFeatures: `Desbloquear todas las funciones de nave`,
136
137
cheats_unlockAllShipDecorations: `Desbloquear todas las decoraciones de nave`,
@@ -131,6 +131,7 @@ dict = {
131
131
cheats_infiniteEndo: `Endo infini`,
132
132
cheats_infiniteRegalAya: `Aya Raffiné infini`,
133
133
cheats_infiniteHelminthMaterials: `Ressources d'Helminth infinies`,
134
cheats_claimingBlueprintRefundsIngredients: `[UNTRANSLATED] Claiming Blueprint Refunds Ingredients`,
134
135
cheats_dontSubtractConsumables: `[UNTRANSLATED] Don't Subtract Consumables`,
135
136
cheats_unlockAllShipFeatures: `Débloquer tous les segments du vaisseau`,
136
137
cheats_unlockAllShipDecorations: `Débloquer toutes les décorations du vaisseau`,
@@ -131,6 +131,7 @@ dict = {
131
131
cheats_infiniteEndo: `Бесконечное эндо`,
132
132
cheats_infiniteRegalAya: `Бесконечная Королевская Айя`,
133
133
cheats_infiniteHelminthMaterials: `Бесконечные Выделения Гельминта`,
134
cheats_claimingBlueprintRefundsIngredients: `[UNTRANSLATED] Claiming Blueprint Refunds Ingredients`,
134
135
cheats_dontSubtractConsumables: `Не уменьшать количество расходников`,
135
136
cheats_unlockAllShipFeatures: `Разблокировать все функции корабля`,
136
137
cheats_unlockAllShipDecorations: `Разблокировать все украшения корабля`,
@@ -131,6 +131,7 @@ dict = {
131
131
cheats_infiniteEndo: `无限内融核心`,
132
132
cheats_infiniteRegalAya: `无限御品阿耶`,
133
133
cheats_infiniteHelminthMaterials: `无限Helminth材料`,
134
cheats_claimingBlueprintRefundsIngredients: `[UNTRANSLATED] Claiming Blueprint Refunds Ingredients`,
134
135
cheats_dontSubtractConsumables: `[UNTRANSLATED] Don't Subtract Consumables`,
135
136
cheats_unlockAllShipFeatures: `解锁所有飞船功能`,
136
137
cheats_unlockAllShipDecorations: `解锁所有飞船装饰`,