fix some stuff
All checks were successful
Build / build (18) (push) Successful in 35s
Build / build (20) (push) Successful in 49s
Build / build (18) (pull_request) Successful in 36s
Build / build (20) (pull_request) Successful in 51s
Build / build (22) (pull_request) Successful in 26s
Build / build (22) (push) Successful in 27s
All checks were successful
Build / build (18) (push) Successful in 35s
Build / build (20) (push) Successful in 49s
Build / build (18) (pull_request) Successful in 36s
Build / build (20) (pull_request) Successful in 51s
Build / build (22) (pull_request) Successful in 26s
Build / build (22) (push) Successful in 27s
This commit is contained in:
parent
af6a466948
commit
49b702df2e
@ -5,6 +5,7 @@ import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
|||||||
import { updateQuestKey, IUpdateQuestRequest } from "@/src/services/questService";
|
import { updateQuestKey, IUpdateQuestRequest } from "@/src/services/questService";
|
||||||
import { getQuestCompletionItems } from "@/src/services/itemDataService";
|
import { getQuestCompletionItems } from "@/src/services/itemDataService";
|
||||||
import { addItems, getInventory } from "@/src/services/inventoryService";
|
import { addItems, getInventory } from "@/src/services/inventoryService";
|
||||||
|
import { IInventoryChanges } from "@/src/types/purchaseTypes";
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||||
export const updateQuestController: RequestHandler = async (req, res) => {
|
export const updateQuestController: RequestHandler = async (req, res) => {
|
||||||
@ -18,6 +19,9 @@ export const updateQuestController: RequestHandler = async (req, res) => {
|
|||||||
|
|
||||||
const inventory = await getInventory(accountId);
|
const inventory = await getInventory(accountId);
|
||||||
|
|
||||||
|
const updateQuestResponse: { CustomData?: string; InventoryChanges?: IInventoryChanges; MissionRewards: [] } = {
|
||||||
|
MissionRewards: []
|
||||||
|
};
|
||||||
updateQuestKey(inventory, updateQuestRequest.QuestKeys);
|
updateQuestKey(inventory, updateQuestRequest.QuestKeys);
|
||||||
|
|
||||||
if (updateQuestRequest.QuestKeys[0].Completed) {
|
if (updateQuestRequest.QuestKeys[0].Completed) {
|
||||||
@ -28,12 +32,15 @@ export const updateQuestController: RequestHandler = async (req, res) => {
|
|||||||
|
|
||||||
const inventoryChanges = await addItems(inventory, questCompletionItems);
|
const inventoryChanges = await addItems(inventory, questCompletionItems);
|
||||||
inventory.ActiveQuest = "";
|
inventory.ActiveQuest = "";
|
||||||
await inventory.save();
|
|
||||||
|
|
||||||
res.json({ MissionRewards: [], inventoryChanges });
|
updateQuestResponse.InventoryChanges = inventoryChanges;
|
||||||
return;
|
}
|
||||||
|
|
||||||
|
//TODO: might need to parse the custom data and add the associated items to inventory
|
||||||
|
if (updateQuestRequest.QuestKeys[0].CustomData) {
|
||||||
|
updateQuestResponse.CustomData = updateQuestRequest.QuestKeys[0].CustomData;
|
||||||
}
|
}
|
||||||
|
|
||||||
await inventory.save();
|
await inventory.save();
|
||||||
res.send({ MissionRewards: [] });
|
res.send(updateQuestResponse);
|
||||||
};
|
};
|
||||||
|
@ -494,7 +494,7 @@ const questKeysSchema = new Schema<IQuestKeyDatabase>(
|
|||||||
Progress: { type: [questProgressSchema], default: undefined },
|
Progress: { type: [questProgressSchema], default: undefined },
|
||||||
unlock: Boolean,
|
unlock: Boolean,
|
||||||
Completed: Boolean,
|
Completed: Boolean,
|
||||||
//CustomData: Schema.Types.Mixed,
|
CustomData: String,
|
||||||
CompletionDate: Date,
|
CompletionDate: Date,
|
||||||
ItemType: String
|
ItemType: String
|
||||||
},
|
},
|
||||||
|
@ -28,6 +28,7 @@ export const updateQuestKey = (
|
|||||||
throw new Error(`quest key ${questKeyUpdate[0].ItemType} not found`);
|
throw new Error(`quest key ${questKeyUpdate[0].ItemType} not found`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(questKeyUpdate[0]);
|
||||||
inventory.QuestKeys[questKeyIndex] = questKeyUpdate[0];
|
inventory.QuestKeys[questKeyIndex] = questKeyUpdate[0];
|
||||||
|
|
||||||
if (questKeyUpdate[0].Completed) {
|
if (questKeyUpdate[0].Completed) {
|
||||||
|
@ -86,7 +86,7 @@ export interface IQuestKeyDatabase {
|
|||||||
Progress?: IQuestStage[];
|
Progress?: IQuestStage[];
|
||||||
unlock?: boolean;
|
unlock?: boolean;
|
||||||
Completed?: boolean;
|
Completed?: boolean;
|
||||||
CustomData?: string; //TODO: check whether this actually exists
|
CustomData?: string;
|
||||||
ItemType: string;
|
ItemType: string;
|
||||||
CompletionDate?: Date;
|
CompletionDate?: Date;
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,8 @@ import {
|
|||||||
TSolarMapRegion,
|
TSolarMapRegion,
|
||||||
TEquipmentKey,
|
TEquipmentKey,
|
||||||
IFusionTreasure,
|
IFusionTreasure,
|
||||||
IQuestKeyClient,
|
IPlayerSkills,
|
||||||
IPlayerSkills
|
IQuestKeyDatabase
|
||||||
} from "./inventoryTypes/inventoryTypes";
|
} from "./inventoryTypes/inventoryTypes";
|
||||||
|
|
||||||
export interface IThemeUpdateRequest {
|
export interface IThemeUpdateRequest {
|
||||||
@ -46,7 +46,7 @@ export type IMissionInventoryUpdateRequest = {
|
|||||||
Consumables?: ITypeCount[];
|
Consumables?: ITypeCount[];
|
||||||
FusionTreasures?: IFusionTreasure[];
|
FusionTreasures?: IFusionTreasure[];
|
||||||
Recipes?: ITypeCount[];
|
Recipes?: ITypeCount[];
|
||||||
QuestKeys?: IQuestKeyClient[];
|
QuestKeys?: Omit<IQuestKeyDatabase, "CompletionDate">[];
|
||||||
RegularCredits?: number;
|
RegularCredits?: number;
|
||||||
MissionFailed: boolean;
|
MissionFailed: boolean;
|
||||||
MissionStatus: IMissionStatus;
|
MissionStatus: IMissionStatus;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user