feat: dojo decorations #1079
@ -13,6 +13,9 @@ export const contributeToDojoComponentController: RequestHandler = async (req, r
 | 
			
		||||
    // Any clan member should have permission to contribute although notably permission is denied if they have not crafted the dojo key and were simply invited in.
 | 
			
		||||
    const request = JSON.parse(String(req.body)) as IContributeToDojoComponentRequest;
 | 
			
		||||
    const component = guild.DojoComponents.id(request.ComponentId)!;
 | 
			
		||||
    const inventoryChanges: IInventoryChanges = {};
 | 
			
		||||
 | 
			
		||||
    if (!component.CompletionTime) {
 | 
			
		||||
        const componentMeta = Object.values(ExportDojoRecipes.rooms).find(x => x.resultType == component.pf)!;
 | 
			
		||||
 | 
			
		||||
        component.RegularCredits ??= 0;
 | 
			
		||||
@ -20,14 +23,17 @@ export const contributeToDojoComponentController: RequestHandler = async (req, r
 | 
			
		||||
            request.RegularCredits = scaleRequiredCount(componentMeta.price) - component.RegularCredits;
 | 
			
		||||
        }
 | 
			
		||||
        component.RegularCredits += request.RegularCredits;
 | 
			
		||||
    const inventoryChanges: IInventoryChanges = updateCurrency(inventory, request.RegularCredits, false);
 | 
			
		||||
        inventoryChanges.RegularCredits = -request.RegularCredits;
 | 
			
		||||
        updateCurrency(inventory, request.RegularCredits, false);
 | 
			
		||||
 | 
			
		||||
        component.MiscItems ??= [];
 | 
			
		||||
        const miscItemChanges: IMiscItem[] = [];
 | 
			
		||||
        for (const ingredientContribution of request.IngredientContributions) {
 | 
			
		||||
            const componentMiscItem = component.MiscItems.find(x => x.ItemType == ingredientContribution.ItemType);
 | 
			
		||||
            if (componentMiscItem) {
 | 
			
		||||
            const ingredientMeta = componentMeta.ingredients.find(x => x.ItemType == ingredientContribution.ItemType)!;
 | 
			
		||||
                const ingredientMeta = componentMeta.ingredients.find(
 | 
			
		||||
                    x => x.ItemType == ingredientContribution.ItemType
 | 
			
		||||
                )!;
 | 
			
		||||
                if (
 | 
			
		||||
                    componentMiscItem.ItemCount + ingredientContribution.ItemCount >
 | 
			
		||||
                    scaleRequiredCount(ingredientMeta.ItemCount)
 | 
			
		||||
@ -62,6 +68,7 @@ export const contributeToDojoComponentController: RequestHandler = async (req, r
 | 
			
		||||
                component.CompletionTime = new Date(Date.now() + componentMeta.time * 1000);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    await guild.save();
 | 
			
		||||
    await inventory.save();
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user