fix: consume resources & standing required for gilding (#1132)
Fixes #1122 Reviewed-on: OpenWF/SpaceNinjaServer#1132
This commit is contained in:
		
							parent
							
								
									d5feec2c37
								
							
						
					
					
						commit
						814f4cfdad
					
				@ -1,29 +1,29 @@
 | 
				
			|||||||
import { RequestHandler } from "express";
 | 
					import { RequestHandler } from "express";
 | 
				
			||||||
import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
					import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
				
			||||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
					import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
				
			||||||
import { getInventory } from "@/src/services/inventoryService";
 | 
					import { addMiscItems, getInventory } from "@/src/services/inventoryService";
 | 
				
			||||||
import { WeaponTypeInternal } from "@/src/services/itemDataService";
 | 
					import { WeaponTypeInternal } from "@/src/services/itemDataService";
 | 
				
			||||||
import { ArtifactPolarity, EquipmentFeatures } from "@/src/types/inventoryTypes/commonInventoryTypes";
 | 
					import { ArtifactPolarity, EquipmentFeatures, IEquipmentClient } from "@/src/types/inventoryTypes/commonInventoryTypes";
 | 
				
			||||||
 | 
					import { ExportRecipes } from "warframe-public-export-plus";
 | 
				
			||||||
 | 
					import { IInventoryChanges } from "@/src/types/purchaseTypes";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const modularWeaponCategory: (WeaponTypeInternal | "Hoverboards")[] = [
 | 
					const modularWeaponCategory: (WeaponTypeInternal | "Hoverboards")[] = [
 | 
				
			||||||
    "LongGuns",
 | 
					    "LongGuns",
 | 
				
			||||||
    "Pistols",
 | 
					    "Pistols",
 | 
				
			||||||
    "Melee",
 | 
					    "Melee",
 | 
				
			||||||
    "OperatorAmps",
 | 
					    "OperatorAmps",
 | 
				
			||||||
    "Hoverboards" // Not sure about hoverboards just coppied from modual crafting
 | 
					    "Hoverboards"
 | 
				
			||||||
];
 | 
					];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
interface IGildWeaponRequest {
 | 
					interface IGildWeaponRequest {
 | 
				
			||||||
    ItemName: string;
 | 
					    ItemName: string;
 | 
				
			||||||
    Recipe: string; // /Lotus/Weapons/SolarisUnited/LotusGildKitgunBlueprint
 | 
					    Recipe: string; // e.g. /Lotus/Weapons/SolarisUnited/LotusGildKitgunBlueprint
 | 
				
			||||||
    PolarizeSlot?: number;
 | 
					    PolarizeSlot?: number;
 | 
				
			||||||
    PolarizeValue?: ArtifactPolarity;
 | 
					    PolarizeValue?: ArtifactPolarity;
 | 
				
			||||||
    ItemId: string;
 | 
					    ItemId: string;
 | 
				
			||||||
    Category: WeaponTypeInternal | "Hoverboards";
 | 
					    Category: WeaponTypeInternal | "Hoverboards";
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// In export there no recipes for gild action, so reputation and ressources only consumed visually
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export const gildWeaponController: RequestHandler = async (req, res) => {
 | 
					export const gildWeaponController: RequestHandler = async (req, res) => {
 | 
				
			||||||
    const accountId = await getAccountIdForRequest(req);
 | 
					    const accountId = await getAccountIdForRequest(req);
 | 
				
			||||||
    const data = getJSONfromString<IGildWeaponRequest>(String(req.body));
 | 
					    const data = getJSONfromString<IGildWeaponRequest>(String(req.body));
 | 
				
			||||||
@ -40,7 +40,8 @@ export const gildWeaponController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const weapon = inventory[data.Category][weaponIndex];
 | 
					    const weapon = inventory[data.Category][weaponIndex];
 | 
				
			||||||
    weapon.Features = EquipmentFeatures.GILDED; // maybe 9 idk if DOUBLE_CAPACITY is also given
 | 
					    weapon.Features ??= 0;
 | 
				
			||||||
 | 
					    weapon.Features |= EquipmentFeatures.GILDED;
 | 
				
			||||||
    weapon.ItemName = data.ItemName;
 | 
					    weapon.ItemName = data.ItemName;
 | 
				
			||||||
    weapon.XP = 0;
 | 
					    weapon.XP = 0;
 | 
				
			||||||
    if (data.Category != "OperatorAmps" && data.PolarizeSlot && data.PolarizeValue) {
 | 
					    if (data.Category != "OperatorAmps" && data.PolarizeSlot && data.PolarizeValue) {
 | 
				
			||||||
@ -52,11 +53,29 @@ export const gildWeaponController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
        ];
 | 
					        ];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    inventory[data.Category][weaponIndex] = weapon;
 | 
					    inventory[data.Category][weaponIndex] = weapon;
 | 
				
			||||||
    await inventory.save();
 | 
					    const inventoryChanges: IInventoryChanges = {};
 | 
				
			||||||
 | 
					    inventoryChanges[data.Category] = [weapon.toJSON<IEquipmentClient>()];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    res.json({
 | 
					    const recipe = ExportRecipes[data.Recipe];
 | 
				
			||||||
        InventoryChanges: {
 | 
					    inventoryChanges.MiscItems = recipe.secretIngredients!.map(ingredient => ({
 | 
				
			||||||
            [data.Category]: [weapon]
 | 
					        ItemType: ingredient.ItemType,
 | 
				
			||||||
 | 
					        ItemCount: ingredient.ItemCount * -1
 | 
				
			||||||
 | 
					    }));
 | 
				
			||||||
 | 
					    addMiscItems(inventory, inventoryChanges.MiscItems);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const affiliationMods = [];
 | 
				
			||||||
 | 
					    if (recipe.syndicateStandingChange) {
 | 
				
			||||||
 | 
					        const affiliation = inventory.Affiliations.find(x => x.Tag == recipe.syndicateStandingChange!.tag)!;
 | 
				
			||||||
 | 
					        affiliation.Standing += recipe.syndicateStandingChange.value;
 | 
				
			||||||
 | 
					        affiliationMods.push({
 | 
				
			||||||
 | 
					            Tag: recipe.syndicateStandingChange.tag,
 | 
				
			||||||
 | 
					            Standing: recipe.syndicateStandingChange.value
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    await inventory.save();
 | 
				
			||||||
 | 
					    res.json({
 | 
				
			||||||
 | 
					        InventoryChanges: inventoryChanges,
 | 
				
			||||||
 | 
					        AffiliationMods: affiliationMods
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user