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); }
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); }
public void Add(BattleCard card) { if (this.Contains(card)) { throw new InvalidOperationException(); } cards[card.Id] = card; }
public void Add(BattleCard card) { if (this.Contains(card)) { return; } this.cardsById.Add(card.Id, card); }
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); }
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); } }
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); }
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); }
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); }
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); }
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); } } }
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); } } }
public virtual int Compare(BattleCard x, BattleCard y) => GetKey(x).CompareTo(GetKey(y));
public bool Contains(BattleCard card) { return(this.cards.ContainsKey(card.Id)); }
public bool Contains(BattleCard card) => _deck.ContainsKey(card.Id);
public bool Contains(BattleCard card) { int key = card.Id; return(this.byId.ContainsKey(key)); }
public virtual int Compare(BattleCard x, BattleCard y) { return(this.GetKey(x).CompareTo(this.GetKey(y))); }
public void Add(BattleCard card) { this.battleCards.Add(card.Id, card); }