예제 #1
0
        public int GetCount(ICardCountKey key)
        {
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            if (CardCountKeys.Standard.Equals(key))
            {
                return(Number);
            }
            if (CardCountKeys.Foil.Equals(key))
            {
                return(FoilNumber);
            }
            if (CardCountKeys.AltArt.Equals(key))
            {
                return(AltArtNumber);
            }
            if (CardCountKeys.FoilAltArt.Equals(key))
            {
                return(FoilAltArtNumber);
            }

            throw new ArgumentException("Unmanaged type of key", nameof(key));
        }
예제 #2
0
        public bool Equals(ICardCountKey other)
        {
            if (other == null)
            {
                return(false);
            }

            return(IsFoil == other.IsFoil && IsAltArt == other.IsAltArt);
        }
예제 #3
0
        public int GetCount(ICardCountKey key)
        {
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            if (!_counts.TryGetValue(key, out int value))
            {
                return(0);
            }

            return(value);
        }
예제 #4
0
        private void AuditAddCard(int idCollection, int idGatherer, int idLanguage, ICardCountKey cardCountKey, int countToAdd)
        {
            if (idCollection <= 0 || countToAdd == 0 || idGatherer == 0 || idLanguage < 0 || cardCountKey == null)
            {
                return;
            }

            InsertNewAudit(new Audit
            {
                IdCollection = idCollection,
                Quantity     = countToAdd,
                IdGatherer   = idGatherer,
                IsFoil       = cardCountKey.IsFoil,
                IsAltArt     = cardCountKey.IsAltArt,
                IdLanguage   = idLanguage
            });
        }
예제 #5
0
        public void ChangeCardEditionFoilAltArtLanguage(ICardCollection collection, ICard card, int countToChange, IEdition editionSource, ICardCountKey cardCountKeySource, ILanguage languageSource,
                                                        IEdition editionDestination, ICardCountKey cardCountKeyDestination, ILanguage languageDestination)
        {
            if (countToChange <= 0)
            {
                return;
            }

            using (new WriterLock(_lock))
            {
                if (languageSource == null || languageDestination == null || cardCountKeySource == null || cardCountKeyDestination == null)
                {
                    return;
                }

                int idGathererSource      = GetIdGatherer(card, editionSource);
                int idGathererDestination = GetIdGatherer(card, editionDestination);
                ICardInCollectionCount cardInCollectionCount = GetCardCollection(collection, idGathererSource, languageSource.Id);

                if (cardInCollectionCount == null || idGathererDestination == 0)
                {
                    return;
                }

                if (cardInCollectionCount.GetCount(cardCountKeySource) < countToChange)
                {
                    return;
                }

                CardCount cardCountSource = new CardCount
                {
                    { cardCountKeySource, -countToChange }
                };

                CardCount cardCountDestination = new CardCount
                {
                    { cardCountKeyDestination, countToChange }
                };

                InsertOrUpdateCardInCollection(collection.Id, idGathererSource, languageSource.Id, cardCountSource);
                InsertOrUpdateCardInCollection(collection.Id, idGathererDestination, languageDestination.Id, cardCountDestination);
            }
        }
예제 #6
0
        public void Add(ICardCountKey key, int count)
        {
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            if (count == 0)
            {
                return;
            }

            if (!_counts.TryGetValue(key, out int value))
            {
                value = 0;
            }

            value       += count;
            _counts[key] = value;
        }
예제 #7
0
        private void MoveCardToOtherCollection(ICardCollection collection, int idGatherer, int idLanguage, int countToMove, ICardCountKey cardCountKey, ICardCollection collectionDestination)
        {
            if (countToMove <= 0 || cardCountKey == null)
            {
                return;
            }

            using (new WriterLock(_lock))
            {
                ICardInCollectionCount cardInCollectionCount = GetCardCollection(collection, idGatherer, idLanguage);
                if (cardInCollectionCount == null)
                {
                    return;
                }

                if (cardInCollectionCount.GetCount(cardCountKey) < countToMove)
                {
                    return;
                }

                CardCount cardCountSource = new CardCount
                {
                    { cardCountKey, -countToMove }
                };

                CardCount cardCountDestination = new CardCount
                {
                    { cardCountKey, countToMove }
                };

                InsertOrUpdateCardInCollection(collection.Id, idGatherer, idLanguage, cardCountSource);
                InsertOrUpdateCardInCollection(collectionDestination.Id, idGatherer, idLanguage, cardCountDestination);
            }
        }
예제 #8
0
 public int GetCount(ICardCountKey key)
 {
     return(_cardCount.GetCount(key));
 }
예제 #9
0
 internal void Add(ICardCountKey key, int number)
 {
     _cardCount.Add(key, number);
 }
예제 #10
0
 public int GetCount(ICardCountKey key)
 {
     return(-1);
 }