Skip to content

Commit

Permalink
refactor: return non-collectible cards by default
Browse files Browse the repository at this point in the history
...anywhere but in GetFromName.
  • Loading branch information
beheh committed Apr 23, 2024
1 parent 706e4bd commit 4c05073
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion HearthDb.Tests/UnitTest1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void TestMechanics()
[TestMethod]
public void TestCardText()
{
var lucentbark = Cards.GetFromDbfId(51796, false);
var lucentbark = Cards.GetFromDbfId(51796);
System.Console.WriteLine(lucentbark.Text);
Assert.IsTrue(lucentbark.Text.Contains("(5 left!)"));

Expand Down
2 changes: 1 addition & 1 deletion HearthDb/Cards.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static Cards()
public static Card GetFromName(string name, Locale lang, bool collectible = true)
=> (collectible ? Collectible : All).Values.FirstOrDefault(x => x.GetLocName(lang)?.Equals(name, StringComparison.InvariantCultureIgnoreCase) ?? false);

public static Card GetFromDbfId(int dbfId, bool collectible = true)
public static Card GetFromDbfId(int dbfId, bool collectible = false)
=> (collectible ? CollectibleByDbfId : AllByDbfId).TryGetValue(dbfId, out var card) ? card : null;

private static bool IsDeflectOBot(Entity entity) => entity.CardId == CardIds.NonCollectible.Neutral.DeflectOBot || entity.CardId == CardIds.NonCollectible.Neutral.DeflectOBotTavernBrawl;
Expand Down
6 changes: 3 additions & 3 deletions HearthDb/Deckstrings/Deck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class Deck
/// <summary>
/// Gets the card object for the given HeroDbfId
/// </summary>
public Card GetHero() => Cards.GetFromDbfId(HeroDbfId, false);
public Card GetHero() => Cards.GetFromDbfId(HeroDbfId);

/// <summary>
/// Converts (DbfId, Count) dictionary to (CardObject, Count).
Expand All @@ -61,10 +61,10 @@ public Dictionary<Card, int> GetCards() => CardDbfIds
public Dictionary<Card, Dictionary<Card, int>> GetSideboards() => Sideboards
.Select(x => new
{
Owner = Cards.GetFromDbfId(x.Key),
Owner = Cards.GetFromDbfId(x.Key),
Sideboard = x.Value.Select(s => new
{
Card = Cards.GetFromDbfId(s.Key),
Card = Cards.GetFromDbfId(s.Key),
Count = s.Value
}).Where(s => s.Card != null).ToDictionary(x => x.Card, x => x.Count)
})
Expand Down

0 comments on commit 4c05073

Please sign in to comment.