Fix it... again
This commit is contained in:
parent
0a80e11d9f
commit
fe451171ab
@ -44,7 +44,6 @@ import { IMissionInventoryUpdate } from "@/src/types/missionInventoryUpdateType"
|
||||
const missionInventoryUpdateController: RequestHandler = async (req, res) => {
|
||||
const id = req.query.accountId as string;
|
||||
|
||||
// Remove the hash, which is added directly below the JSON data.
|
||||
const [data] = String(req.body).split("\n");
|
||||
|
||||
try {
|
||||
@ -55,7 +54,7 @@ const missionInventoryUpdateController: RequestHandler = async (req, res) => {
|
||||
console.error("Error parsing JSON data:", err);
|
||||
}
|
||||
|
||||
// TODO - get original response
|
||||
// TODO - Return the updated inventory the way the game does it.
|
||||
res.json({});
|
||||
};
|
||||
|
||||
|
@ -81,10 +81,24 @@ export const updateCurrency = async (price: number, usePremium: boolean, account
|
||||
return { [currencyName]: -price };
|
||||
};
|
||||
|
||||
// TODO: AffiliationMods support (Nightwave).
|
||||
export const updateGeneric = async (data: IGenericUpdate, accountId: string) => {
|
||||
const inventory = await getInventory(accountId);
|
||||
data.NodeIntrosCompleted = data.NodeIntrosCompleted.concat(inventory.NodeIntrosCompleted);
|
||||
|
||||
// Make it an array for easier parsing.
|
||||
if (typeof data.NodeIntrosCompleted === "string") {
|
||||
data.NodeIntrosCompleted = [ data.NodeIntrosCompleted ];
|
||||
}
|
||||
|
||||
// Combine the two arrays into one.
|
||||
data.NodeIntrosCompleted = inventory.NodeIntrosCompleted.concat(data.NodeIntrosCompleted);
|
||||
|
||||
// Remove duplicate entries.
|
||||
const nodes = [ ...new Set(data.NodeIntrosCompleted) ];
|
||||
|
||||
inventory.NodeIntrosCompleted = nodes;
|
||||
await inventory.save();
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
@ -184,7 +198,7 @@ export const missionInventoryUpdate = async (data: IMissionInventoryUpdate, acco
|
||||
const inventory = await getInventory(accountId);
|
||||
|
||||
// Currency
|
||||
// !!! TODO: Make a helper specifically for adding currencies with negative/positive checks shared between them.
|
||||
// TODO: Make a helper specifically for adding currencies with negative/positive checks shared between them.
|
||||
// TODO - Multipliers (from Boosters or otherwise).
|
||||
const credits = RegularCredits as number;
|
||||
inventory.RegularCredits += credits < 0 ? Math.abs(credits) : credits; // If credits are negative, flip them.
|
||||
|
Loading…
x
Reference in New Issue
Block a user