Skip to content

Commit

Permalink
Use RemoteConfig to import Whizbang decks
Browse files Browse the repository at this point in the history
  • Loading branch information
azeier committed Aug 9, 2019
1 parent d9c6b0a commit 903036a
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions Hearthstone Deck Tracker/Importing/DeckImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using HearthDb.Enums;
using HearthMirror;
using HearthMirror.Objects;
using Hearthstone_Deck_Tracker.Hearthstone;
Expand All @@ -16,6 +15,7 @@
using Card = Hearthstone_Deck_Tracker.Hearthstone.Card;
using CardIds = HearthDb.CardIds;
using Deck = Hearthstone_Deck_Tracker.Hearthstone.Deck;
using Hearthstone_Deck_Tracker.Utility;

#endregion

Expand Down Expand Up @@ -154,21 +154,23 @@ public static List<ImportedDeck> GetImportedDecks(IEnumerable<HearthMirror.Objec
{
if(deck.Cards.Count == 1 && deck.Cards.Single().Id == CardIds.Collectible.Neutral.WhizbangTheWonderful)
{
var templateDecks = Reflection.GetTemplateDecks()?.Where(x => x.SortOrder < 2).Select(x =>
var data = RemoteConfig.Instance.Data;
if (data != null)
{
if(!Hearthstone.CardIds.CardClassHero.TryGetValue((CardClass)x.Class, out var hero))
return null;
return new HearthMirror.Objects.Deck
var whizbangDecks = data.WhizbangDecks.Select(x =>
{
Id = x.DeckId,
Name = x.Title,
Cards = x.Cards,
Hero = hero
};
}).Where(x => x != null);
if(templateDecks != null)
{
importedDecks.AddRange(GetImportedDecks(templateDecks, localDecks));
if(!Hearthstone.CardIds.CardClassHero.TryGetValue(x.Class, out var hero))
return null;
return new HearthMirror.Objects.Deck
{
Id = x.DeckId,
Name = x.Title,
Cards = x.Cards.Select(c => new HearthMirror.Objects.Card(Database.GetCardFromDbfId(c.DbfId).Id, c.Count, false)).ToList(),
Hero = hero,
};
}).Where(x => x != null);

importedDecks.AddRange(GetImportedDecks(whizbangDecks, localDecks));
continue;
}
}
Expand Down

0 comments on commit 903036a

Please sign in to comment.