示例#1
0
        public void Buy(int groupId, int slotId)
        {
            var slot    = _shop.GetSlot(groupId, slotId);
            var good    = _shop.GetGood(slot.GoodId);
            var current = DateTimeOffset.UtcNow.ToUnixTimeSeconds();

            if (!_shop.State.Groups.TryGetValue(groupId, out var groupData))
            {
                Logger.Error($"no state group id = {groupId}", this);
                return;
            }
            if (groupData.FinishTime != 0)
            {
                if (slot.IsBuy)
                {
                    throw new Exception($"Allready buy group id = {groupId} slot id = {slotId}");
                }
                slot.IsBuy = true;
            }

            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.BuyGood(slot.GoodId);
        }