返回提交历史
Modified
package-lock.json
+4
-4
Modified
package.json
+1
-1
Modified
src/controllers/api/infestedFoundryController.ts
+60
-0
Modified
src/models/inventoryModels/inventoryModel.ts
+4
-1
Modified
src/types/inventoryTypes/inventoryTypes.ts
+7
-1
XFEstudio/XFESpaceNinjaServer
feat: implement feeding of helminth (#597)
febe7ec5
代码差异
5 个文件
+76
-7
@@ -12,7 +12,7 @@
12
12
"copyfiles": "^2.4.1",
13
13
"express": "^5.0.0-beta.3",
14
14
"mongoose": "^8.9.2",
15
"warframe-public-export-plus": "^0.5.7",
15
"warframe-public-export-plus": "^0.5.8",
16
16
"warframe-riven-info": "^0.1.2",
17
17
"winston": "^3.17.0",
18
18
"winston-daily-rotate-file": "^5.0.0"
@@ -3877,9 +3877,9 @@
3877
3877
}
3878
3878
},
3879
3879
"node_modules/warframe-public-export-plus": {
3880
"version": "0.5.7",
3881
"resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.7.tgz",
3882
"integrity": "sha512-5cT48YPZCJ/KGCtAK4hGtaE6709CYIPzCJUI/8odJxntnUfe2R3Np+T8+iw431H2mVA+4CF9ByhvicODhdBPLw=="
3880
"version": "0.5.8",
3881
"resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.8.tgz",
3882
"integrity": "sha512-ZhHrKIkI6nhjKDlxhrNcfN8r2Yc9g+eeKLS6+9w7gzC4NscIt6TU8tH8bfjJTDeo6nRrzt88szX1/Oo3WnUY4Q=="
3883
3883
},
3884
3884
"node_modules/warframe-riven-info": {
3885
3885
"version": "0.1.2",
@@ -16,7 +16,7 @@
16
16
"copyfiles": "^2.4.1",
17
17
"express": "^5.0.0-beta.3",
18
18
"mongoose": "^8.9.2",
19
"warframe-public-export-plus": "^0.5.7",
19
"warframe-public-export-plus": "^0.5.8",
20
20
"warframe-riven-info": "^0.1.2",
21
21
"winston": "^3.17.0",
22
22
"winston-daily-rotate-file": "^5.0.0"
@@ -3,6 +3,8 @@ import { getAccountIdForRequest } from "@/src/services/loginService";
3
3
import { getJSONfromString } from "@/src/helpers/stringHelpers";
4
4
import { getInventory, addMiscItems } from "@/src/services/inventoryService";
5
5
import { IOid } from "@/src/types/commonTypes";
6
import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
7
import { ExportMisc } from "warframe-public-export-plus";
6
8
7
9
// eslint-disable-next-line @typescript-eslint/no-misused-promises
8
10
export const infestedFoundryController: RequestHandler = async (req, res) => {
@@ -53,6 +55,57 @@ export const infestedFoundryController: RequestHandler = async (req, res) => {
53
55
break;
54
56
}
55
57
58
case "c": {
59
// consume items
60
const request = getJSONfromString(String(req.body)) as IHelminthFeedRequest;
61
const inventory = await getInventory(accountId);
62
inventory.InfestedFoundry ??= {};
63
inventory.InfestedFoundry.Resources ??= [];
64
inventory.InfestedFoundry.XP ??= 0;
65
66
const miscItemChanges: IMiscItem[] = [];
67
let totalPercentagePointsGained = 0;
68
69
for (const contribution of request.ResourceContributions) {
70
const snack = ExportMisc.helminthSnacks[contribution.ItemType];
71
72
// Note: Currently ignoring loss of apetite
73
totalPercentagePointsGained += snack.gain / 0.01;
74
const resource = inventory.InfestedFoundry.Resources.find(x => x.ItemType == snack.type);
75
if (resource) {
76
resource.Count += Math.trunc(snack.gain * 1000);
77
} else {
78
inventory.InfestedFoundry.Resources.push({
79
ItemType: snack.type,
80
Count: Math.trunc(snack.gain * 1000)
81
});
82
}
83
84
// tally items for removal
85
const change = miscItemChanges.find(x => x.ItemType == contribution.ItemType);
86
if (change) {
87
change.ItemCount -= snack.count;
88
} else {
89
miscItemChanges.push({ ItemType: contribution.ItemType, ItemCount: snack.count * -1 });
90
}
91
}
92
93
inventory.InfestedFoundry.XP += 666 * totalPercentagePointsGained;
94
addMiscItems(inventory, miscItemChanges);
95
await inventory.save();
96
97
res.json({
98
InventoryChanges: {
99
InfestedFoundry: {
100
XP: inventory.InfestedFoundry.XP,
101
Resources: inventory.InfestedFoundry.Resources
102
}
103
},
104
MiscItems: miscItemChanges
105
});
106
break;
107
}
108
56
109
case "o": // offerings update
57
110
// {"OfferingsIndex":540,"SuitTypes":["/Lotus/Powersuits/PaxDuviricus/PaxDuviricusBaseSuit","/Lotus/Powersuits/Nezha/NezhaBaseSuit","/Lotus/Powersuits/Devourer/DevourerBaseSuit"],"Extra":false}
58
111
res.status(404).end();
@@ -74,6 +127,13 @@ interface IHelminthNameRequest {
74
127
newName: string;
75
128
}
76
129
130
interface IHelminthFeedRequest {
131
ResourceContributions: {
132
ItemType: string;
133
Date: number; // unix timestamp
134
}[];
135
}
136
77
137
const colorToShard: Record<string, string> = {
78
138
ACC_RED: "/Lotus/Types/Gameplay/NarmerSorties/ArchonCrystalAmar",
79
139
ACC_RED_MYTHIC: "/Lotus/Types/Gameplay/NarmerSorties/ArchonCrystalAmarMythic",
@@ -25,6 +25,7 @@ import {
25
25
IPlayerSkills,
26
26
ISettings,
27
27
IInfestedFoundry,
28
IHelminthResource,
28
29
IConsumedSuit,
29
30
IQuestProgress,
30
31
IQuestKeyDatabase,
@@ -454,10 +455,12 @@ const consumedSchuitsSchema = new Schema<IConsumedSuit>({
454
455
c: colorSchema
455
456
});
456
457
458
const helminthResourceSchema = new Schema<IHelminthResource>({ ItemType: String, Count: Number }, { _id: false });
459
457
460
const infestedFoundrySchema = new Schema<IInfestedFoundry>(
458
461
{
459
462
Name: String,
460
Resources: { type: [typeCountSchema], default: undefined },
463
Resources: { type: [helminthResourceSchema], default: undefined },
461
464
Slots: Number,
462
465
XP: Number,
463
466
ConsumedSuits: { type: [consumedSchuitsSchema], default: undefined },
@@ -524,9 +524,15 @@ export interface IFusionTreasure {
524
524
Sockets: number;
525
525
}
526
526
527
// Like ITypeCount except 'Count' instead of 'ItemCount'
528
export interface IHelminthResource {
529
ItemType: string;
530
Count: number;
531
}
532
527
533
export interface IInfestedFoundry {
528
534
Name?: string;
529
Resources?: ITypeCount[];
535
Resources?: IHelminthResource[];
530
536
Slots?: number;
531
537
XP?: number;
532
538
ConsumedSuits?: IConsumedSuit[];