feat: trade fish for standing
This commit is contained in:
parent
48aa145a20
commit
94cd9f0dd7
8
package-lock.json
generated
8
package-lock.json
generated
@ -12,7 +12,7 @@
|
|||||||
"copyfiles": "^2.4.1",
|
"copyfiles": "^2.4.1",
|
||||||
"express": "^5",
|
"express": "^5",
|
||||||
"mongoose": "^8.9.2",
|
"mongoose": "^8.9.2",
|
||||||
"warframe-public-export-plus": "^0.5.17",
|
"warframe-public-export-plus": "^0.5.18",
|
||||||
"warframe-riven-info": "^0.1.2",
|
"warframe-riven-info": "^0.1.2",
|
||||||
"winston": "^3.17.0",
|
"winston": "^3.17.0",
|
||||||
"winston-daily-rotate-file": "^5.0.0"
|
"winston-daily-rotate-file": "^5.0.0"
|
||||||
@ -3778,9 +3778,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/warframe-public-export-plus": {
|
"node_modules/warframe-public-export-plus": {
|
||||||
"version": "0.5.17",
|
"version": "0.5.18",
|
||||||
"resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.17.tgz",
|
"resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.18.tgz",
|
||||||
"integrity": "sha512-AWOfUxDHz+UmpbA9ZUGLIrP+3eQOiVq9tw1FXgx7ySkJLEnZUsoi3wn0IFiavSy2iE6JQIyCiSIZCJQTaCV6kA=="
|
"integrity": "sha512-wUaW5Ua5tXHOYkKJxbealdCcTnRLUN7UCkvYOJEwlB/H14EBzDaqxg4engGqzbq4H8fmttyp3EUo4vazSaxZWg=="
|
||||||
},
|
},
|
||||||
"node_modules/warframe-riven-info": {
|
"node_modules/warframe-riven-info": {
|
||||||
"version": "0.1.2",
|
"version": "0.1.2",
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
"copyfiles": "^2.4.1",
|
"copyfiles": "^2.4.1",
|
||||||
"express": "^5",
|
"express": "^5",
|
||||||
"mongoose": "^8.9.2",
|
"mongoose": "^8.9.2",
|
||||||
"warframe-public-export-plus": "^0.5.17",
|
"warframe-public-export-plus": "^0.5.18",
|
||||||
"warframe-riven-info": "^0.1.2",
|
"warframe-riven-info": "^0.1.2",
|
||||||
"winston": "^3.17.0",
|
"winston": "^3.17.0",
|
||||||
"winston-daily-rotate-file": "^5.0.0"
|
"winston-daily-rotate-file": "^5.0.0"
|
||||||
|
@ -6,30 +6,48 @@ import { RequestHandler } from "express";
|
|||||||
import { ExportResources } from "warframe-public-export-plus";
|
import { ExportResources } from "warframe-public-export-plus";
|
||||||
|
|
||||||
export const fishmongerController: RequestHandler = async (req, res) => {
|
export const fishmongerController: RequestHandler = async (req, res) => {
|
||||||
if (!req.query.dissect) {
|
|
||||||
throw new Error("expected fishmonger request to be for dissection");
|
|
||||||
}
|
|
||||||
const accountId = await getAccountIdForRequest(req);
|
const accountId = await getAccountIdForRequest(req);
|
||||||
const inventory = await getInventory(accountId);
|
const inventory = await getInventory(accountId);
|
||||||
const body = getJSONfromString(String(req.body)) as IFishmongerRequest;
|
const body = getJSONfromString(String(req.body)) as IFishmongerRequest;
|
||||||
const miscItemChanges: IMiscItem[] = [];
|
const miscItemChanges: IMiscItem[] = [];
|
||||||
|
let syndicateTag: string | undefined;
|
||||||
|
let standingChange = 0;
|
||||||
for (const fish of body.Fish) {
|
for (const fish of body.Fish) {
|
||||||
for (const part of ExportResources[fish.ItemType].dissectionParts!) {
|
const fishData = ExportResources[fish.ItemType];
|
||||||
const partItem = miscItemChanges.find(x => x.ItemType == part.ItemType);
|
if (req.query.dissect == "1") {
|
||||||
if (partItem) {
|
for (const part of fishData.dissectionParts!) {
|
||||||
partItem.ItemCount += part.ItemCount;
|
const partItem = miscItemChanges.find(x => x.ItemType == part.ItemType);
|
||||||
} else {
|
if (partItem) {
|
||||||
miscItemChanges.push(part);
|
partItem.ItemCount += part.ItemCount;
|
||||||
|
} else {
|
||||||
|
miscItemChanges.push(part);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
syndicateTag = fishData.syndicateTag!;
|
||||||
|
standingChange += fishData.standingBonus!;
|
||||||
}
|
}
|
||||||
miscItemChanges.push({ ItemType: fish.ItemType, ItemCount: fish.ItemCount * -1 });
|
miscItemChanges.push({ ItemType: fish.ItemType, ItemCount: fish.ItemCount * -1 });
|
||||||
}
|
}
|
||||||
addMiscItems(inventory, miscItemChanges);
|
addMiscItems(inventory, miscItemChanges);
|
||||||
|
if (standingChange && syndicateTag) {
|
||||||
|
const syndicate = inventory.Affiliations.find(x => x.Tag == syndicateTag);
|
||||||
|
if (syndicate !== undefined) {
|
||||||
|
syndicate.Standing += standingChange;
|
||||||
|
} else {
|
||||||
|
inventory.Affiliations.push({
|
||||||
|
Tag: syndicateTag,
|
||||||
|
Standing: standingChange
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
await inventory.save();
|
await inventory.save();
|
||||||
res.json({
|
res.json({
|
||||||
InventoryChanges: {
|
InventoryChanges: {
|
||||||
MiscItems: miscItemChanges
|
MiscItems: miscItemChanges
|
||||||
}
|
},
|
||||||
|
SyndicateTag: syndicateTag,
|
||||||
|
StandingChange: standingChange
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user