forked from OpenWF/SpaceNinjaServer
check if previous vision is completed
This commit is contained in:
parent
6da3e30348
commit
6fd7967b4f
@ -6,24 +6,40 @@ import { logger } from "../../utils/logger.ts";
|
|||||||
|
|
||||||
export const feedPrinceController: RequestHandler = async (req, res) => {
|
export const feedPrinceController: RequestHandler = async (req, res) => {
|
||||||
const accountId = await getAccountIdForRequest(req);
|
const accountId = await getAccountIdForRequest(req);
|
||||||
const inventory = await getInventory(accountId, "MiscItems NokkoColony");
|
const inventory = await getInventory(accountId, "MiscItems NokkoColony NodeIntrosCompleted");
|
||||||
const payload = getJSONfromString<IFeedPrinceRequest>(String(req.body));
|
const payload = getJSONfromString<IFeedPrinceRequest>(String(req.body));
|
||||||
|
|
||||||
switch (payload.Mode) {
|
switch (payload.Mode) {
|
||||||
case "r": {
|
case "r": {
|
||||||
const InventoryChanges = {};
|
|
||||||
addMiscItem(inventory, "/Lotus/Types/Items/MiscItems/MushroomFood", payload.Amount * -1, InventoryChanges);
|
|
||||||
inventory.NokkoColony ??= {
|
inventory.NokkoColony ??= {
|
||||||
FeedLevel: 0,
|
FeedLevel: 0,
|
||||||
JournalEntries: []
|
JournalEntries: []
|
||||||
};
|
};
|
||||||
|
const InventoryChanges = {};
|
||||||
inventory.NokkoColony.FeedLevel += payload.Amount;
|
inventory.NokkoColony.FeedLevel += payload.Amount;
|
||||||
await inventory.save();
|
if (
|
||||||
res.json({
|
(!inventory.NodeIntrosCompleted.includes("CompletedVision1") && inventory.NokkoColony.FeedLevel > 20) ||
|
||||||
FeedSucceeded: true,
|
(!inventory.NodeIntrosCompleted.includes("CompletedVision2") && inventory.NokkoColony.FeedLevel > 60)
|
||||||
FeedLevel: inventory.NokkoColony.FeedLevel,
|
) {
|
||||||
InventoryChanges
|
res.json({
|
||||||
});
|
FeedSucceeded: false,
|
||||||
|
FeedLevel: inventory.NokkoColony.FeedLevel - payload.Amount,
|
||||||
|
InventoryChanges
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
addMiscItem(
|
||||||
|
inventory,
|
||||||
|
"/Lotus/Types/Items/MiscItems/MushroomFood",
|
||||||
|
payload.Amount * -1,
|
||||||
|
InventoryChanges
|
||||||
|
);
|
||||||
|
await inventory.save();
|
||||||
|
res.json({
|
||||||
|
FeedSucceeded: true,
|
||||||
|
FeedLevel: inventory.NokkoColony.FeedLevel,
|
||||||
|
InventoryChanges
|
||||||
|
});
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user