add updateEntratiVault
This commit is contained in:
parent
6230f52f27
commit
f7f4b20422
@ -1,6 +1,6 @@
|
|||||||
import { toMongoDate } from "@/src/helpers/inventoryHelpers";
|
import { toMongoDate } from "@/src/helpers/inventoryHelpers";
|
||||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
||||||
import { getInventory } from "@/src/services/inventoryService";
|
import { getInventory, updateEntratiVault } from "@/src/services/inventoryService";
|
||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||||
import { RequestHandler } from "express";
|
import { RequestHandler } from "express";
|
||||||
|
|
||||||
@ -11,26 +11,7 @@ export const entratiLabConquestModeController: RequestHandler = async (req, res)
|
|||||||
"EntratiVaultCountResetDate EntratiVaultCountLastPeriod EntratiLabConquestUnlocked EchoesHexConquestUnlocked EchoesHexConquestActiveFrameVariants EchoesHexConquestActiveStickers EntratiLabConquestActiveFrameVariants EntratiLabConquestCacheScoreMission EchoesHexConquestCacheScoreMission"
|
"EntratiVaultCountResetDate EntratiVaultCountLastPeriod EntratiLabConquestUnlocked EchoesHexConquestUnlocked EchoesHexConquestActiveFrameVariants EchoesHexConquestActiveStickers EntratiLabConquestActiveFrameVariants EntratiLabConquestCacheScoreMission EchoesHexConquestCacheScoreMission"
|
||||||
);
|
);
|
||||||
const body = getJSONfromString<IEntratiLabConquestModeRequest>(String(req.body));
|
const body = getJSONfromString<IEntratiLabConquestModeRequest>(String(req.body));
|
||||||
if (!inventory.EntratiVaultCountResetDate || Date.now() >= inventory.EntratiVaultCountResetDate.getTime()) {
|
updateEntratiVault(inventory);
|
||||||
const EPOCH = 1734307200 * 1000; // Mondays, amirite?
|
|
||||||
const day = Math.trunc((Date.now() - EPOCH) / 86400000);
|
|
||||||
const week = Math.trunc(day / 7);
|
|
||||||
const weekStart = EPOCH + week * 604800000;
|
|
||||||
const weekEnd = weekStart + 604800000;
|
|
||||||
inventory.EntratiVaultCountLastPeriod = 0;
|
|
||||||
inventory.EntratiVaultCountResetDate = new Date(weekEnd);
|
|
||||||
if (inventory.EntratiLabConquestUnlocked) {
|
|
||||||
inventory.EntratiLabConquestUnlocked = 0;
|
|
||||||
inventory.EntratiLabConquestCacheScoreMission = 0;
|
|
||||||
inventory.EntratiLabConquestActiveFrameVariants = [];
|
|
||||||
}
|
|
||||||
if (inventory.EchoesHexConquestUnlocked) {
|
|
||||||
inventory.EchoesHexConquestUnlocked = 0;
|
|
||||||
inventory.EchoesHexConquestCacheScoreMission = 0;
|
|
||||||
inventory.EchoesHexConquestActiveFrameVariants = [];
|
|
||||||
inventory.EchoesHexConquestActiveStickers = [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (body.BuyMode) {
|
if (body.BuyMode) {
|
||||||
inventory.EntratiVaultCountLastPeriod! += 2;
|
inventory.EntratiVaultCountLastPeriod! += 2;
|
||||||
if (body.IsEchoesDeepArchemedea) {
|
if (body.IsEchoesDeepArchemedea) {
|
||||||
@ -51,7 +32,7 @@ export const entratiLabConquestModeController: RequestHandler = async (req, res)
|
|||||||
}
|
}
|
||||||
await inventory.save();
|
await inventory.save();
|
||||||
res.json({
|
res.json({
|
||||||
EntratiVaultCountResetDate: toMongoDate(inventory.EntratiVaultCountResetDate),
|
EntratiVaultCountResetDate: toMongoDate(inventory.EntratiVaultCountResetDate!),
|
||||||
EntratiVaultCountLastPeriod: inventory.EntratiVaultCountLastPeriod,
|
EntratiVaultCountLastPeriod: inventory.EntratiVaultCountLastPeriod,
|
||||||
EntratiLabConquestUnlocked: inventory.EntratiLabConquestUnlocked,
|
EntratiLabConquestUnlocked: inventory.EntratiLabConquestUnlocked,
|
||||||
EntratiLabConquestCacheScoreMission: inventory.EntratiLabConquestCacheScoreMission,
|
EntratiLabConquestCacheScoreMission: inventory.EntratiLabConquestCacheScoreMission,
|
||||||
|
|||||||
@ -2449,3 +2449,26 @@ export const giveNemesisPetRecipe = (
|
|||||||
export const getEffectiveAvatarImageType = (inventory: TInventoryDatabaseDocument): string => {
|
export const getEffectiveAvatarImageType = (inventory: TInventoryDatabaseDocument): string => {
|
||||||
return inventory.ActiveAvatarImageType ?? "/Lotus/Types/StoreItems/AvatarImages/AvatarImageDefault";
|
return inventory.ActiveAvatarImageType ?? "/Lotus/Types/StoreItems/AvatarImages/AvatarImageDefault";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const updateEntratiVault = (inventory: TInventoryDatabaseDocument): void => {
|
||||||
|
if (!inventory.EntratiVaultCountResetDate || Date.now() >= inventory.EntratiVaultCountResetDate.getTime()) {
|
||||||
|
const EPOCH = 1734307200 * 1000; // Mondays, amirite?
|
||||||
|
const day = Math.trunc((Date.now() - EPOCH) / 86400000);
|
||||||
|
const week = Math.trunc(day / 7);
|
||||||
|
const weekStart = EPOCH + week * 604800000;
|
||||||
|
const weekEnd = weekStart + 604800000;
|
||||||
|
inventory.EntratiVaultCountLastPeriod = 0;
|
||||||
|
inventory.EntratiVaultCountResetDate = new Date(weekEnd);
|
||||||
|
if (inventory.EntratiLabConquestUnlocked) {
|
||||||
|
inventory.EntratiLabConquestUnlocked = 0;
|
||||||
|
inventory.EntratiLabConquestCacheScoreMission = 0;
|
||||||
|
inventory.EntratiLabConquestActiveFrameVariants = [];
|
||||||
|
}
|
||||||
|
if (inventory.EchoesHexConquestUnlocked) {
|
||||||
|
inventory.EchoesHexConquestUnlocked = 0;
|
||||||
|
inventory.EchoesHexConquestCacheScoreMission = 0;
|
||||||
|
inventory.EchoesHexConquestActiveFrameVariants = [];
|
||||||
|
inventory.EchoesHexConquestActiveStickers = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user