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
3 changed files with 47 additions and 47 deletions
Showing only changes of commit 032a183751 - Show all commits

View File

@ -1,10 +1,10 @@
import { RequestHandler } from "express";
import { missionInventoryUpdate } from "@/src/services/inventoryService";
import {
MissionInventoryUpdate,
MissionInventoryUpdateRewardInfo,
MissionRewardResponse,
Reward
IMissionInventoryUpdate,
IMissionInventoryUpdateRewardInfo,
IMissionRewardResponse,
IReward
} from "@/src/types/missionInventoryUpdateType";
import { RawUpgrade } from "@/src/types/inventoryTypes/inventoryTypes";
@ -68,7 +68,7 @@ const missionInventoryUpdateController: RequestHandler = async (req, res) => {
// TODO - salt check
try {
const parsedData = JSON.parse(data) as MissionInventoryUpdate;
const parsedData = JSON.parse(data) as IMissionInventoryUpdate;
if (typeof parsedData !== "object" || parsedData === null) throw new Error("Invalid data format");
const { InventoryChanges, MissionRewards } = getRewards(parsedData.RewardInfo);
@ -125,8 +125,8 @@ const missionInventoryUpdateController: RequestHandler = async (req, res) => {
*/
const getRewards = (
rewardInfo: MissionInventoryUpdateRewardInfo | undefined
): { InventoryChanges: MissionInventoryUpdate; MissionRewards: MissionRewardResponse[] } => {
rewardInfo: IMissionInventoryUpdateRewardInfo | undefined
): { InventoryChanges: IMissionInventoryUpdate; MissionRewards: IMissionRewardResponse[] } => {
if (!rewardInfo) return { InventoryChanges: {}, MissionRewards: [] };
// TODO - add Rotation logic
@ -147,13 +147,13 @@ const getRewards = (
// "rewardSeed": -5604904486637266000
// },
const rewards = (missionsDropTable as { [key: string]: Reward[] })[rewardInfo.node];
const rewards = (missionsDropTable as { [key: string]: IReward[] })[rewardInfo.node];
if (!rewards) return { InventoryChanges: {}, MissionRewards: [] };
// Separate guaranteed and chance drops
const guaranteedDrops: Reward[] = [];
const chanceDrops: Reward[] = [];
const guaranteedDrops: IReward[] = [];
const chanceDrops: IReward[] = [];
for (const reward of rewards) {
if (reward.chance === 100) guaranteedDrops.push(reward);
else chanceDrops.push(reward);
@ -167,7 +167,7 @@ const getRewards = (
return formatRewardsToInventoryType(guaranteedDrops);
};
const getRandomRewardByChance = (data: Reward[] | undefined): Reward | undefined => {
const getRandomRewardByChance = (data: IReward[] | undefined): IReward | undefined => {
if (!data || data.length == 0) return;
const totalChance = data.reduce((sum, item) => sum + item.chance, 0);
@ -185,10 +185,10 @@ const getRandomRewardByChance = (data: Reward[] | undefined): Reward | undefined
};
const formatRewardsToInventoryType = (
rewards: Reward[]
): { InventoryChanges: MissionInventoryUpdate; MissionRewards: MissionRewardResponse[] } => {
const InventoryChanges: MissionInventoryUpdate = {};
const MissionRewards: MissionRewardResponse[] = [];
rewards: IReward[]
): { InventoryChanges: IMissionInventoryUpdate; MissionRewards: IMissionRewardResponse[] } => {
const InventoryChanges: IMissionInventoryUpdate = {};
const MissionRewards: IMissionRewardResponse[] = [];
rewards.forEach(i => {
const mod = modNames[i.name];
const skin = skinNames[i.name];
@ -238,8 +238,8 @@ const formatRewardsToInventoryType = (
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const _missionRewardsCheckAllNamings = () => {
let tempRewards: Reward[] = [];
Object.values(missionsDropTable as { [key: string]: Reward[] }).forEach(i => {
let tempRewards: IReward[] = [];
Object.values(missionsDropTable as { [key: string]: IReward[] }).forEach(i => {
i.forEach(j => {
tempRewards.push(j);
});

View File

@ -13,7 +13,7 @@ import {
MiscItem,
RawUpgrade
} from "@/src/types/inventoryTypes/inventoryTypes";
import { MissionInventoryUpdate, MissionInventoryUpdateGear } from "../types/missionInventoryUpdateType";
import { IMissionInventoryUpdate, IMissionInventoryUpdateGear } from "../types/missionInventoryUpdateType";
const createInventory = async (accountOwnerId: Types.ObjectId) => {
try {
@ -116,7 +116,7 @@ export const addCustomization = async (customizatonName: string, accountId: stri
const addGearExpByCategory = (
inventory: IInventoryDatabaseDocument,
gearArray: MissionInventoryUpdateGear[] | undefined,
gearArray: IMissionInventoryUpdateGear[] | undefined,
categoryName: "Pistols" | "LongGuns" | "Melee" | "Suits"
) => {
const category = inventory[categoryName];
@ -179,7 +179,7 @@ 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) => {
export const missionInventoryUpdate = async (data: IMissionInventoryUpdate, accountId: string) => {
const { RawUpgrades, MiscItems, RegularCredits, ChallengeProgress } = data;
const inventory = await getInventory(accountId);

View File

@ -1,18 +1,11 @@
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
/* eslint-disable @typescript-eslint/no-explicit-any */
interface MongooseId {
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
$oid: string;
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
}
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
import { Oid } from "./commonTypes";
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
import { Date } from "./inventoryTypes/inventoryTypes";
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
interface ExpireDate {
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
$date: {
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
$numberLong: string;
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
};
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
}
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
export interface MissionInventoryUpdateGear {
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
export interface IMissionInventoryUpdateGear {
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
ItemType: string;
ItemName: string;
ItemId: MongooseId;
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
ItemId: Oid;
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
XP: number;
UpgradeVer: number;
Features: number;
@ -20,7 +13,7 @@ export interface MissionInventoryUpdateGear {
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
CustomizationSlotPurchases: number;
ModSlotPurchases: number;
FocusLens: string;
Expiry: ExpireDate;
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
Expiry: Date;
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
Polarity: any[];
Configs: any[];
ModularParts: any[];
@ -29,22 +22,29 @@ export interface MissionInventoryUpdateGear {
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
UpgradeFingerprint: string;
OffensiveUpgrade: string;
DefensiveUpgrade: string;
UpgradesExpiry: ExpireDate;
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
UpgradesExpiry: Date;
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
ArchonCrystalUpgrades: any[];
}
export interface MissionInventoryUpdateItem {
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
export interface IMissionInventoryUpdateItem {
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
ItemCount: number;
ItemType: string;
}
interface MissionInventoryUpdateChallange {
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
export interface IMissionInventoryUpdateCard extends IMissionInventoryUpdateItem {
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
ItemId: Oid;
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
UpgradeFingerprint: string;
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
PendingRerollFingerprint: string;
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
LastAdded: Oid;
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
}
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
export interface IMissionInventoryUpdateChallange {
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
Name: string;
Progress: number;
Completed: any[];
}
export interface MissionInventoryUpdateRewardInfo {
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
export interface IMissionInventoryUpdateRewardInfo {
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
node: string;
rewardTier?: number;
nightmareMode?: boolean;
@ -59,22 +59,22 @@ export interface MissionInventoryUpdateRewardInfo {
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
rewardSeed?: number;
}
export interface MissionInventoryUpdate {
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
export interface IMissionInventoryUpdate {
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
rewardsMultiplier?: number;
ActiveBoosters?: any[];
LongGuns?: MissionInventoryUpdateGear[];
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
Pistols?: MissionInventoryUpdateGear[];
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
Suits?: MissionInventoryUpdateGear[];
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
Melee?: MissionInventoryUpdateGear[];
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
RawUpgrades?: MissionInventoryUpdateItem[];
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
MiscItems?: MissionInventoryUpdateItem[];
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
LongGuns?: IMissionInventoryUpdateGear[];
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
Pistols?: IMissionInventoryUpdateGear[];
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
Suits?: IMissionInventoryUpdateGear[];
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
Melee?: IMissionInventoryUpdateGear[];
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
RawUpgrades?: IMissionInventoryUpdateItem[];
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
MiscItems?: IMissionInventoryUpdateItem[];
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
RegularCredits?: number;
ChallengeProgress?: MissionInventoryUpdateChallange[];
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
RewardInfo?: MissionInventoryUpdateRewardInfo;
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
ChallengeProgress?: IMissionInventoryUpdateChallange[];
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
RewardInfo?: IMissionInventoryUpdateRewardInfo;
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
FusionPoints?: number;
}
export interface MissionRewardResponse {
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
export interface IMissionRewardResponse {
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
StoreItem?: string;
TypeName: string;
UpgradeLevel: number;
@ -83,7 +83,7 @@ export interface MissionRewardResponse {
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
ProductCategory: string;
}
export interface Reward {
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
export interface IReward {
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
name: string;
chance: number;
rotation?: string;

OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type
OrdisPrime commented 2023-09-03 06:18:14 -07:00 (Migrated from github.com)
Review

instead of this use /types/commonTypes Oid type

instead of this use /types/commonTypes Oid type