MissionInventoryUpdate(not completed), Mod upgrade, Booster purchase #49
@ -1,5 +1,6 @@
|
||||
import { RequestHandler } from "express";
|
||||
import { missionInventoryUpdate } from "@/src/services/inventoryService";
|
||||
import fs from 'fs';
|
||||
/*
|
||||
- [ ] crossPlaySetting
|
||||
- [ ] rewardsMultiplier
|
||||
@ -39,11 +40,27 @@ import { missionInventoryUpdate } from "@/src/services/inventoryService";
|
||||
- [ ] FpsSamples
|
||||
*/
|
||||
const missionInventoryUpdateController: RequestHandler = async (req, res) => {
|
||||
fs.writeFile("./tmp/missionInventoryUpdate", req.body,(err)=>{
|
||||
if(err)
|
||||
return console.log(err);
|
||||
}); // temp log, !!! tmp folder need on main dir
|
||||
|
||||
const [data, _secondIGuessIsSalt] = String(req.body).split("\n");
|
||||
const id = req.query.accountId as string;
|
||||
|
||||
await missionInventoryUpdate(JSON.parse(data), id);
|
||||
// TODO - salt check
|
||||
|
||||
try {
|
||||
const parsedData = JSON.parse(data);
|
||||
if (typeof parsedData !== 'object' || parsedData === null)
|
||||
|
||||
throw new Error('Invalid data format');
|
||||
|
||||
await missionInventoryUpdate(parsedData, id);
|
||||
} catch (err) {
|
||||
console.error('Error parsing JSON data:', err);
|
||||
}
|
||||
|
||||
![]() can you seperate interfaces into seperate files? we got the /types folder, for example string dictionary could be in /types/commonTypes.ts can you seperate interfaces into seperate files? we got the /types folder, for example string dictionary could be in /types/commonTypes.ts
![]() is this the best way? looks a bit suspicious with the many else ifs is this the best way? looks a bit suspicious with the many else ifs
![]() and you could make a types/missionInventoryUpdatesTypes.ts as well and you could make a types/missionInventoryUpdatesTypes.ts as well
![]() need that like this for now need that like this for now
|
||||
// TODO - get original response
|
||||
res.json({});
|
||||
};
|
||||
|
||||
|
@ -111,6 +111,8 @@ export const missionInventoryUpdate = async (data: MissionInventoryUpdate, accou
|
||||
const { RawUpgrades, MiscItems, Suits, Pistols, LongGuns, Melee, RegularCredits } = data;
|
||||
const inventory = await getInventory(accountId);
|
||||
|
||||
// TODO - multipliers logic
|
||||
|
||||
const addGearExpByCategory = (gearArray: MissionInventoryUpdateGear[] | undefined, categoryName: 'Pistols'|'LongGuns'|'Melee'|'Suits') => {
|
||||
const category = inventory[categoryName];
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user
what is the purpose of this?
can you explain what the difference is between missioncredits and MissionCredits?
can you please use brackets like:
if (something){
expression;
}
it makes it easier to read
where possible: instead of "i" or "j" use descriptive names such as rawUpgrade or so
perhaps make a function for this logic.
A controller should only "control" the calling of functions, with as little logic as possible.
You could make a service/missionInventoryUpdateService and put all the logic there, while you call those functions from the controller. Some logic in the controller is totally fine.
move types and interfaces into types/missionInventoryTypes