返回提交历史
Modified
src/controllers/api/infestedFoundryController.ts
+38
-10
XFEstudio/SpaceNinjaServer
feat: sentient apetite (#726)
82621ebe
代码差异
1 个文件
+38
-10
@@ -3,7 +3,13 @@ import { getAccountIdForRequest } from "@/src/services/loginService";
3
3
import { getJSONfromString } from "@/src/helpers/stringHelpers";
4
4
import { getInventory, addMiscItems, updateCurrency, addRecipes } from "@/src/services/inventoryService";
5
5
import { IOid } from "@/src/types/commonTypes";
6
import { IConsumedSuit, IInfestedFoundry, IMiscItem, ITypeCount } from "@/src/types/inventoryTypes/inventoryTypes";
6
import {
7
IConsumedSuit,
8
IHelminthFoodRecord,
9
IInfestedFoundry,
10
IMiscItem,
11
ITypeCount
12
} from "@/src/types/inventoryTypes/inventoryTypes";
7
13
import { ExportMisc, ExportRecipes } from "warframe-public-export-plus";
8
14
import { getRecipe } from "@/src/services/itemDataService";
9
15
import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel";
@@ -92,6 +98,34 @@ export const infestedFoundryController: RequestHandler = async (req, res) => {
92
98
for (const contribution of request.ResourceContributions) {
93
99
const snack = ExportMisc.helminthSnacks[contribution.ItemType];
94
100
101
// tally items for removal
102
const change = miscItemChanges.find(x => x.ItemType == contribution.ItemType);
103
if (change) {
104
change.ItemCount -= snack.count;
105
} else {
106
miscItemChanges.push({ ItemType: contribution.ItemType, ItemCount: snack.count * -1 });
107
}
108
109
if (snack.type == "/Lotus/Types/Items/InfestedFoundry/HelminthAppetiteCooldownReducer") {
110
// sentinent apetite
111
let mostDislikedSnackRecord: IHelminthFoodRecord = { ItemType: "", Date: 0 };
112
for (const resource of inventory.InfestedFoundry.Resources) {
113
if (resource.RecentlyConvertedResources) {
114
for (const record of resource.RecentlyConvertedResources) {
115
if (record.Date > mostDislikedSnackRecord.Date) {
116
mostDislikedSnackRecord = record;
117
}
118
}
119
}
120
}
121
logger.debug("helminth eats sentient resource; most disliked snack:", {
122
type: mostDislikedSnackRecord.ItemType,
123
date: mostDislikedSnackRecord.Date
124
});
125
mostDislikedSnackRecord.Date = currentUnixSeconds + 24 * 60 * 60; // Possibly unfaithful
126
continue;
127
}
128
95
129
let resource = inventory.InfestedFoundry.Resources.find(x => x.ItemType == snack.type);
96
130
if (!resource) {
97
131
resource =
@@ -116,21 +150,13 @@ export const infestedFoundryController: RequestHandler = async (req, res) => {
116
150
apetiteFactor
117
151
});
118
152
if (hoursRemaining >= 18) {
119
record.Date = currentUnixSeconds + 72 * 60 * 60;
153
record.Date = currentUnixSeconds + 72 * 60 * 60; // Possibly unfaithful
120
154
} else {
121
155
record.Date = currentUnixSeconds + 24 * 60 * 60;
122
156
}
123
157
124
158
totalPercentagePointsGained += snack.gain * 100 * apetiteFactor; // 30% would be gain=0.3, so percentage points is equal to gain * 100.
125
159
resource.Count += Math.trunc(snack.gain * 1000 * apetiteFactor); // 30% would be gain=0.3 or Count=300, so Count=gain*1000.
126
127
// tally items for removal
128
const change = miscItemChanges.find(x => x.ItemType == contribution.ItemType);
129
if (change) {
130
change.ItemCount -= snack.count;
131
} else {
132
miscItemChanges.push({ ItemType: contribution.ItemType, ItemCount: snack.count * -1 });
133
}
134
160
}
135
161
136
162
const recipeChanges = addInfestedFoundryXP(inventory.InfestedFoundry, 666 * totalPercentagePointsGained);
@@ -435,6 +461,8 @@ interface IHelminthInvigorationRequest {
435
461
ResourceCosts: number[];
436
462
}
437
463
464
// A fitted model for observed apetite values. Likely slightly inaccurate.
465
//
438
466
// Hours remaining, percentage points gained (out of 30 total)
439
467
// 0, 30
440
468
// 5, 25.8