fix: active quest and update quest
This commit is contained in:
parent
93dce67037
commit
eb96ee5168
@ -1,7 +1,30 @@
|
|||||||
|
import { getInventory } from "@/src/services/inventoryService";
|
||||||
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||||
import { RequestHandler } from "express";
|
import { RequestHandler } from "express";
|
||||||
|
|
||||||
const setActiveQuestController: RequestHandler = (_req, res) => {
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||||
res.sendStatus(200);
|
const setActiveQuestController: RequestHandler = async (req, res) => {
|
||||||
|
const accountId = await getAccountIdForRequest(req);
|
||||||
|
const quest = req.query.quest as string;
|
||||||
|
|
||||||
|
const inventory = await getInventory(accountId);
|
||||||
|
const questKey = inventory.QuestKeys.find(q => q.ItemType == quest);
|
||||||
|
if (questKey == null)
|
||||||
|
inventory.QuestKeys.push({ ItemType: quest });
|
||||||
|
inventory.ActiveQuest = quest;
|
||||||
|
await inventory.save();
|
||||||
|
|
||||||
|
res.json({
|
||||||
|
inventoryChanges: {
|
||||||
|
QuestKey: [{
|
||||||
|
ItemType: quest
|
||||||
|
}],
|
||||||
|
Herses: [],
|
||||||
|
PremiumCreditsFree: 0,
|
||||||
|
PremiumCredits: 0,
|
||||||
|
RegularCredits: 0
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export { setActiveQuestController };
|
export { setActiveQuestController };
|
||||||
|
38
src/controllers/api/updateQuestController.ts
Normal file
38
src/controllers/api/updateQuestController.ts
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import { RequestHandler } from "express";
|
||||||
|
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
||||||
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||||
|
import { IQuestKeyDatabase } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||||
|
import { logger } from "@/src/utils/logger";
|
||||||
|
import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
|
||||||
|
|
||||||
|
export interface IUpdateQuestRequest {
|
||||||
|
QuestKeys: IQuestKeyDatabase[];
|
||||||
|
PS: string;
|
||||||
|
questCompletion: boolean;
|
||||||
|
PlayerShipEvents: [];
|
||||||
|
crossPlaySetting: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IUpdateQuestResponse {
|
||||||
|
CustomData?: string;
|
||||||
|
MissionRewards: [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||||
|
const updateQuestController: RequestHandler = async (req, res) => {
|
||||||
|
const accountId = await getAccountIdForRequest(req);
|
||||||
|
const payload = getJSONfromString(req.body as string) as IUpdateQuestRequest;
|
||||||
|
logger.debug("quest: " + payload.QuestKeys[0].ItemType);
|
||||||
|
|
||||||
|
const inventory = await Inventory.findOne({ accountOwnerId: accountId });
|
||||||
|
if (inventory) {
|
||||||
|
/* empty */
|
||||||
|
}
|
||||||
|
|
||||||
|
const result: IUpdateQuestResponse = {
|
||||||
|
MissionRewards: []
|
||||||
|
};
|
||||||
|
res.json(result);
|
||||||
|
};
|
||||||
|
|
||||||
|
export { updateQuestController };
|
@ -58,6 +58,7 @@ import { surveysController } from "@/src/controllers/api/surveysController";
|
|||||||
import { syndicateSacrificeController } from "../controllers/api/syndicateSacrificeController";
|
import { syndicateSacrificeController } from "../controllers/api/syndicateSacrificeController";
|
||||||
import { trainingResultController } from "@/src/controllers/api/trainingResultController";
|
import { trainingResultController } from "@/src/controllers/api/trainingResultController";
|
||||||
import { updateChallengeProgressController } from "@/src/controllers/api/updateChallengeProgressController";
|
import { updateChallengeProgressController } from "@/src/controllers/api/updateChallengeProgressController";
|
||||||
|
import { updateQuestController } from "../controllers/api/updateQuestController";
|
||||||
import { updateSessionGetController, updateSessionPostController } from "@/src/controllers/api/updateSessionController";
|
import { updateSessionGetController, updateSessionPostController } from "@/src/controllers/api/updateSessionController";
|
||||||
import { updateThemeController } from "../controllers/api/updateThemeController";
|
import { updateThemeController } from "../controllers/api/updateThemeController";
|
||||||
import { upgradesController } from "@/src/controllers/api/upgradesController";
|
import { upgradesController } from "@/src/controllers/api/upgradesController";
|
||||||
@ -128,6 +129,7 @@ apiRouter.post("/stepSequencers.php", stepSequencersController);
|
|||||||
apiRouter.post("/syndicateSacrifice.php", syndicateSacrificeController);
|
apiRouter.post("/syndicateSacrifice.php", syndicateSacrificeController);
|
||||||
apiRouter.post("/trainingResult.php", trainingResultController);
|
apiRouter.post("/trainingResult.php", trainingResultController);
|
||||||
apiRouter.post("/updateChallengeProgress.php", updateChallengeProgressController);
|
apiRouter.post("/updateChallengeProgress.php", updateChallengeProgressController);
|
||||||
|
apiRouter.post("/updateQuest.php", updateQuestController);
|
||||||
apiRouter.post("/updateSession.php", updateSessionPostController);
|
apiRouter.post("/updateSession.php", updateSessionPostController);
|
||||||
apiRouter.post("/updateTheme.php", updateThemeController);
|
apiRouter.post("/updateTheme.php", updateThemeController);
|
||||||
apiRouter.post("/upgrades.php", upgradesController);
|
apiRouter.post("/upgrades.php", upgradesController);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user