1 #include "Types.h"
2 #include "Store_Inventory.h"
3 #include "Random.h"
4 #include "Debug.h"
5 #include "LaptopSave.h"
6 #include "ShopKeeper_Interface.h"
7 #include "ArmsDealerInvInit.h"
8 
9 #include "ContentManager.h"
10 #include "DealerInventory.h"
11 #include "GameInstance.h"
12 #include "ItemModel.h"
13 
14 
15 // SetupStoreInventory sets up the initial quantity on hand for all of Bobby Ray's inventory items
SetupStoreInventory(STORE_INVENTORY * pInventoryArray,BOOLEAN fUsed)16 void SetupStoreInventory( STORE_INVENTORY *pInventoryArray, BOOLEAN fUsed )
17 {
18 	UINT16 i;
19 	UINT16 usItemIndex;
20 	UINT8 ubNumBought;
21 
22 	//loop through all items BR can stock to init a starting quantity on hand
23 	for(i = 0; i < LaptopSaveInfo.usInventoryListLength[fUsed]; i++)
24 	{
25 		usItemIndex = pInventoryArray[ i ].usItemIndex;
26 		Assert(usItemIndex < MAXITEMS);
27 
28 		const ItemModel *item = GCM->getItem(usItemIndex);
29 		int maxAmount = fUsed ? GCM->getBobbyRayUsedInventory()->getMaxItemAmount(item) : GCM->getBobbyRayNewInventory()->getMaxItemAmount(item);
30 		ubNumBought = DetermineInitialInvItems(ARMS_DEALER_BOBBYR, usItemIndex, maxAmount, fUsed);
31 		if ( ubNumBought > 0)
32 		{
33 			// If doing used items
34 			if( fUsed )
35 			{
36 				// then there should only be 1 of them, and it's damaged
37 				pInventoryArray[i].ubQtyOnHand = 1;
38 				pInventoryArray[i].ubItemQuality = 20 + (UINT8) Random( 60 );
39 			}
40 			else	// new
41 			{
42 				pInventoryArray[i].ubQtyOnHand = ubNumBought;
43 				pInventoryArray[i].ubItemQuality = 100;
44 			}
45 		}
46 		else
47 		{
48 			// doesn't sell / not in stock
49 			pInventoryArray[i].ubQtyOnHand = 0;
50 			pInventoryArray[i].ubItemQuality = 0;
51 		}
52 	}
53 }
54