Skip to content

Commit

Permalink
Fix Dreadscale not being added to ActualCards
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Burnett committed Aug 21, 2015
1 parent 20b956f commit 07b942e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
32 changes: 26 additions & 6 deletions HDTTests/Hearthstone/CardDbTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.IO;
using System.Linq;
using System.IO;
using Hearthstone_Deck_Tracker.Hearthstone;
using Microsoft.VisualStudio.TestTools.UnitTesting;

Expand All @@ -7,14 +8,33 @@ namespace HDTTests.Hearthstone
[TestClass]
public class CardDBTest
{
/*
* Correct for patch 2.7.0.9166
*/

// Test collectable card count
[TestMethod]
public void TestTotalCollectableCards()
{
Assert.AreEqual(566, Game.GetActualCards().Count);
// 3.0.0.9786 - TGT
Assert.AreEqual(698, Game.GetActualCards().Count);
}

// Dreadscale card has unusual id ending in 't', some tests to check it is recognized
[TestMethod]
public void TestDreadscaleFromId()
{
var card = Game.GetCardFromId("AT_063t");
Assert.AreEqual("Dreadscale", card.Name);
}
[TestMethod]
public void TestDreadscaleInGetActual()
{
var db = Game.GetActualCards();
var found = db.Any<Card>(c => c.LocalizedName.ToLowerInvariant().Contains("dreadscale"));
Assert.IsTrue(found);
}
[TestMethod]
public void TestDreadscaleIsActual()
{
Card c = new Card { Id = "AT_063t", Name = "Dreadscale", Type = "Minion" };
Assert.IsTrue(Game.IsActualCard(c));
}

[TestMethod]
Expand Down
6 changes: 4 additions & 2 deletions Hearthstone Deck Tracker/Hearthstone/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,14 @@ public static void AddPlayToCurrentGame(PlayType play, int turn, string cardId)
CurrentGameStats.AddPlay(play, turn, cardId);
}

// TODO: possibly refactor with GetActualCards, reduce duplication
public static bool IsActualCard(Card card)
{
if(card == null)
return false;
return (card.Type == "Minion" || card.Type == "Spell" || card.Type == "Weapon")
&& Helper.IsNumeric(card.Id.ElementAt(card.Id.Length - 1)) && Helper.IsNumeric(card.Id.ElementAt(card.Id.Length - 2))
&& (Helper.IsNumeric(card.Id.ElementAt(card.Id.Length - 1)) || card.Id == "AT_063t")
&& Helper.IsNumeric(card.Id.ElementAt(card.Id.Length - 2))
&& !CardIds.InvalidCardIds.Any(id => card.Id.Contains(id));
}

Expand Down Expand Up @@ -849,7 +851,7 @@ public static List<Card> GetActualCards()
{
return (from card in _cardDb.Values
where card.Type == "Minion" || card.Type == "Spell" || card.Type == "Weapon"
where Helper.IsNumeric(card.Id.ElementAt(card.Id.Length - 1))
where Helper.IsNumeric(card.Id.ElementAt(card.Id.Length - 1)) || card.Id == "AT_063t"
where Helper.IsNumeric(card.Id.ElementAt(card.Id.Length - 2))
where !CardIds.InvalidCardIds.Any(id => card.Id.Contains(id))
select card).ToList();
Expand Down

0 comments on commit 07b942e

Please sign in to comment.