Example #1
0
        public override UpdateResult Update()
        {
            var cards = _gameDataProvider.GetPackCards();

            if (cards?.Count == 5)
            {
                if (cards.All(x => _previousPack.Any(c => c.Id == x.Id & c.Premium == x.Premium)))
                {
                    return(UpdateResult.Continue);
                }
                if (_previousPack.Any())
                {
                    _invokeEvent = true;
                }
                _previousPack.Clear();
                _previousPack.AddRange(cards);
                if (_invokeEvent)
                {
                    var pack = new Pack((Booster)_gameDataProvider.GetPackId(),
                                        cards.Select(x => new CollectionCard(x.Id, x.Premium ? 0 : x.Count, x.Premium ? x.Count : 0)));
                    PackOpened?.Invoke(new PackOpenedEventArgs(pack));
                }
            }
            else
            {
                _invokeEvent = true;
            }

            return(UpdateResult.Continue);
        }