public void Add(BattleCard card)
 {
     _deck[card.Id] = card;
     AddToSearchableCollection <DamageIndex>(_cardTypeSortedByDamage, card, (c) => c.Type);
     AddToSearchableCollection <SwagIndex>(_nameSortBySwag, card, (c) => c.Name);
     _sortBySwag.Add(card);
 }
コード例 #2
0
 public void Add(BattleCard card)
 {
     this.cards.Add(card.Id, card);
     this.AddToSearchCollection <DamageIndex>(this.typesSortedByDamage, card, c => c.Type);
     this.AddToSearchCollection <SwagIndex>(this.namesSortedBySwag, card, c => c.Name);
     this.sortedBySwag.Add(card);
 }
コード例 #3
0
        public void Add(BattleCard card)
        {
            if (this.Contains(card))
            {
                throw new InvalidOperationException();
            }

            cards[card.Id] = card;
        }
コード例 #4
0
        public void Add(BattleCard card)
        {
            if (this.Contains(card))
            {
                return;
            }

            this.cardsById.Add(card.Id, card);
        }
コード例 #5
0
        public override int Compare(BattleCard x, BattleCard y)
        {
            int compare = base.Compare(x, y);

            if (compare == 0)
            {
                compare = x.Id.CompareTo(y.Id);
            }
            return(compare);
        }
コード例 #6
0
        private void RemoveFromSearchableCollection(IDictionary dictionary, BattleCard card, Func <BattleCard, object> getKey)
        {
            var key = getKey(card);

            (dictionary[key] as Table <BattleCard>).Remove(card);
            if (!(dictionary[key] as Table <BattleCard>).Any())
            {
                dictionary.Remove(key);
            }
        }
コード例 #7
0
        public void RemoveById(int id)
        {
            this.CardNotExistException(id);
            BattleCard card = this.cards[id];

            this.RemoveFromSearchableCollection(this.cardTypeSortedByDamage, card, c => c.Type);
            this.RemoveFromSearchableCollection(this.cardNameSortedBySawg, card, c => c.Name);
            this.cardsSortedBySwag.Remove(card);
            this.cards.Remove(id);
        }
コード例 #8
0
        public void ChangeCardType(int id, CardType type)
        {
            this.CardNotExistException(id);

            BattleCard card = this.cards[id];

            this.RemoveFromSearchableCollection(this.cardTypeSortedByDamage, card, c => c.Type);
            card.Type = type;
            this.AddToSearchableCollection <DamageIndex>(this.cardTypeSortedByDamage, card, c => c.Type);
        }
コード例 #9
0
        public void Add(BattleCard card)
        {
            if (!this.Contains(card))
            {
                this.cards[card.Id] = card;
            }

            this.AddToSearchableCollection <DamageIndex>(this.cardTypeSortedByDamage, card, c => c.Type);
            this.AddToSearchableCollection <SwagIndex>(this.cardNameSortedBySawg, card, c => c.Name);
            this.cardsSortedBySwag.Add(card);
        }
        private void AddToSearchableCollection <T>(IDictionary dict, BattleCard card, Func <BattleCard, object> getKey)
            where T : Index <double>, new()
        {
            var key = getKey(card);

            if (dict[key] == null)
            {
                dict[key] = new Table <BattleCard>(new T());
            }

            (dict[key] as Table <BattleCard>).Add(card);
        }
コード例 #11
0
        public void RemoveById(int id)
        {
            if (!this.byId.ContainsKey(id))
            {
                throw new InvalidOperationException();
            }

            BattleCard cardToRemove = this.GetById(id);

            this.byId.Remove(id);
            this.byName[cardToRemove.Name].Remove(cardToRemove);
            this.bySwag.Remove(cardToRemove);
        }
コード例 #12
0
        private void RemoveFromSearchCollection(IDictionary dictionary, BattleCard card, Func <BattleCard, object> getKey)
        {
            var key = getKey(card);

            if (dictionary[key] != null)
            {
                var items = dictionary[key] as Table <BattleCard>;
                items.Remove(card);

                if (items.Count() == 0)
                {
                    dictionary.Remove(key);
                }
            }
        }
コード例 #13
0
        public void Add(BattleCard card)
        {
            if (!this.Contains(card))
            {
                this.byId.Add(card.Id, card);

                if (!this.byName.ContainsKey(card.Name))
                {
                    this.byName.Add(card.Name, new OrderedBag <BattleCard>((x, y)
                                                                           => y.Swag.CompareTo(x.Swag)));
                }

                this.byName[card.Name].Add(card);
                this.bySwag.Add(card);
            }
        }
        private void RemoveFromSearchableCollection(IDictionary dict, BattleCard card, Func <BattleCard, object> getKey)
        {
            if (!_deck.ContainsKey(card.Id))
            {
                throw new InvalidOperationException();
            }
            var key = getKey(card);

            if (dict[key] != null)
            {
                var items = (dict[key] as Table <BattleCard>);
                items.Remove(card);
                if (items.Count() == 0)
                {
                    dict.Remove(key);
                }
            }
        }
コード例 #15
0
 public virtual int Compare(BattleCard x, BattleCard y) =>
 GetKey(x).CompareTo(GetKey(y));
コード例 #16
0
 public bool Contains(BattleCard card)
 {
     return(this.cards.ContainsKey(card.Id));
 }
 public bool Contains(BattleCard card) => _deck.ContainsKey(card.Id);
コード例 #18
0
        public bool Contains(BattleCard card)
        {
            int key = card.Id;

            return(this.byId.ContainsKey(key));
        }
コード例 #19
0
 public virtual int Compare(BattleCard x, BattleCard y)
 {
     return(this.GetKey(x).CompareTo(this.GetKey(y)));
 }
コード例 #20
0
ファイル: RoyaleArena.cs プロジェクト: VenziVi/SoftUni
 public void Add(BattleCard card)
 {
     this.battleCards.Add(card.Id, card);
 }