MissionInventoryUpdate(not completed), Mod upgrade, Booster purchase #49

Merged
holmityd merged 40 commits from interface-names into main 2023-09-06 03:02:54 -07:00
2 changed files with 22 additions and 3 deletions
Showing only changes of commit 856d3c1ccb - Show all commits

View File

@ -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)
OrdisPrime commented 2023-09-05 05:35:07 -07:00 (Migrated from github.com)
Review

what is the purpose of this?

what is the purpose of this?
OrdisPrime commented 2023-09-05 05:43:03 -07:00 (Migrated from github.com)
Review

can you explain what the difference is between missioncredits and MissionCredits?

can you explain what the difference is between missioncredits and MissionCredits?
OrdisPrime commented 2023-09-05 05:46:03 -07:00 (Migrated from github.com)
Review

can you please use brackets like:
if (something){
expression;
}

can you please use brackets like: if (something){ expression; }
OrdisPrime commented 2023-09-05 05:46:25 -07:00 (Migrated from github.com)
Review

it makes it easier to read

it makes it easier to read
OrdisPrime commented 2023-09-05 05:47:38 -07:00 (Migrated from github.com)
Review

where possible: instead of "i" or "j" use descriptive names such as rawUpgrade or so

where possible: instead of "i" or "j" use descriptive names such as rawUpgrade or so
OrdisPrime commented 2023-09-05 05:49:43 -07:00 (Migrated from github.com)
Review

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.

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.
OrdisPrime commented 2023-09-05 05:50:28 -07:00 (Migrated from github.com)
Review

move types and interfaces into types/missionInventoryTypes

move types and interfaces into types/missionInventoryTypes
throw new Error('Invalid data format');
await missionInventoryUpdate(parsedData, id);
} catch (err) {
console.error('Error parsing JSON data:', err);
}
OrdisPrime commented 2023-09-03 06:14:51 -07:00 (Migrated from github.com)
Review

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
OrdisPrime commented 2023-09-03 06:15:35 -07:00 (Migrated from github.com)
Review

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
OrdisPrime commented 2023-09-03 06:20:43 -07:00 (Migrated from github.com)
Review

and you could make a types/missionInventoryUpdatesTypes.ts as well

and you could make a types/missionInventoryUpdatesTypes.ts as well
holmityd commented 2023-09-03 10:36:13 -07:00 (Migrated from github.com)
Review

need that like this for now

need that like this for now
// TODO - get original response
res.json({});
};

View File

@ -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];