feat: trade fish for standing (#681)
This commit is contained in:
		
							parent
							
								
									e7a9f2e2b8
								
							
						
					
					
						commit
						b8ceb78c98
					
				
							
								
								
									
										8
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										8
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							@ -12,7 +12,7 @@
 | 
			
		||||
        "copyfiles": "^2.4.1",
 | 
			
		||||
        "express": "^5",
 | 
			
		||||
        "mongoose": "^8.9.2",
 | 
			
		||||
        "warframe-public-export-plus": "^0.5.17",
 | 
			
		||||
        "warframe-public-export-plus": "^0.5.18",
 | 
			
		||||
        "warframe-riven-info": "^0.1.2",
 | 
			
		||||
        "winston": "^3.17.0",
 | 
			
		||||
        "winston-daily-rotate-file": "^5.0.0"
 | 
			
		||||
@ -3778,9 +3778,9 @@
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/warframe-public-export-plus": {
 | 
			
		||||
      "version": "0.5.17",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.17.tgz",
 | 
			
		||||
      "integrity": "sha512-AWOfUxDHz+UmpbA9ZUGLIrP+3eQOiVq9tw1FXgx7ySkJLEnZUsoi3wn0IFiavSy2iE6JQIyCiSIZCJQTaCV6kA=="
 | 
			
		||||
      "version": "0.5.18",
 | 
			
		||||
      "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.5.18.tgz",
 | 
			
		||||
      "integrity": "sha512-wUaW5Ua5tXHOYkKJxbealdCcTnRLUN7UCkvYOJEwlB/H14EBzDaqxg4engGqzbq4H8fmttyp3EUo4vazSaxZWg=="
 | 
			
		||||
    },
 | 
			
		||||
    "node_modules/warframe-riven-info": {
 | 
			
		||||
      "version": "0.1.2",
 | 
			
		||||
 | 
			
		||||
@ -16,7 +16,7 @@
 | 
			
		||||
    "copyfiles": "^2.4.1",
 | 
			
		||||
    "express": "^5",
 | 
			
		||||
    "mongoose": "^8.9.2",
 | 
			
		||||
    "warframe-public-export-plus": "^0.5.17",
 | 
			
		||||
    "warframe-public-export-plus": "^0.5.18",
 | 
			
		||||
    "warframe-riven-info": "^0.1.2",
 | 
			
		||||
    "winston": "^3.17.0",
 | 
			
		||||
    "winston-daily-rotate-file": "^5.0.0"
 | 
			
		||||
 | 
			
		||||
@ -6,30 +6,48 @@ import { RequestHandler } from "express";
 | 
			
		||||
import { ExportResources } from "warframe-public-export-plus";
 | 
			
		||||
 | 
			
		||||
export const fishmongerController: RequestHandler = async (req, res) => {
 | 
			
		||||
    if (!req.query.dissect) {
 | 
			
		||||
        throw new Error("expected fishmonger request to be for dissection");
 | 
			
		||||
    }
 | 
			
		||||
    const accountId = await getAccountIdForRequest(req);
 | 
			
		||||
    const inventory = await getInventory(accountId);
 | 
			
		||||
    const body = getJSONfromString(String(req.body)) as IFishmongerRequest;
 | 
			
		||||
    const miscItemChanges: IMiscItem[] = [];
 | 
			
		||||
    let syndicateTag: string | undefined;
 | 
			
		||||
    let standingChange = 0;
 | 
			
		||||
    for (const fish of body.Fish) {
 | 
			
		||||
        for (const part of ExportResources[fish.ItemType].dissectionParts!) {
 | 
			
		||||
            const partItem = miscItemChanges.find(x => x.ItemType == part.ItemType);
 | 
			
		||||
            if (partItem) {
 | 
			
		||||
                partItem.ItemCount += part.ItemCount;
 | 
			
		||||
            } else {
 | 
			
		||||
                miscItemChanges.push(part);
 | 
			
		||||
        const fishData = ExportResources[fish.ItemType];
 | 
			
		||||
        if (req.query.dissect == "1") {
 | 
			
		||||
            for (const part of fishData.dissectionParts!) {
 | 
			
		||||
                const partItem = miscItemChanges.find(x => x.ItemType == part.ItemType);
 | 
			
		||||
                if (partItem) {
 | 
			
		||||
                    partItem.ItemCount += part.ItemCount * fish.ItemCount;
 | 
			
		||||
                } else {
 | 
			
		||||
                    miscItemChanges.push({ ItemType: part.ItemType, ItemCount: part.ItemCount * fish.ItemCount });
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            syndicateTag = fishData.syndicateTag!;
 | 
			
		||||
            standingChange += fishData.standingBonus! * fish.ItemCount;
 | 
			
		||||
        }
 | 
			
		||||
        miscItemChanges.push({ ItemType: fish.ItemType, ItemCount: fish.ItemCount * -1 });
 | 
			
		||||
    }
 | 
			
		||||
    addMiscItems(inventory, miscItemChanges);
 | 
			
		||||
    if (standingChange && syndicateTag) {
 | 
			
		||||
        const syndicate = inventory.Affiliations.find(x => x.Tag == syndicateTag);
 | 
			
		||||
        if (syndicate !== undefined) {
 | 
			
		||||
            syndicate.Standing += standingChange;
 | 
			
		||||
        } else {
 | 
			
		||||
            inventory.Affiliations.push({
 | 
			
		||||
                Tag: syndicateTag,
 | 
			
		||||
                Standing: standingChange
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    await inventory.save();
 | 
			
		||||
    res.json({
 | 
			
		||||
        InventoryChanges: {
 | 
			
		||||
            MiscItems: miscItemChanges
 | 
			
		||||
        }
 | 
			
		||||
        },
 | 
			
		||||
        SyndicateTag: syndicateTag,
 | 
			
		||||
        StandingChange: standingChange
 | 
			
		||||
    });
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user