Mission rewards save #46

Merged
holmityd merged 15 commits from main into main 2023-08-31 03:29:10 -07:00
2 changed files with 11 additions and 7 deletions
Showing only changes of commit bfdc6bfaff - Show all commits

View File

@ -23,7 +23,7 @@ import { MissionInventoryUpdate } from "@/src/types/missionInventoryUpdateType";
- [ ] LastRegionPlayed - [ ] LastRegionPlayed
- [ ] GameModeId - [ ] GameModeId
- [ ] hosts - [ ] hosts
- [+] ChallengeProgress - [x] ChallengeProgress
- [ ] SeasonChallengeHistory - [ ] SeasonChallengeHistory
- [ ] PS - [ ] PS
- [ ] ActiveDojoColorResearch - [ ] ActiveDojoColorResearch

View File

@ -164,17 +164,21 @@ const addChallenges = (inventory: IInventoryDatabaseDocument, itemsArray: Challe
}); });
}; };
const gearKeys = ["Suits", "Pistols", "LongGuns", "Melee"] as const;
type GearKeysType = (typeof gearKeys)[number];
export const missionInventoryUpdate = async (data: MissionInventoryUpdate, accountId: string): Promise<void> => { export const missionInventoryUpdate = async (data: MissionInventoryUpdate, accountId: string): Promise<void> => {
const { RawUpgrades, MiscItems, Suits, Pistols, LongGuns, Melee, RegularCredits, ChallengeProgress } = data; const { RawUpgrades, MiscItems, RegularCredits, ChallengeProgress } = data;
const inventory = await getInventory(accountId); const inventory = await getInventory(accountId);
// TODO - multipliers logic // TODO - multipliers logic
// credits
inventory.RegularCredits += RegularCredits || 0; inventory.RegularCredits += RegularCredits || 0;
addGearExpByCategory(inventory, Pistols, "Pistols");
addGearExpByCategory(inventory, LongGuns, "LongGuns"); // gear exp
addGearExpByCategory(inventory, Melee, "Melee"); gearKeys.forEach((key: GearKeysType) => addGearExpByCategory(inventory, data[key], key));
addGearExpByCategory(inventory, Suits, "Suits");
// other
addItemsByCategory(inventory, RawUpgrades, "RawUpgrades"); // TODO - check mods fusion level addItemsByCategory(inventory, RawUpgrades, "RawUpgrades"); // TODO - check mods fusion level
addItemsByCategory(inventory, MiscItems, "MiscItems"); addItemsByCategory(inventory, MiscItems, "MiscItems");
addChallenges(inventory, ChallengeProgress); addChallenges(inventory, ChallengeProgress);