Mission rewards fix #54
@ -22,7 +22,7 @@ import { IMissionInventoryUpdateRequest } from "@/src/types/requestTypes";
|
||||
- [ ] CurrentLoadOutIds
|
||||
- [ ] AliveTime
|
||||
- [ ] MissionTime
|
||||
- [ ] Missions
|
||||
- [x] Missions
|
||||
- [ ] CompletedAlerts
|
||||
- [ ] LastRegionPlayed
|
||||
- [ ] GameModeId
|
||||
|
@ -11,6 +11,7 @@ import {
|
||||
IFlavourItem,
|
||||
IInventoryDatabaseDocument,
|
||||
IMiscItem,
|
||||
IMission,
|
||||
IRawUpgrade
|
||||
} from "@/src/types/inventoryTypes/inventoryTypes";
|
||||
import { IGenericUpdate } from "../types/genericUpdate";
|
||||
@ -228,11 +229,24 @@ const addChallenges = (inventory: IInventoryDatabaseDocument, itemsArray: IChall
|
||||
});
|
||||
};
|
||||
|
||||
const addMissionComplate = (inventory: IInventoryDatabaseDocument, { Tag, Completes }: IMission) => {
|
||||
const { Missions } = inventory;
|
||||
const itemIndex = Missions.findIndex(item => item.Tag === Tag);
|
||||
|
||||
if (itemIndex !== -1) {
|
||||
Missions[itemIndex].Completes += Completes;
|
||||
inventory.markModified(`Missions.${itemIndex}.Completes`);
|
||||
} else {
|
||||
Missions.push({ Tag, Completes });
|
||||
}
|
||||
};
|
||||
|
||||
const gearKeys = ["Suits", "Pistols", "LongGuns", "Melee"] as const;
|
||||
type GearKeysType = (typeof gearKeys)[number];
|
||||
|
||||
export const missionInventoryUpdate = async (data: IMissionInventoryUpdateRequest, accountId: string) => {
|
||||
const { RawUpgrades, MiscItems, RegularCredits, ChallengeProgress, FusionPoints, Consumables, Recipes } = data;
|
||||
const { RawUpgrades, MiscItems, RegularCredits, ChallengeProgress, FusionPoints, Consumables, Recipes, Missions } =
|
||||
data;
|
||||
const inventory = await getInventory(accountId);
|
||||
|
||||
// credits
|
||||
@ -250,6 +264,7 @@ export const missionInventoryUpdate = async (data: IMissionInventoryUpdateReques
|
||||
addConsumables(inventory, Consumables);
|
||||
addRecipes(inventory, Recipes);
|
||||
addChallenges(inventory, ChallengeProgress);
|
||||
addMissionComplate(inventory, Missions!);
|
||||
|
||||
const changedInventory = await inventory.save();
|
||||
return changedInventory.toJSON();
|
||||
|
@ -45,19 +45,19 @@ const getRewards = ({
|
||||
drops.push(...guaranteedDrops);
|
||||
}
|
||||
|
||||
const testDrops = [
|
||||
{ chance: 7.69, name: "Lith W3 Relic", rotation: "B" },
|
||||
{ chance: 7.69, name: "Lith W3 Relic", rotation: "B" },
|
||||
{ chance: 10.82, name: "2X Orokin Cell", rotation: "C" },
|
||||
{ chance: 10.82, name: "Arrow Mutation", rotation: "C" },
|
||||
{ chance: 10.82, name: "200 Endo", rotation: "C" },
|
||||
{ chance: 10.82, name: "200 Endo", rotation: "C" },
|
||||
{ chance: 10.82, name: "2,000,000 Credits Cache", rotation: "C" },
|
||||
{ chance: 7.69, name: "Health Restore (Large)", rotation: "C" },
|
||||
{ chance: 7.69, name: "Vapor Specter Blueprint", rotation: "C" }
|
||||
];
|
||||
console.log("Mission rewards:", testDrops);
|
||||
return formatRewardsToInventoryType(testDrops);
|
||||
// const testDrops = [
|
||||
// { chance: 7.69, name: "Lith W3 Relic", rotation: "B" },
|
||||
// { chance: 7.69, name: "Lith W3 Relic", rotation: "B" },
|
||||
// { chance: 10.82, name: "2X Orokin Cell", rotation: "C" },
|
||||
// { chance: 10.82, name: "Arrow Mutation", rotation: "C" },
|
||||
// { chance: 10.82, name: "200 Endo", rotation: "C" },
|
||||
// { chance: 10.82, name: "200 Endo", rotation: "C" },
|
||||
// { chance: 10.82, name: "2,000,000 Credits Cache", rotation: "C" },
|
||||
// { chance: 7.69, name: "Health Restore (Large)", rotation: "C" },
|
||||
// { chance: 7.69, name: "Vapor Specter Blueprint", rotation: "C" }
|
||||
// ];
|
||||
// console.log("Mission rewards:", testDrops);
|
||||
// return formatRewardsToInventoryType(testDrops);
|
||||
|
||||
console.log("Mission rewards:", drops);
|
||||
return formatRewardsToInventoryType(drops);
|
||||
|
@ -4,6 +4,7 @@ import {
|
||||
IConsumable,
|
||||
ICrewShipSalvagedWeaponSkin,
|
||||
IMiscItem,
|
||||
IMission,
|
||||
IRawUpgrade
|
||||
} from "./inventoryTypes/inventoryTypes";
|
||||
import { IWeaponDatabase } from "./inventoryTypes/weaponTypes";
|
||||
@ -31,6 +32,7 @@ interface IMissionInventoryUpdateRequest {
|
||||
ChallengeProgress?: IChallengeProgress[];
|
||||
RewardInfo?: IMissionInventoryUpdateRequestRewardInfo;
|
||||
FusionPoints?: number;
|
||||
Missions?: IMission;
|
||||
}
|
||||
|
||||
interface IMissionInventoryUpdateRequestRewardInfo {
|
||||
|
Loading…
x
Reference in New Issue
Block a user