Exemplo n.º 1
0
        private async void CheckForPacks()
        {
            _running = true;
            while (_watch)
            {
                await Task.Delay(1000);

                if (!_watch)
                {
                    break;
                }
                var cards = Reflection.GetPackCards();
                if (cards?.Any() ?? false)
                {
                    if (cards.All(x => _previousPack.Any(c => c.Id == x.Id & c.Premium == x.Premium)))
                    {
                        continue;
                    }
                    Log.Info("Found new pack: " + string.Join(", ", cards.Select(x => $"{x.Id}{(x.Premium ? " (golden)" : "")}")));
                    _previousPack.Clear();
                    _previousPack.AddRange(cards);
                    NewPackEventHandler?.Invoke(this, new PackEventArgs(cards));
                }
            }
            _running = false;
        }
Exemplo n.º 2
0
        private async void CheckForPacks()
        {
            _running = true;
            while (_watch)
            {
                await Task.Delay(_delay);

                if (!_watch)
                {
                    break;
                }
                var cards = _packProvider.GetCards();
                if (cards?.Count == 5)
                {
                    if (cards.All(x => _previousPack.Any(c => c.Id == x.Id & c.Premium == x.Premium)))
                    {
                        continue;
                    }
                    if (_previousPack.Any())
                    {
                        _invokeEvent = true;
                    }
                    _previousPack.Clear();
                    _previousPack.AddRange(cards);
                    if (_invokeEvent)
                    {
                        NewPackEventHandler?.Invoke(this, new PackEventArgs(cards, _packProvider.GetPackId()));
                    }
                }
                else
                {
                    _invokeEvent = true;
                }
            }
            _running = false;
        }