feat: nightcap syndicate #2934
@ -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;
 | 
				
			||||||
 | 
					            if (
 | 
				
			||||||
 | 
					                (!inventory.NodeIntrosCompleted.includes("CompletedVision1") && inventory.NokkoColony.FeedLevel > 20) ||
 | 
				
			||||||
 | 
					                (!inventory.NodeIntrosCompleted.includes("CompletedVision2") && inventory.NokkoColony.FeedLevel > 60)
 | 
				
			||||||
 | 
					            ) {
 | 
				
			||||||
 | 
					                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();
 | 
					                await inventory.save();
 | 
				
			||||||
                res.json({
 | 
					                res.json({
 | 
				
			||||||
                    FeedSucceeded: true,
 | 
					                    FeedSucceeded: true,
 | 
				
			||||||
                    FeedLevel: inventory.NokkoColony.FeedLevel,
 | 
					                    FeedLevel: inventory.NokkoColony.FeedLevel,
 | 
				
			||||||
                    InventoryChanges
 | 
					                    InventoryChanges
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user