feat: implement feeding of helminth
Currently, Helminth never gets tired of resources. This may be implemented later.
This commit is contained in:
parent
37f6fe9323
commit
695f3bf77a
8
package-lock.json
generated
8
package-lock.json
generated
@ -12,7 +12,7 @@
|
||||
"copyfiles": "^2.4.1",
|
||||
"express": "^5.0.0-beta.3",
|
||||
"mongoose": "^8.9.2",
|
||||
"warframe-public-export-plus": "^0.5.7",
|
||||
"warframe-public-export-plus": "^0.5.8",
|
||||
"warframe-riven-info": "^0.1.2",
|
||||
"winston": "^3.17.0",
|
||||
"winston-daily-rotate-file": "^5.0.0"
|
||||
@ -3877,9 +3877,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/warframe-public-export-plus": {
|
||||
"version": "0.5.7",
|
||||
"resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.7.tgz",
|
||||
"integrity": "sha512-5cT48YPZCJ/KGCtAK4hGtaE6709CYIPzCJUI/8odJxntnUfe2R3Np+T8+iw431H2mVA+4CF9ByhvicODhdBPLw=="
|
||||
"version": "0.5.8",
|
||||
"resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.8.tgz",
|
||||
"integrity": "sha512-ZhHrKIkI6nhjKDlxhrNcfN8r2Yc9g+eeKLS6+9w7gzC4NscIt6TU8tH8bfjJTDeo6nRrzt88szX1/Oo3WnUY4Q=="
|
||||
},
|
||||
"node_modules/warframe-riven-info": {
|
||||
"version": "0.1.2",
|
||||
|
@ -16,7 +16,7 @@
|
||||
"copyfiles": "^2.4.1",
|
||||
"express": "^5.0.0-beta.3",
|
||||
"mongoose": "^8.9.2",
|
||||
"warframe-public-export-plus": "^0.5.7",
|
||||
"warframe-public-export-plus": "^0.5.8",
|
||||
"warframe-riven-info": "^0.1.2",
|
||||
"winston": "^3.17.0",
|
||||
"winston-daily-rotate-file": "^5.0.0"
|
||||
|
@ -3,6 +3,8 @@ import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
||||
import { getInventory, addMiscItems } from "@/src/services/inventoryService";
|
||||
import { IOid } from "@/src/types/commonTypes";
|
||||
import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||
import { ExportMisc } from "warframe-public-export-plus";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||
export const infestedFoundryController: RequestHandler = async (req, res) => {
|
||||
@ -53,6 +55,57 @@ export const infestedFoundryController: RequestHandler = async (req, res) => {
|
||||
break;
|
||||
}
|
||||
|
||||
case "c": {
|
||||
// consume items
|
||||
const request = getJSONfromString(String(req.body)) as IHelminthFeedRequest;
|
||||
const inventory = await getInventory(accountId);
|
||||
inventory.InfestedFoundry ??= {};
|
||||
inventory.InfestedFoundry.Resources ??= [];
|
||||
inventory.InfestedFoundry.XP ??= 0;
|
||||
|
||||
const miscItemChanges: IMiscItem[] = [];
|
||||
let totalPercentagePointsGained = 0;
|
||||
|
||||
for (const contribution of request.ResourceContributions) {
|
||||
const snack = ExportMisc.helminthSnacks[contribution.ItemType];
|
||||
|
||||
// Note: Currently ignoring loss of apetite
|
||||
totalPercentagePointsGained += snack.gain / 0.01;
|
||||
const resource = inventory.InfestedFoundry.Resources.find(x => x.ItemType == snack.type);
|
||||
if (resource) {
|
||||
resource.Count += Math.trunc(snack.gain * 1000);
|
||||
} else {
|
||||
inventory.InfestedFoundry.Resources.push({
|
||||
ItemType: snack.type,
|
||||
Count: Math.trunc(snack.gain * 1000)
|
||||
});
|
||||
}
|
||||
|
||||
// tally items for removal
|
||||
const change = miscItemChanges.find(x => x.ItemType == contribution.ItemType);
|
||||
if (change) {
|
||||
change.ItemCount -= snack.count;
|
||||
} else {
|
||||
miscItemChanges.push({ ItemType: contribution.ItemType, ItemCount: snack.count * -1 });
|
||||
}
|
||||
}
|
||||
|
||||
inventory.InfestedFoundry.XP += 666 * totalPercentagePointsGained;
|
||||
addMiscItems(inventory, miscItemChanges);
|
||||
await inventory.save();
|
||||
|
||||
res.json({
|
||||
InventoryChanges: {
|
||||
InfestedFoundry: {
|
||||
XP: inventory.InfestedFoundry.XP,
|
||||
Resources: inventory.InfestedFoundry.Resources
|
||||
}
|
||||
},
|
||||
MiscItems: miscItemChanges
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
case "o": // offerings update
|
||||
// {"OfferingsIndex":540,"SuitTypes":["/Lotus/Powersuits/PaxDuviricus/PaxDuviricusBaseSuit","/Lotus/Powersuits/Nezha/NezhaBaseSuit","/Lotus/Powersuits/Devourer/DevourerBaseSuit"],"Extra":false}
|
||||
res.status(404).end();
|
||||
@ -74,6 +127,13 @@ interface IHelminthNameRequest {
|
||||
newName: string;
|
||||
}
|
||||
|
||||
interface IHelminthFeedRequest {
|
||||
ResourceContributions: {
|
||||
ItemType: string;
|
||||
Date: number; // unix timestamp
|
||||
}[];
|
||||
}
|
||||
|
||||
const colorToShard: Record<string, string> = {
|
||||
ACC_RED: "/Lotus/Types/Gameplay/NarmerSorties/ArchonCrystalAmar",
|
||||
ACC_RED_MYTHIC: "/Lotus/Types/Gameplay/NarmerSorties/ArchonCrystalAmarMythic",
|
||||
|
@ -25,6 +25,7 @@ import {
|
||||
IPlayerSkills,
|
||||
ISettings,
|
||||
IInfestedFoundry,
|
||||
IHelminthResource,
|
||||
IConsumedSuit,
|
||||
IQuestProgress,
|
||||
IQuestKeyDatabase,
|
||||
@ -454,10 +455,12 @@ const consumedSchuitsSchema = new Schema<IConsumedSuit>({
|
||||
c: colorSchema
|
||||
});
|
||||
|
||||
const helminthResourceSchema = new Schema<IHelminthResource>({ ItemType: String, Count: Number }, { _id: false });
|
||||
|
||||
const infestedFoundrySchema = new Schema<IInfestedFoundry>(
|
||||
{
|
||||
Name: String,
|
||||
Resources: { type: [typeCountSchema], default: undefined },
|
||||
Resources: { type: [helminthResourceSchema], default: undefined },
|
||||
Slots: Number,
|
||||
XP: Number,
|
||||
ConsumedSuits: { type: [consumedSchuitsSchema], default: undefined },
|
||||
|
@ -524,9 +524,15 @@ export interface IFusionTreasure {
|
||||
Sockets: number;
|
||||
}
|
||||
|
||||
// Like ITypeCount except 'Count' instead of 'ItemCount'
|
||||
export interface IHelminthResource {
|
||||
ItemType: string;
|
||||
Count: number;
|
||||
}
|
||||
|
||||
export interface IInfestedFoundry {
|
||||
Name?: string;
|
||||
Resources?: ITypeCount[];
|
||||
Resources?: IHelminthResource[];
|
||||
Slots?: number;
|
||||
XP?: number;
|
||||
ConsumedSuits?: IConsumedSuit[];
|
||||
|
Loading…
x
Reference in New Issue
Block a user