forked from OpenWF/SpaceNinjaServer
Completing Quests via the webui will now also award the quest's items and mails. Also fixes doubly adding key chain items. A few items will not be added, as it is currently impossible to determine the item category by path for these items. This will be fixed soon. Reviewed-on: OpenWF/SpaceNinjaServer#965 Co-authored-by: Ordis <134585663+OrdisPrime@users.noreply.github.com> Co-committed-by: Ordis <134585663+OrdisPrime@users.noreply.github.com>
24 lines
877 B
TypeScript
24 lines
877 B
TypeScript
import { RequestHandler } from "express";
|
|
import { parseString } from "@/src/helpers/general";
|
|
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
|
import { getInventory } from "@/src/services/inventoryService";
|
|
import { IGroup } from "@/src/types/loginTypes";
|
|
import { giveKeyChainItem } from "@/src/services/questService";
|
|
|
|
export const giveKeyChainTriggeredItemsController: RequestHandler = async (req, res) => {
|
|
const accountId = parseString(req.query.accountId);
|
|
const keyChainInfo = getJSONfromString<IKeyChainRequest>((req.body as string).toString());
|
|
|
|
const inventory = await getInventory(accountId);
|
|
const inventoryChanges = giveKeyChainItem(inventory, keyChainInfo);
|
|
await inventory.save();
|
|
|
|
res.send(inventoryChanges);
|
|
};
|
|
|
|
export interface IKeyChainRequest {
|
|
KeyChain: string;
|
|
ChainStage: number;
|
|
Groups?: IGroup[];
|
|
}
|