forked from OpenWF/SpaceNinjaServer
feat: entratiLabConquestMode.php (#1291)
Reviewed-on: OpenWF/SpaceNinjaServer#1291
This commit is contained in:
parent
bc6f03b7c9
commit
e0d31b8988
69
src/controllers/api/entratiLabConquestModeController.ts
Normal file
69
src/controllers/api/entratiLabConquestModeController.ts
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
import { toMongoDate } from "@/src/helpers/inventoryHelpers";
|
||||||
|
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
||||||
|
import { getInventory } from "@/src/services/inventoryService";
|
||||||
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||||
|
import { RequestHandler } from "express";
|
||||||
|
|
||||||
|
export const entratiLabConquestModeController: RequestHandler = async (req, res) => {
|
||||||
|
const accountId = await getAccountIdForRequest(req);
|
||||||
|
const inventory = await getInventory(
|
||||||
|
accountId,
|
||||||
|
"EntratiVaultCountResetDate EntratiVaultCountLastPeriod EntratiLabConquestUnlocked EchoesHexConquestUnlocked EchoesHexConquestActiveFrameVariants EchoesHexConquestActiveStickers EntratiLabConquestActiveFrameVariants EntratiLabConquestCacheScoreMission EchoesHexConquestCacheScoreMission"
|
||||||
|
);
|
||||||
|
const body = getJSONfromString<IEntratiLabConquestModeRequest>(String(req.body));
|
||||||
|
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.EntratiLabConquestActiveFrameVariants = [];
|
||||||
|
}
|
||||||
|
if (inventory.EchoesHexConquestUnlocked) {
|
||||||
|
inventory.EchoesHexConquestUnlocked = 0;
|
||||||
|
inventory.EchoesHexConquestActiveFrameVariants = [];
|
||||||
|
inventory.EchoesHexConquestActiveStickers = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (body.BuyMode) {
|
||||||
|
inventory.EntratiVaultCountLastPeriod! += 2;
|
||||||
|
if (body.IsEchoesDeepArchemedea) {
|
||||||
|
inventory.EchoesHexConquestUnlocked = 1;
|
||||||
|
} else {
|
||||||
|
inventory.EntratiLabConquestUnlocked = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (body.IsEchoesDeepArchemedea) {
|
||||||
|
if (inventory.EchoesHexConquestUnlocked) {
|
||||||
|
inventory.EchoesHexConquestActiveFrameVariants = body.EchoesHexConquestActiveFrameVariants!;
|
||||||
|
inventory.EchoesHexConquestActiveStickers = body.EchoesHexConquestActiveStickers!;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (inventory.EntratiLabConquestUnlocked) {
|
||||||
|
inventory.EntratiLabConquestActiveFrameVariants = body.EntratiLabConquestActiveFrameVariants!;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await inventory.save();
|
||||||
|
res.json({
|
||||||
|
EntratiVaultCountResetDate: toMongoDate(inventory.EntratiVaultCountResetDate),
|
||||||
|
EntratiVaultCountLastPeriod: inventory.EntratiVaultCountLastPeriod,
|
||||||
|
EntratiLabConquestUnlocked: inventory.EntratiLabConquestUnlocked,
|
||||||
|
EntratiLabConquestCacheScoreMission: inventory.EntratiLabConquestCacheScoreMission,
|
||||||
|
EchoesHexConquestUnlocked: inventory.EchoesHexConquestUnlocked,
|
||||||
|
EchoesHexConquestCacheScoreMission: inventory.EchoesHexConquestCacheScoreMission
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
interface IEntratiLabConquestModeRequest {
|
||||||
|
BuyMode?: number;
|
||||||
|
IsEchoesDeepArchemedea?: number;
|
||||||
|
EntratiLabConquestUnlocked?: number;
|
||||||
|
EntratiLabConquestActiveFrameVariants?: string[];
|
||||||
|
EchoesHexConquestUnlocked?: number;
|
||||||
|
EchoesHexConquestActiveFrameVariants?: string[];
|
||||||
|
EchoesHexConquestActiveStickers?: string[];
|
||||||
|
}
|
@ -1463,7 +1463,20 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
|
|||||||
DialogueHistory: dialogueHistorySchema,
|
DialogueHistory: dialogueHistorySchema,
|
||||||
CalendarProgress: calenderProgressSchema,
|
CalendarProgress: calenderProgressSchema,
|
||||||
|
|
||||||
SongChallenges: { type: [songChallengeSchema], default: undefined }
|
SongChallenges: { type: [songChallengeSchema], default: undefined },
|
||||||
|
|
||||||
|
// Netracells + Deep Archimedea
|
||||||
|
EntratiVaultCountLastPeriod: { type: Number, default: undefined },
|
||||||
|
EntratiVaultCountResetDate: { type: Date, default: undefined },
|
||||||
|
EntratiLabConquestUnlocked: { type: Number, default: undefined },
|
||||||
|
EntratiLabConquestHardModeStatus: { type: Number, default: undefined },
|
||||||
|
EntratiLabConquestCacheScoreMission: { type: Number, default: undefined },
|
||||||
|
EntratiLabConquestActiveFrameVariants: { type: [String], default: undefined },
|
||||||
|
EchoesHexConquestUnlocked: { type: Number, default: undefined },
|
||||||
|
EchoesHexConquestHardModeStatus: { type: Number, default: undefined },
|
||||||
|
EchoesHexConquestCacheScoreMission: { type: Number, default: undefined },
|
||||||
|
EchoesHexConquestActiveFrameVariants: { type: [String], default: undefined },
|
||||||
|
EchoesHexConquestActiveStickers: { type: [String], default: undefined }
|
||||||
},
|
},
|
||||||
{ timestamps: { createdAt: "Created", updatedAt: false } }
|
{ timestamps: { createdAt: "Created", updatedAt: false } }
|
||||||
);
|
);
|
||||||
|
@ -30,6 +30,7 @@ import { dojoComponentRushController } from "@/src/controllers/api/dojoComponent
|
|||||||
import { dojoController } from "@/src/controllers/api/dojoController";
|
import { dojoController } from "@/src/controllers/api/dojoController";
|
||||||
import { dronesController } from "@/src/controllers/api/dronesController";
|
import { dronesController } from "@/src/controllers/api/dronesController";
|
||||||
import { endlessXpController } from "@/src/controllers/api/endlessXpController";
|
import { endlessXpController } from "@/src/controllers/api/endlessXpController";
|
||||||
|
import { entratiLabConquestModeController } from "@/src/controllers/api/entratiLabConquestModeController";
|
||||||
import { evolveWeaponController } from "@/src/controllers/api/evolveWeaponController";
|
import { evolveWeaponController } from "@/src/controllers/api/evolveWeaponController";
|
||||||
import { findSessionsController } from "@/src/controllers/api/findSessionsController";
|
import { findSessionsController } from "@/src/controllers/api/findSessionsController";
|
||||||
import { fishmongerController } from "@/src/controllers/api/fishmongerController";
|
import { fishmongerController } from "@/src/controllers/api/fishmongerController";
|
||||||
@ -183,6 +184,7 @@ apiRouter.post("/destroyDojoDeco.php", destroyDojoDecoController);
|
|||||||
apiRouter.post("/dojoComponentRush.php", dojoComponentRushController);
|
apiRouter.post("/dojoComponentRush.php", dojoComponentRushController);
|
||||||
apiRouter.post("/drones.php", dronesController);
|
apiRouter.post("/drones.php", dronesController);
|
||||||
apiRouter.post("/endlessXp.php", endlessXpController);
|
apiRouter.post("/endlessXp.php", endlessXpController);
|
||||||
|
apiRouter.post("/entratiLabConquestMode.php", entratiLabConquestModeController);
|
||||||
apiRouter.post("/evolveWeapon.php", evolveWeaponController);
|
apiRouter.post("/evolveWeapon.php", evolveWeaponController);
|
||||||
apiRouter.post("/findSessions.php", findSessionsController);
|
apiRouter.post("/findSessions.php", findSessionsController);
|
||||||
apiRouter.post("/fishmonger.php", fishmongerController);
|
apiRouter.post("/fishmonger.php", fishmongerController);
|
||||||
|
@ -335,6 +335,17 @@ export interface IInventoryClient extends IDailyAffiliations, InventoryClientEqu
|
|||||||
DialogueHistory?: IDialogueHistoryClient;
|
DialogueHistory?: IDialogueHistoryClient;
|
||||||
CalendarProgress: ICalendarProgress;
|
CalendarProgress: ICalendarProgress;
|
||||||
SongChallenges?: ISongChallenge[];
|
SongChallenges?: ISongChallenge[];
|
||||||
|
EntratiVaultCountLastPeriod?: number;
|
||||||
|
EntratiVaultCountResetDate?: Date;
|
||||||
|
EntratiLabConquestUnlocked?: number;
|
||||||
|
EntratiLabConquestHardModeStatus?: number;
|
||||||
|
EntratiLabConquestCacheScoreMission?: number;
|
||||||
|
EntratiLabConquestActiveFrameVariants?: string[];
|
||||||
|
EchoesHexConquestUnlocked?: number;
|
||||||
|
EchoesHexConquestHardModeStatus?: number;
|
||||||
|
EchoesHexConquestCacheScoreMission?: number;
|
||||||
|
EchoesHexConquestActiveFrameVariants?: string[];
|
||||||
|
EchoesHexConquestActiveStickers?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IAffiliation {
|
export interface IAffiliation {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user