void Add(Index Index) { if (!_index.ContainsValue(Index.Card.HDTCard.Id)) { HearthDb.Card DbCard = HearthDb.Cards.GetFromDbfId(Index.Card.HDTCard.DbfIf); string name = ""; string text = ""; name = DbCard.Name?.ToLower(); text = DbCard.Text?.ToLower(); string locName = ""; string locText = ""; if (Enum.TryParse(Config.Instance.SelectedLanguage, out Locale lang)) { locName = DbCard.GetLocName(lang)?.ToLower(); locText = DbCard.GetLocText(lang)?.ToLower(); } _sb.Append(locName).Append(name).Append(locText).Append(text); _index.Add(_sb.ToString(), Index.Card.HDTCard.Id); _sb.Clear(); _indexObjects.Add(Index.Card.HDTCard.Id, new List <Index>()); } _indexObjects[Index.Card.HDTCard.Id].Add(Index); }
public Card(string id, string playerClass, Rarity rarity, string type, string name, int cost, string localizedName, int inHandCount, int count, string text, string englishText, int attack, int health, string race, string[] mechanics, int?durability, string artist, string set, List <string> alternativeNames = null, List <string> alternativeTexts = null, HearthDb.Card dbCard = null) { Id = id; PlayerClass = playerClass; Rarity = rarity; Type = type; Name = name; Cost = cost; LocalizedName = localizedName; InHandCount = inHandCount; Count = count; Text = text; EnglishText = englishText; Attack = attack; Health = health; Race = race; Durability = durability; Mechanics = mechanics; Artist = artist; Set = set; if (alternativeNames != null) { AlternativeNames = alternativeNames; } if (alternativeTexts != null) { AlternativeTexts = alternativeTexts; } _dbCard = dbCard; }
public Card(HearthDb.Card dbCard) { _dbCard = dbCard; Id = dbCard.Id; Count = 1; PlayerClass = HearthDbConverter.ConvertClass(dbCard.Class); Rarity = dbCard.Rarity; Type = HearthDbConverter.CardTypeConverter(dbCard.Type); Name = dbCard.GetLocName(Locale.enUS); Cost = dbCard.Cost; LocalizedName = dbCard.GetLocName(SelectedLanguage); Text = dbCard.GetLocText(SelectedLanguage); EnglishText = dbCard.GetLocText(Locale.enUS); Attack = dbCard.Attack; Health = dbCard.Health; Race = HearthDbConverter.RaceConverter(dbCard.Race); Durability = dbCard.Durability > 0 ? (int?)dbCard.Durability : null; Mechanics = dbCard.Mechanics; Artist = dbCard.ArtistName; Set = HearthDbConverter.SetConverter(dbCard.Set); foreach (var altLangStr in Config.Instance.AlternativeLanguages) { if (Enum.TryParse(altLangStr, out Locale altLang)) { AlternativeNames.Add(dbCard.GetLocName(altLang)); AlternativeTexts.Add(dbCard.GetLocText(altLang)); } } _loaded = true; }
public void Load() { if (_loaded) { return; } var stats = Database.GetCardFromId(Id); if (stats == null) { return; } PlayerClass = stats.PlayerClass; Rarity = stats.Rarity; Type = stats.Type; Name = stats.Name; Cost = stats.Cost; LocalizedName = stats.LocalizedName; InHandCount = stats.InHandCount; Text = stats._text; EnglishText = stats.EnglishText; Attack = stats.Attack; Health = stats.Health; Race = stats.Race; Durability = stats.Durability; Mechanics = stats.Mechanics; Artist = stats.Artist; Set = stats.Set; AlternativeNames = stats.AlternativeNames; AlternativeTexts = stats.AlternativeTexts; _dbCard = stats._dbCard; _loaded = true; OnPropertyChanged(); }
private void PrintByCardCounts() { List <Pack> packs = GetPacks(); List <Card> allCards = GetAllCards(); var cardCount = new Dictionary <HearthDb.Card, int>(); allCards.ForEach((card) => { HearthDb.Card key = card.CardInfo; int currentCount = cardCount.ContainsKey(key) ? cardCount[key] : 0; currentCount++; cardCount[key] = currentCount; }); var sorted = cardCount.OrderByDescending(kp => kp.Value).GroupBy(kp => kp.Key.Rarity).ToList(); foreach (var group in sorted) { var kvps = group.ToList(); WriteLine("{0} - {1}", group.Key, kvps.Count()); WriteLine("------------------------------"); kvps.ForEach((kvp) => { WriteLine("{0,25} {1}", kvp.Key.Name, kvp.Value); }); WriteLine(""); } }
public Card(HearthDb.Card card) { Id = card.Id; Name = card.Name; Text = card.Text; //use our own Card Class design switch (card.Class) { case CardClass.DRUID: Class = PlayerClasses.DRUID; break; case CardClass.HUNTER: Class = PlayerClasses.HUNTER; break; case CardClass.MAGE: Class = PlayerClasses.MAGE; break; case CardClass.PALADIN: Class = PlayerClasses.PALADIN; break; case CardClass.PRIEST: Class = PlayerClasses.PRIEST; break; case CardClass.ROGUE: Class = PlayerClasses.ROGUE; break; case CardClass.SHAMAN: Class = PlayerClasses.SHAMAN; break; case CardClass.WARLOCK: Class = PlayerClasses.WARLOCK; break; case CardClass.WARRIOR: Class = PlayerClasses.WARRIOR; break; default: Class = PlayerClasses.NONE; break; } Rarity = card.Rarity; Cost = card.Cost; }
private void Convert(HearthMirror.Objects.Deck deck) { for (int i = 0; i < deck.Cards.Count; i++) { HearthDb.Card dbCard = HearthDb.Cards.Collectible[deck.Cards[i].Id]; Card card = new Card(dbCard) { Count = deck.Cards[i].Count }; m_lstCards.Add(card); } }
private static int CheckForDisenchantedCards(List <Card> lstCurrentCollection, List <CachedCardEx> lstCardsHistory, List <Card> lstOld) { int nRet = 0; for (int i = 0; i < lstOld.Count; i++) { Card cardB = lstOld[i]; HearthDb.Card dbCardB = HearthDb.Cards.All[cardB.Id]; if (CardSets.All.ContainsKey(dbCardB.Set)) { Card cardA = lstCurrentCollection.Find(c => c.Id.Equals(cardB.Id) && c.Premium == cardB.Premium); int nCount = cardB.Count; if (cardA != null) { nCount = cardB.Count - cardA.Count; } else { } nCount *= -1; lstCardsHistory.Add(new CachedCardEx { Id = cardB.Id, Count = nCount, IsGolden = cardB.Premium, Timestamp = DateTime.Now }); nRet += 1; } else { } } return(nRet); }
public Card(HearthDb.Card dbCard, bool baconCard = false) { _dbCard = dbCard; Id = dbCard.Id; Count = 1; PlayerClass = HearthDbConverter.ConvertClass(dbCard.Class); Rarity = dbCard.Rarity; Type = HearthDbConverter.CardTypeConverter(dbCard.Type); Name = dbCard.GetLocName(Locale.enUS); Cost = dbCard.Cost; LocalizedName = dbCard.GetLocName(SelectedLanguage); Text = dbCard.GetLocText(SelectedLanguage); EnglishText = dbCard.GetLocText(Locale.enUS); Attack = dbCard.Attack; Health = dbCard.Health; Race = HearthDbConverter.RaceConverter(dbCard.Race); Durability = dbCard.Durability > 0 ? (int?)dbCard.Durability : null; Mechanics = dbCard.Mechanics; Artist = dbCard.ArtistName; Set = HearthDbConverter.SetConverter(dbCard.Set); BaconCard = baconCard; _loaded = true; }
public CardInfo(HearthDb.Card card, int count) { m_Card = card; m_Count = count; }
public Card(HearthDb.Card dbCard) { _dbCard = dbCard; Language lang; if(!Enum.TryParse(Config.Instance.SelectedLanguage, out lang)) lang = Language.enUS; Id = dbCard.Id; Count = 1; PlayerClass = HearthDbConverter.ConvertClass(dbCard.Class); Rarity = HearthDbConverter.RariryConverter(dbCard.Rarity); Type = HearthDbConverter.CardTypeConverter(dbCard.Type); Name = dbCard.GetLocName(Language.enUS); Cost = dbCard.Cost; LocalizedName = dbCard.GetLocName(lang); Text = dbCard.GetLocText(lang); EnglishText = dbCard.GetLocText(Language.enUS); Attack = dbCard.Attack; Health = dbCard.Health; Race = HearthDbConverter.RaceConverter(dbCard.Race); Durability = dbCard.Durability > 0 ? (int?)dbCard.Durability : null; Mechanics = dbCard.Mechanics; Artist = dbCard.ArtistName; Set = HearthDbConverter.SetConverter(dbCard.Set); foreach(var altLangStr in Config.Instance.AlternativeLanguages) { Language altLang; if(Enum.TryParse(altLangStr, out altLang)) { AlternativeNames.Add(dbCard.GetLocName(altLang)); AlternativeTexts.Add(dbCard.GetLocText(altLang)); } } _loaded = true; }
private void PrintDupesByUser() { List <Pack> packs = GetPacks(); List <Card> allCards = GetAllCards(); var outputs = new Dictionary <HearthDb.Enums.Rarity, List <String> >(); packs.GroupBy(pack => pack.UploaderId).ToList().ForEach((group) => { var packsCount = group.ToList().Count(); WriteLine("------------------------------"); WriteLine("{0} - {1}", group.Key, packsCount); WriteLine("------------------------------"); WriteLine(""); var allUserCards = group.Select((p) => p.Cards) .Aggregate(new List <Card>(), (result, cards) => { result.AddRange(cards); return(result); }).ToList(); var cardCount = new Dictionary <HearthDb.Card, int>(); allUserCards.ForEach((card) => { HearthDb.Card key = card.CardInfo; int currentCount = cardCount.ContainsKey(key) ? cardCount[key] : 0; currentCount++; cardCount[key] = currentCount; }); var sorted = cardCount.OrderByDescending(kp => kp.Value).GroupBy(kp => kp.Key.Rarity).ToList(); foreach (var g in sorted) { var kvps = g.ToList(); var total = kvps.Sum(kp => kp.Value); WriteLine("{0} - {1} - {2}", g.Key, kvps.Count(), total); WriteLine("------------------------------"); WriteLine("{0:0.00}% - {1:0.00}%", ((double)kvps[kvps.Count() - 1].Value / (double)total) * 100.0d, ((double)kvps[0].Value / (double)total) * 100.0d); if (!outputs.ContainsKey(g.Key)) { outputs[g.Key] = new List <string>(); } outputs[g.Key].Add(string.Format("{0:00.00}%", (double)kvps[0].Value / (double)kvps[kvps.Count() - 1].Value)); //kvps.ForEach((kvp) => //{ // WriteLine("{0,25} {1}", kvp.Key.Name, kvp.Value); //}); WriteLine(""); } }); WriteLine("------------------------------"); WriteLine("------------------------------"); WriteLine(""); outputs.ToList().ForEach((kvp) => { WriteLine("{0} ", kvp.Key); WriteLine("------------------------------"); kvp.Value.OrderByDescending(v => v).ToList().ForEach((v) => { WriteLine(v); }); WriteLine(""); }); }
public Card(string id, string playerClass, Rarity rarity, string type, string name, int cost, string localizedName, int inHandCount, int count, string text, string englishText, int attack, int health, string race, string[] mechanics, int? durability, string artist, string set, List<string> alternativeNames = null, List<string> alternativeTexts = null, HearthDb.Card dbCard = null) { Id = id; PlayerClass = playerClass; Rarity = rarity; Type = type; Name = name; Cost = cost; LocalizedName = localizedName; InHandCount = inHandCount; Count = count; Text = text; EnglishText = englishText; Attack = attack; Health = health; Race = race; Durability = durability; Mechanics = mechanics; Artist = artist; Set = set; if(alternativeNames != null) AlternativeNames = alternativeNames; if(alternativeTexts != null) AlternativeTexts = alternativeTexts; _dbCard = dbCard; }
public void Load() { if(_loaded) return; var stats = Database.GetCardFromId(Id); if(stats == null) return; PlayerClass = stats.PlayerClass; Rarity = stats.Rarity; Type = stats.Type; Name = stats.Name; Cost = stats.Cost; LocalizedName = stats.LocalizedName; InHandCount = stats.InHandCount; Text = stats._text; EnglishText = stats.EnglishText; Attack = stats.Attack; Health = stats.Health; Race = stats.Race; Durability = stats.Durability; Mechanics = stats.Mechanics; Artist = stats.Artist; Set = stats.Set; AlternativeNames = stats.AlternativeNames; AlternativeTexts = stats.AlternativeTexts; _dbCard = stats._dbCard; _loaded = true; OnPropertyChanged(); }
public PopularityCard(HearthDb.Card dbCard, JsonCard j) { this.dbCard = dbCard; this.jsonCard = j; }
public CardWrapper(Card card) { m_card = card; m_dbCard = HearthDb.Cards.All[m_card.Id]; }