mission complete

This commit is contained in:
holmityd 2023-09-07 14:43:59 +04:00
parent bc9cf70092
commit a999d6644c
4 changed files with 32 additions and 15 deletions

View File

@ -22,7 +22,7 @@ import { IMissionInventoryUpdateRequest } from "@/src/types/requestTypes";
- [ ] CurrentLoadOutIds - [ ] CurrentLoadOutIds
- [ ] AliveTime - [ ] AliveTime
- [ ] MissionTime - [ ] MissionTime
- [ ] Missions - [x] Missions
- [ ] CompletedAlerts - [ ] CompletedAlerts
- [ ] LastRegionPlayed - [ ] LastRegionPlayed
- [ ] GameModeId - [ ] GameModeId

View File

@ -11,6 +11,7 @@ import {
IFlavourItem, IFlavourItem,
IInventoryDatabaseDocument, IInventoryDatabaseDocument,
IMiscItem, IMiscItem,
IMission,
IRawUpgrade IRawUpgrade
} from "@/src/types/inventoryTypes/inventoryTypes"; } from "@/src/types/inventoryTypes/inventoryTypes";
import { IGenericUpdate } from "../types/genericUpdate"; 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; const gearKeys = ["Suits", "Pistols", "LongGuns", "Melee"] as const;
type GearKeysType = (typeof gearKeys)[number]; type GearKeysType = (typeof gearKeys)[number];
export const missionInventoryUpdate = async (data: IMissionInventoryUpdateRequest, accountId: string) => { 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); const inventory = await getInventory(accountId);
// credits // credits
@ -250,6 +264,7 @@ export const missionInventoryUpdate = async (data: IMissionInventoryUpdateReques
addConsumables(inventory, Consumables); addConsumables(inventory, Consumables);
addRecipes(inventory, Recipes); addRecipes(inventory, Recipes);
addChallenges(inventory, ChallengeProgress); addChallenges(inventory, ChallengeProgress);
addMissionComplate(inventory, Missions!);
const changedInventory = await inventory.save(); const changedInventory = await inventory.save();
return changedInventory.toJSON(); return changedInventory.toJSON();

View File

@ -45,19 +45,19 @@ const getRewards = ({
drops.push(...guaranteedDrops); drops.push(...guaranteedDrops);
} }
const testDrops = [ // const testDrops = [
{ chance: 7.69, name: "Lith W3 Relic", rotation: "B" }, // { chance: 7.69, name: "Lith W3 Relic", rotation: "B" },
{ 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: "2X Orokin Cell", rotation: "C" },
{ chance: 10.82, name: "Arrow Mutation", 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: "200 Endo", rotation: "C" }, // { chance: 10.82, name: "200 Endo", rotation: "C" },
{ chance: 10.82, name: "2,000,000 Credits Cache", 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: "Health Restore (Large)", rotation: "C" },
{ chance: 7.69, name: "Vapor Specter Blueprint", rotation: "C" } // { chance: 7.69, name: "Vapor Specter Blueprint", rotation: "C" }
]; // ];
console.log("Mission rewards:", testDrops); // console.log("Mission rewards:", testDrops);
return formatRewardsToInventoryType(testDrops); // return formatRewardsToInventoryType(testDrops);
console.log("Mission rewards:", drops); console.log("Mission rewards:", drops);
return formatRewardsToInventoryType(drops); return formatRewardsToInventoryType(drops);

View File

@ -4,6 +4,7 @@ import {
IConsumable, IConsumable,
ICrewShipSalvagedWeaponSkin, ICrewShipSalvagedWeaponSkin,
IMiscItem, IMiscItem,
IMission,
IRawUpgrade IRawUpgrade
} from "./inventoryTypes/inventoryTypes"; } from "./inventoryTypes/inventoryTypes";
import { IWeaponDatabase } from "./inventoryTypes/weaponTypes"; import { IWeaponDatabase } from "./inventoryTypes/weaponTypes";
@ -31,6 +32,7 @@ interface IMissionInventoryUpdateRequest {
ChallengeProgress?: IChallengeProgress[]; ChallengeProgress?: IChallengeProgress[];
RewardInfo?: IMissionInventoryUpdateRequestRewardInfo; RewardInfo?: IMissionInventoryUpdateRequestRewardInfo;
FusionPoints?: number; FusionPoints?: number;
Missions?: IMission;
} }
interface IMissionInventoryUpdateRequestRewardInfo { interface IMissionInventoryUpdateRequestRewardInfo {