static void LocatorPurchase_OnTrade(DaggerfallTradeWindow.WindowModes mode, int numItems, int value)
 {
     if (mode == DaggerfallTradeWindow.WindowModes.Buy && numItems > 0)
     {   // Remove holy items from player items.
         ItemCollection coll = GameManager.Instance.PlayerEntity.Items;
         numItems = RemoveItems(coll, numItems, (int)ReligiousItems.Holy_tome);
         numItems = RemoveItems(coll, numItems, (int)ReligiousItems.Holy_dagger);
         coll     = GameManager.Instance.PlayerEntity.WagonItems;
         numItems = RemoveItems(coll, numItems, (int)ReligiousItems.Holy_tome);
         numItems = RemoveItems(coll, numItems, (int)ReligiousItems.Holy_dagger);
     }
     // If this was an attempt to steal, then reduce guild reputation by 25.
     if (value == 0)
     {
         GameManager.Instance.PlayerEntity.FactionData.ChangeReputation(factionId, -25, true);
     }
 }
        public static void TradeUpdateShopGold(DaggerfallTradeWindow.WindowModes mode, int value)
        {
            ulong           creationTime      = 0;
            int             buildingQuality   = 0;
            bool            investedIn        = false;
            uint            amountInvested    = 0;
            int             shopAttitude      = 0;
            int             buildingKey       = 0;
            int             currentGoldSupply = 0;
            int             currentBuildingID = GameManager.Instance.PlayerEnterExit.BuildingDiscoveryData.buildingKey;
            PlayerEnterExit playerEnterExit   = GameManager.Instance.PlayerEnterExit;

            try
            {
                ShopData sd;
                if (ShopBuildingData.TryGetValue(currentBuildingID, out sd))
                {
                    buildingKey     = currentBuildingID;
                    creationTime    = sd.CreationTime;
                    investedIn      = sd.InvestedIn;
                    amountInvested  = sd.AmountInvested;
                    shopAttitude    = sd.ShopAttitude;
                    buildingQuality = sd.BuildingQuality;
                }
                //Debug.LogFormat("Sale Value = {0}", value);
                if (mode == DaggerfallTradeWindow.WindowModes.Buy && (playerEnterExit.BuildingDiscoveryData.buildingType == DFLocation.BuildingTypes.Temple || playerEnterExit.BuildingDiscoveryData.buildingType == DFLocation.BuildingTypes.GuildHall))
                {
                    //Debug.Log("You are buying inside a Temple or a Guild-Hall.");
                }
                else if (mode == DaggerfallTradeWindow.WindowModes.Buy)
                {
                    currentGoldSupply = sd.CurrentGoldSupply + value;
                    ShopBuildingData.Remove(buildingKey);

                    ShopData currentBuildKey = new ShopData
                    {
                        CreationTime      = creationTime,
                        InvestedIn        = investedIn,
                        AmountInvested    = amountInvested,
                        ShopAttitude      = shopAttitude,
                        BuildingQuality   = buildingQuality,
                        CurrentGoldSupply = currentGoldSupply
                    };
                    ShopBuildingData.Add(buildingKey, currentBuildKey);
                }
                else
                {
                    currentGoldSupply = sd.CurrentGoldSupply - value;
                    ShopBuildingData.Remove(buildingKey);

                    ShopData currentBuildKey = new ShopData
                    {
                        CreationTime      = creationTime,
                        InvestedIn        = investedIn,
                        AmountInvested    = amountInvested,
                        ShopAttitude      = shopAttitude,
                        BuildingQuality   = buildingQuality,
                        CurrentGoldSupply = currentGoldSupply
                    };
                    ShopBuildingData.Add(buildingKey, currentBuildKey);
                }
                //Debug.LogFormat("Shop Gold Supply After Sale = {0}", currentGoldSupply);
                FlexCurrentGoldSupply = currentGoldSupply;
            }
            catch
            {
                //Debug.Log("You are buying inside a Temple or a Guild-Hall, as your first entered building since launching the game!");
            }
        }