Merge remote-tracking branch 'upstream'
This commit is contained in:
commit
d5fb125005
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];
|
||||||
|
if (req.query.dissect == "1") {
|
||||||
|
for (const part of fishData.dissectionParts!) {
|
||||||
const partItem = miscItemChanges.find(x => x.ItemType == part.ItemType);
|
const partItem = miscItemChanges.find(x => x.ItemType == part.ItemType);
|
||||||
if (partItem) {
|
if (partItem) {
|
||||||
partItem.ItemCount += part.ItemCount;
|
partItem.ItemCount += part.ItemCount * fish.ItemCount;
|
||||||
} else {
|
} else {
|
||||||
miscItemChanges.push(part);
|
miscItemChanges.push({ ItemType: part.ItemType, ItemCount: part.ItemCount * fish.ItemCount });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
syndicateTag = fishData.syndicateTag!;
|
||||||
|
standingChange += fishData.standingBonus! * fish.ItemCount;
|
||||||
|
}
|
||||||
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
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,24 +1,59 @@
|
|||||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
||||||
import { syndicateSacrifice } from "@/src/services/inventoryService";
|
|
||||||
import { ISyndicateSacrifice } from "@/src/types/syndicateTypes";
|
|
||||||
import { RequestHandler } from "express";
|
import { RequestHandler } from "express";
|
||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||||
|
import { ExportSyndicates } from "warframe-public-export-plus";
|
||||||
|
import { handleStoreItemAcquisition } from "@/src/services/purchaseService";
|
||||||
|
import { getInventory } from "@/src/services/inventoryService";
|
||||||
|
import { IInventoryChanges } from "@/src/types/purchaseTypes";
|
||||||
|
|
||||||
const syndicateSacrificeController: RequestHandler = async (request, response) => {
|
export const syndicateSacrificeController: RequestHandler = async (request, response) => {
|
||||||
const accountId = await getAccountIdForRequest(request);
|
const accountId = await getAccountIdForRequest(request);
|
||||||
const update = getJSONfromString(String(request.body)) as ISyndicateSacrifice;
|
const inventory = await getInventory(accountId);
|
||||||
let reply = {};
|
const data = getJSONfromString(String(request.body)) as ISyndicateSacrifice;
|
||||||
try {
|
|
||||||
if (typeof update !== "object") {
|
let syndicate = inventory.Affiliations.find(x => x.Tag == data.AffiliationTag);
|
||||||
throw new Error("Invalid data format");
|
if (!syndicate) {
|
||||||
|
syndicate = inventory.Affiliations[inventory.Affiliations.push({ Tag: data.AffiliationTag, Standing: 0 }) - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
reply = await syndicateSacrifice(update, accountId);
|
let reward: string | undefined;
|
||||||
} catch (err) {
|
|
||||||
console.error("Error parsing JSON data:", err);
|
const manifest = ExportSyndicates[data.AffiliationTag];
|
||||||
|
if (manifest?.initiationReward && data.SacrificeLevel == 0) {
|
||||||
|
reward = manifest.initiationReward;
|
||||||
|
syndicate.Initiated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
response.json(reply);
|
const level = data.SacrificeLevel - (syndicate.Title ?? 0);
|
||||||
|
const res: ISyndicateSacrificeResponse = {
|
||||||
|
AffiliationTag: data.AffiliationTag,
|
||||||
|
InventoryChanges: {},
|
||||||
|
Level: data.SacrificeLevel,
|
||||||
|
LevelIncrease: level <= 0 ? 1 : level,
|
||||||
|
NewEpisodeReward: syndicate?.Tag == "RadioLegionIntermission9Syndicate"
|
||||||
};
|
};
|
||||||
|
|
||||||
export { syndicateSacrificeController };
|
if (syndicate?.Title !== undefined) syndicate.Title += 1;
|
||||||
|
|
||||||
|
await inventory.save();
|
||||||
|
|
||||||
|
if (reward) {
|
||||||
|
res.InventoryChanges = (await handleStoreItemAcquisition(reward, accountId)).InventoryChanges;
|
||||||
|
}
|
||||||
|
|
||||||
|
response.json(res);
|
||||||
|
};
|
||||||
|
|
||||||
|
interface ISyndicateSacrifice {
|
||||||
|
AffiliationTag: string;
|
||||||
|
SacrificeLevel: number;
|
||||||
|
AllowMultiple: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ISyndicateSacrificeResponse {
|
||||||
|
AffiliationTag: string;
|
||||||
|
Level: number;
|
||||||
|
LevelIncrease: number;
|
||||||
|
InventoryChanges: IInventoryChanges;
|
||||||
|
NewEpisodeReward: boolean;
|
||||||
|
}
|
||||||
|
@ -28,7 +28,6 @@ import {
|
|||||||
} from "../types/requestTypes";
|
} from "../types/requestTypes";
|
||||||
import { logger } from "@/src/utils/logger";
|
import { logger } from "@/src/utils/logger";
|
||||||
import { getWeaponType, getExalted } from "@/src/services/itemDataService";
|
import { getWeaponType, getExalted } from "@/src/services/itemDataService";
|
||||||
import { ISyndicateSacrifice, ISyndicateSacrificeResponse } from "../types/syndicateTypes";
|
|
||||||
import { IEquipmentClient, IItemConfig } from "../types/inventoryTypes/commonInventoryTypes";
|
import { IEquipmentClient, IItemConfig } from "../types/inventoryTypes/commonInventoryTypes";
|
||||||
import {
|
import {
|
||||||
ExportArcanes,
|
ExportArcanes,
|
||||||
@ -38,11 +37,9 @@ import {
|
|||||||
ExportRecipes,
|
ExportRecipes,
|
||||||
ExportResources,
|
ExportResources,
|
||||||
ExportSentinels,
|
ExportSentinels,
|
||||||
ExportSyndicates,
|
|
||||||
ExportUpgrades
|
ExportUpgrades
|
||||||
} from "warframe-public-export-plus";
|
} from "warframe-public-export-plus";
|
||||||
import { createShip } from "./shipService";
|
import { createShip } from "./shipService";
|
||||||
import { handleStoreItemAcquisition } from "./purchaseService";
|
|
||||||
|
|
||||||
export const createInventory = async (
|
export const createInventory = async (
|
||||||
accountOwnerId: Types.ObjectId,
|
accountOwnerId: Types.ObjectId,
|
||||||
@ -552,45 +549,6 @@ export const updateTheme = async (data: IThemeUpdateRequest, accountId: string):
|
|||||||
await inventory.save();
|
await inventory.save();
|
||||||
};
|
};
|
||||||
|
|
||||||
export const syndicateSacrifice = async (
|
|
||||||
data: ISyndicateSacrifice,
|
|
||||||
accountId: string
|
|
||||||
): Promise<ISyndicateSacrificeResponse> => {
|
|
||||||
const inventory = await getInventory(accountId);
|
|
||||||
|
|
||||||
let syndicate = inventory.Affiliations.find(x => x.Tag == data.AffiliationTag);
|
|
||||||
if (!syndicate) {
|
|
||||||
syndicate = inventory.Affiliations[inventory.Affiliations.push({ Tag: data.AffiliationTag, Standing: 0 }) - 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
let reward: string | undefined;
|
|
||||||
|
|
||||||
const manifest = ExportSyndicates[data.AffiliationTag];
|
|
||||||
if (manifest?.initiationReward && data.SacrificeLevel == 0) {
|
|
||||||
reward = manifest.initiationReward;
|
|
||||||
syndicate.Initiated = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const level = data.SacrificeLevel - (syndicate.Title ?? 0);
|
|
||||||
const res: ISyndicateSacrificeResponse = {
|
|
||||||
AffiliationTag: data.AffiliationTag,
|
|
||||||
InventoryChanges: {},
|
|
||||||
Level: data.SacrificeLevel,
|
|
||||||
LevelIncrease: level <= 0 ? 1 : level,
|
|
||||||
NewEpisodeReward: syndicate?.Tag == "RadioLegionIntermission9Syndicate"
|
|
||||||
};
|
|
||||||
|
|
||||||
if (syndicate?.Title !== undefined) syndicate.Title += 1;
|
|
||||||
|
|
||||||
await inventory.save();
|
|
||||||
|
|
||||||
if (reward) {
|
|
||||||
res.InventoryChanges = (await handleStoreItemAcquisition(reward, accountId)).InventoryChanges;
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const addEquipment = async (
|
export const addEquipment = async (
|
||||||
category: TEquipmentKey,
|
category: TEquipmentKey,
|
||||||
type: string,
|
type: string,
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
import { IInventoryChanges } from "./purchaseTypes";
|
|
||||||
|
|
||||||
export interface ISyndicateSacrifice {
|
|
||||||
AffiliationTag: string;
|
|
||||||
SacrificeLevel: number;
|
|
||||||
AllowMultiple: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ISyndicateSacrificeResponse {
|
|
||||||
AffiliationTag: string;
|
|
||||||
Level: number;
|
|
||||||
LevelIncrease: number;
|
|
||||||
InventoryChanges: IInventoryChanges;
|
|
||||||
NewEpisodeReward: boolean;
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user