Пример #1
0
        public override bool Purshase(ShopDefItem item, int quantity)
        {
            bool ret = true;

            Fields.currentShopOwner = RelatedFaction;
            if (!Fields.shopItemsSold.ContainsKey(item.ID))
            {
                PurchasedItem pItem = new PurchasedItem();
                pItem.ID             = item.ID;
                pItem.Count          = quantity;
                pItem.Cost           = UIControler.GetPrice(item) * quantity;
                pItem.TransactionId  = PersistentMapClient.getBMarketId();
                pItem.remainingFunds = PersistentMapClient.companyStats.GetValue <int>("Funds");
                Fields.shopItemsSold.Add(item.ID, pItem);
            }
            else
            {
                Fields.shopItemsSold[item.ID].Count         += quantity;
                Fields.shopItemsSold[item.ID].Cost          += UIControler.GetPrice(item) * quantity;
                Fields.shopItemsSold[item.ID].remainingFunds = PersistentMapClient.companyStats.GetValue <int>("Funds");
            }
            try
            {
                if (Web.PostBuyItems(Fields.shopItemsSold, RelatedFaction, isBlackMarket))
                {
                    UIControler.DefaultPurshase(this, item, quantity);
                }
                else
                {
                    ret = false;
                }
            }
            catch (Exception e)
            {
                PersistentMapClient.Logger.LogError(e);
                ret = false;
            }
            Fields.shopItemsSold = new Dictionary <string, Objects.PurchasedItem>();
            needsRefresh         = true;
            return(ret);
        }