feat: implement purchasing of formas, potatoes, etc.
This commit is contained in:
		
							parent
							
								
									6798e09b50
								
							
						
					
					
						commit
						19ba136c08
					
				@ -5,12 +5,15 @@ import {
 | 
				
			|||||||
    addBooster,
 | 
					    addBooster,
 | 
				
			||||||
    addCustomization,
 | 
					    addCustomization,
 | 
				
			||||||
    addMechSuit,
 | 
					    addMechSuit,
 | 
				
			||||||
 | 
					    addMiscItems,
 | 
				
			||||||
    addPowerSuit,
 | 
					    addPowerSuit,
 | 
				
			||||||
    addSentinel,
 | 
					    addSentinel,
 | 
				
			||||||
    addWeapon,
 | 
					    addWeapon,
 | 
				
			||||||
 | 
					    getInventory,
 | 
				
			||||||
    updateCurrency,
 | 
					    updateCurrency,
 | 
				
			||||||
    updateSlots
 | 
					    updateSlots
 | 
				
			||||||
} from "@/src/services/inventoryService";
 | 
					} from "@/src/services/inventoryService";
 | 
				
			||||||
 | 
					import { IMiscItem } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
				
			||||||
import { IPurchaseRequest, IPurchaseResponse, SlotNameToInventoryName, SlotPurchase } from "@/src/types/purchaseTypes";
 | 
					import { IPurchaseRequest, IPurchaseResponse, SlotNameToInventoryName, SlotPurchase } from "@/src/types/purchaseTypes";
 | 
				
			||||||
import { logger } from "@/src/utils/logger";
 | 
					import { logger } from "@/src/utils/logger";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -179,6 +182,8 @@ const handleTypesPurchase = async (typesName: string, accountId: string) => {
 | 
				
			|||||||
            return await handleSentinelPurchase(typesName, accountId);
 | 
					            return await handleSentinelPurchase(typesName, accountId);
 | 
				
			||||||
        case "SlotItems":
 | 
					        case "SlotItems":
 | 
				
			||||||
            return await handleSlotPurchase(typesName, accountId);
 | 
					            return await handleSlotPurchase(typesName, accountId);
 | 
				
			||||||
 | 
					        case "Items":
 | 
				
			||||||
 | 
					            return await handleMiscItemPurchase(typesName, accountId);
 | 
				
			||||||
        default:
 | 
					        default:
 | 
				
			||||||
            throw new Error(`unknown Types category: ${typeCategory} not implemented or new`);
 | 
					            throw new Error(`unknown Types category: ${typeCategory} not implemented or new`);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -232,3 +237,20 @@ const handleBoostersPurchase = async (boosterStoreName: string, accountId: strin
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const handleMiscItemPurchase = async (uniqueName: string, accountId: string) => {
 | 
				
			||||||
 | 
					    const inventory = await getInventory(accountId);
 | 
				
			||||||
 | 
					    const miscItemChanges = [
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            ItemType: uniqueName,
 | 
				
			||||||
 | 
					            ItemCount: 1
 | 
				
			||||||
 | 
					        } satisfies IMiscItem
 | 
				
			||||||
 | 
					    ];
 | 
				
			||||||
 | 
					    addMiscItems(inventory, miscItemChanges);
 | 
				
			||||||
 | 
					    await inventory.save();
 | 
				
			||||||
 | 
					    return {
 | 
				
			||||||
 | 
					        InventoryChanges: {
 | 
				
			||||||
 | 
					            MiscItems: miscItemChanges
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user