Skip to content

Commit

Permalink
hearthstats tags
Browse files Browse the repository at this point in the history
  • Loading branch information
epix37 committed Apr 21, 2015
1 parent b685363 commit 1d70f2a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
13 changes: 9 additions & 4 deletions Hearthstone Deck Tracker/HearthStats/API/Objects/DeckObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ public class DeckObject
public int klass_id;
public string name;
public string notes;
public string[] tags;
public DateTime updated_at;

public Deck ToDeck(CardObject[] cards, DeckVersion[] versions, string version)
public Deck ToDeck(CardObject[] cards, string[] rawTags, DeckVersion[] versions, string version)
{
try
{
Expand All @@ -46,13 +45,19 @@ public Deck ToDeck(CardObject[] cards, DeckVersion[] versions, string version)

notes = notes.Trim();

var deck = new Deck(name ?? "", Dictionaries.HeroDict[klass_id],
//tags are returned all lowercase, find matching tag
var tags =
rawTags.Select(
tag =>
DeckList.Instance.AllTags.FirstOrDefault(t => string.Equals(t, tag, StringComparison.InvariantCultureIgnoreCase))
?? tag);
var deck = new Deck(name ?? "", Dictionaries.HeroDict[klass_id],
cards == null
? new List<Card>()
: cards.Where(x => x != null && x.count != null && x.id != null)
.Select(x => x.ToCard())
.Where(x => x != null)
.ToList(), tags ?? new string[0], notes ?? "", url, DateTime.Now, archived, new List<Card>(),
.ToList(), tags, notes ?? "", url, DateTime.Now, archived, new List<Card>(),
SerializableVersion.ParseOrDefault(version), new List<Deck>(), true, id.ToString(), Guid.NewGuid(),
deck_version_id.ToString());
deck.LastEdited = updated_at.ToLocalTime();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ public class DeckObjectWrapper
public DeckObject deck;
public DeckVersion[] versions;
public DateTime updated_at;
public string[] tags;

public Deck ToDeck()
{
if(deck == null)
return null;
return deck.ToDeck(cards, versions, current_version);
return deck.ToDeck(cards, tags, versions, current_version);
}
}
}

0 comments on commit 1d70f2a

Please sign in to comment.