Fix interface names, add NodeIntro support. #51
@ -44,7 +44,6 @@ import { IMissionInventoryUpdate } from "@/src/types/missionInventoryUpdateType"
 | 
				
			|||||||
const missionInventoryUpdateController: RequestHandler = async (req, res) => {
 | 
					const missionInventoryUpdateController: RequestHandler = async (req, res) => {
 | 
				
			||||||
    const id = req.query.accountId as string;
 | 
					    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");
 | 
					    const [data] = String(req.body).split("\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
@ -55,7 +54,7 @@ const missionInventoryUpdateController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
        console.error("Error parsing JSON data:", err);
 | 
					        console.error("Error parsing JSON data:", err);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // TODO - get original response
 | 
					    // TODO - Return the updated inventory the way the game does it.
 | 
				
			||||||
    res.json({});
 | 
					    res.json({});
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -81,10 +81,24 @@ export const updateCurrency = async (price: number, usePremium: boolean, account
 | 
				
			|||||||
    return { [currencyName]: -price };
 | 
					    return { [currencyName]: -price };
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// TODO: AffiliationMods support (Nightwave).
 | 
				
			||||||
export const updateGeneric = async (data: IGenericUpdate, accountId: string) => {
 | 
					export const updateGeneric = async (data: IGenericUpdate, accountId: string) => {
 | 
				
			||||||
    const inventory = await getInventory(accountId);
 | 
					    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();
 | 
					    await inventory.save();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return data;
 | 
					    return data;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -184,7 +198,7 @@ export const missionInventoryUpdate = async (data: IMissionInventoryUpdate, acco
 | 
				
			|||||||
    const inventory = await getInventory(accountId);
 | 
					    const inventory = await getInventory(accountId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Currency
 | 
					    // 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).
 | 
					    // TODO - Multipliers (from Boosters or otherwise).
 | 
				
			||||||
    const credits = RegularCredits as number;
 | 
					    const credits = RegularCredits as number;
 | 
				
			||||||
    inventory.RegularCredits += credits < 0 ? Math.abs(credits) : credits; // If credits are negative, flip them.
 | 
					    inventory.RegularCredits += credits < 0 ? Math.abs(credits) : credits; // If credits are negative, flip them.
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user