chore: handle CalendarProgress in updateChallengeProgress
This commit is contained in:
parent
d8ff601be7
commit
4acd87aae6
@ -1,7 +1,7 @@
|
|||||||
import { RequestHandler } from "express";
|
import { RequestHandler } from "express";
|
||||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
||||||
import { getAccountForRequest } from "@/src/services/loginService";
|
import { getAccountForRequest } from "@/src/services/loginService";
|
||||||
import { addChallenges, getInventory } from "@/src/services/inventoryService";
|
import { addCalendarProgress, addChallenges, getInventory } from "@/src/services/inventoryService";
|
||||||
import { IChallengeProgress, ISeasonChallenge } from "@/src/types/inventoryTypes/inventoryTypes";
|
import { IChallengeProgress, ISeasonChallenge } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||||
import { IAffiliationMods } from "@/src/types/purchaseTypes";
|
import { IAffiliationMods } from "@/src/types/purchaseTypes";
|
||||||
import { getEntriesUnsafe } from "@/src/utils/ts-utils";
|
import { getEntriesUnsafe } from "@/src/utils/ts-utils";
|
||||||
@ -25,13 +25,17 @@ export const updateChallengeProgressController: RequestHandler = async (req, res
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
for (const [key, value] of getEntriesUnsafe(challenges)) {
|
for (const [key, value] of getEntriesUnsafe(challenges)) {
|
||||||
|
if (value === undefined) {
|
||||||
|
logger.error(`Challenge progress update key ${key} has no value`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "ChallengesFixVersion":
|
case "ChallengesFixVersion":
|
||||||
inventory.ChallengesFixVersion = value;
|
inventory.ChallengesFixVersion = value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "SeasonChallengeHistory":
|
case "SeasonChallengeHistory":
|
||||||
value!.forEach(({ challenge, id }) => {
|
value.forEach(({ challenge, id }) => {
|
||||||
const itemIndex = inventory.SeasonChallengeHistory.findIndex(i => i.challenge === challenge);
|
const itemIndex = inventory.SeasonChallengeHistory.findIndex(i => i.challenge === challenge);
|
||||||
if (itemIndex !== -1) {
|
if (itemIndex !== -1) {
|
||||||
inventory.SeasonChallengeHistory[itemIndex].id = id;
|
inventory.SeasonChallengeHistory[itemIndex].id = id;
|
||||||
@ -41,6 +45,10 @@ export const updateChallengeProgressController: RequestHandler = async (req, res
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "CalendarProgress":
|
||||||
|
addCalendarProgress(inventory, value);
|
||||||
|
break;
|
||||||
|
|
||||||
case "ChallengeProgress":
|
case "ChallengeProgress":
|
||||||
case "SeasonChallengeCompletions":
|
case "SeasonChallengeCompletions":
|
||||||
case "ChallengePTS":
|
case "ChallengePTS":
|
||||||
@ -63,5 +71,6 @@ interface IUpdateChallengeProgressRequest {
|
|||||||
ChallengeProgress?: IChallengeProgress[];
|
ChallengeProgress?: IChallengeProgress[];
|
||||||
SeasonChallengeHistory?: ISeasonChallenge[];
|
SeasonChallengeHistory?: ISeasonChallenge[];
|
||||||
SeasonChallengeCompletions?: ISeasonChallenge[];
|
SeasonChallengeCompletions?: ISeasonChallenge[];
|
||||||
|
CalendarProgress?: { challenge: string }[];
|
||||||
crossPlaySetting?: string;
|
crossPlaySetting?: string;
|
||||||
}
|
}
|
||||||
|
@ -1832,6 +1832,15 @@ export const addChallenges = (
|
|||||||
return affiliationMods;
|
return affiliationMods;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const addCalendarProgress = (inventory: TInventoryDatabaseDocument, value: { challenge: string }[]): void => {
|
||||||
|
const calendarProgress = getCalendarProgress(inventory);
|
||||||
|
const currentSeason = getWorldState().KnownCalendarSeasons[0];
|
||||||
|
calendarProgress.SeasonProgress.LastCompletedChallengeDayIdx = currentSeason.Days.findIndex(
|
||||||
|
day => day.events.length != 0 && day.events[0].challenge == value[value.length - 1].challenge
|
||||||
|
);
|
||||||
|
checkCalendarChallengeCompletion(calendarProgress, currentSeason);
|
||||||
|
};
|
||||||
|
|
||||||
export const addMissionComplete = (inventory: TInventoryDatabaseDocument, { Tag, Completes, Tier }: IMission): void => {
|
export const addMissionComplete = (inventory: TInventoryDatabaseDocument, { Tag, Completes, Tier }: IMission): void => {
|
||||||
const { Missions } = inventory;
|
const { Missions } = inventory;
|
||||||
const itemIndex = Missions.findIndex(item => item.Tag === Tag);
|
const itemIndex = Missions.findIndex(item => item.Tag === Tag);
|
||||||
|
@ -14,6 +14,7 @@ import { IRngResult, SRng, getRandomElement, getRandomReward } from "@/src/servi
|
|||||||
import { equipmentKeys, IMission, ITypeCount, TEquipmentKey } from "@/src/types/inventoryTypes/inventoryTypes";
|
import { equipmentKeys, IMission, ITypeCount, TEquipmentKey } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||||
import {
|
import {
|
||||||
addBooster,
|
addBooster,
|
||||||
|
addCalendarProgress,
|
||||||
addChallenges,
|
addChallenges,
|
||||||
addConsumables,
|
addConsumables,
|
||||||
addCrewShipAmmo,
|
addCrewShipAmmo,
|
||||||
@ -33,10 +34,8 @@ import {
|
|||||||
addSkin,
|
addSkin,
|
||||||
addStanding,
|
addStanding,
|
||||||
applyClientEquipmentUpdates,
|
applyClientEquipmentUpdates,
|
||||||
checkCalendarChallengeCompletion,
|
|
||||||
combineInventoryChanges,
|
combineInventoryChanges,
|
||||||
generateRewardSeed,
|
generateRewardSeed,
|
||||||
getCalendarProgress,
|
|
||||||
getDialogue,
|
getDialogue,
|
||||||
giveNemesisPetRecipe,
|
giveNemesisPetRecipe,
|
||||||
giveNemesisWeaponRecipe,
|
giveNemesisWeaponRecipe,
|
||||||
@ -671,12 +670,7 @@ export const addMissionInventoryUpdates = async (
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "CalendarProgress": {
|
case "CalendarProgress": {
|
||||||
const calendarProgress = getCalendarProgress(inventory);
|
addCalendarProgress(inventory, value);
|
||||||
const currentSeason = getWorldState().KnownCalendarSeasons[0];
|
|
||||||
calendarProgress.SeasonProgress.LastCompletedChallengeDayIdx = currentSeason.Days.findIndex(
|
|
||||||
day => day.events.length != 0 && day.events[0].challenge == value[value.length - 1].challenge
|
|
||||||
);
|
|
||||||
checkCalendarChallengeCompletion(calendarProgress, currentSeason);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "duviriCaveOffers": {
|
case "duviriCaveOffers": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user