Skip to content

Commit

Permalink
Card: always pass/load HearthDb.Card
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Zeier committed Mar 9, 2016
1 parent 0f700cc commit 5ac53b1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Hearthstone Deck Tracker/Hearthstone/Card.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Hearthstone_Deck_Tracker.Hearthstone
public class Card : ICloneable, INotifyPropertyChanged
{
[NonSerialized]
private readonly HearthDb.Card _dbCard;
private HearthDb.Card _dbCard;

private readonly Regex _overloadRegex = new Regex(@"Overload:.+?\((?<value>(\d+))\)");

Expand Down Expand Up @@ -67,7 +67,7 @@ public Card()

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)
string artist, string set, List<string> alternativeNames = null, List<string> alternativeTexts = null, HearthDb.Card dbCard = null)
{
Id = id;
PlayerClass = playerClass;
Expand All @@ -91,6 +91,7 @@ public Card(string id, string playerClass, Rarity rarity, string type, string na
AlternativeNames = alternativeNames;
if(alternativeTexts != null)
AlternativeTexts = alternativeTexts;
_dbCard = dbCard;
}

private Language? _selectedLanguage;
Expand Down Expand Up @@ -409,7 +410,7 @@ public ImageBrush Background
public string FormattedFlavorText => CleanUpText(_dbCard?.GetLocFlavorText(SelectedLanguage), false) ?? "";

public object Clone() => new Card(Id, PlayerClass, Rarity, Type, Name, Cost, LocalizedName, InHandCount, Count, _text, EnglishText, Attack,
Health, Race, Mechanics, Durability, Artist, Set, AlternativeNames, AlternativeTexts);
Health, Race, Mechanics, Durability, Artist, Set, AlternativeNames, AlternativeTexts, _dbCard);

public event PropertyChangedEventHandler PropertyChanged;

Expand Down Expand Up @@ -451,6 +452,7 @@ public void Load()
Set = stats.Set;
AlternativeNames = stats.AlternativeNames;
AlternativeTexts = stats.AlternativeTexts;
_dbCard = stats._dbCard;
_loaded = true;
OnPropertyChanged();
}
Expand Down

0 comments on commit 5ac53b1

Please sign in to comment.