Esempio n. 1
0
        public void Buy(int offerId)
        {
            var offer = _shop.Static.Offers[offerId];
            var good  = _shop.GetGood(offer.GoodId);

            //var current = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
            //if (current < slot.WaitTime)
            //{
            //    throw new Exception($"wait time = ");
            //}
            //slot.WaitTime = current;
            if (good.RealPrice != 0)
            {
                //var price = _shop.Static.RealPrices[good.RealPrice];
                //if (_shop.State.Transactions[price.StoreId] != PaymentProgress.Complete)
                //{
                //    throw new Exception("transactions no complete");
                //}
                //else
                //{
                //    _shop.State.Transactions.Remove(price.StoreId);
                //}
            }
            else
            {
                foreach (var price in good.Price?.Values ?? new IPrice[0])
                {
                    _scorers.Spend(price, _formula);
                }
            }
            _impacts.ExecuteImpact(good.Impact);
            foreach (var temp in good.Items)
            {
                _dropLogic.Drop(temp.Value);
            }
            LogicLog.BuyOffer(offerId);
        }