Skip to content

Commit ecf3edd

Browse files
committed
fix bug can not find card Brawl
1 parent 76a47b5 commit ecf3edd

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

CardQuery/MainWindow.xaml.cs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections.Generic;
2+
using System.Linq;
23
using System.Text;
34
using System.Windows;
45
using System.Windows.Input;
@@ -118,21 +119,37 @@ private void ButtonCardName_Click(object sender, RoutedEventArgs e)
118119
return;
119120
}
120121

122+
var dictionary = new Dictionary<string, Card>();
121123
var cardList = Cards.GetFromFuzzyName(name, Locale.zhCN, false);
122-
if (cardList.Count == 0)
124+
foreach (var item in cardList)
125+
{
126+
AddItemToDictionary(dictionary, item);
127+
}
128+
cardList = Cards.GetFromFuzzyName(name, Locale.enUS, false);
129+
foreach (var item in cardList)
123130
{
124-
cardList = Cards.GetFromFuzzyName(name, Locale.enUS, false);
131+
AddItemToDictionary(dictionary, item);
125132
}
126133

127-
if (cardList == null || cardList.Count == 0)
134+
if (dictionary.Count == 0)
128135
{
129136
MessageBox.Show($"Can not find the card with name {name} in English(en-US) or Chinese(zh-CN)");
130137
return;
131138
}
132139

140+
cardList = dictionary.Values.ToList();
133141
AddCardToListView(cardList);
134142
}
135143

144+
private void AddItemToDictionary(Dictionary<string, Card> dictionary, Card card)
145+
{
146+
var cardId = card.Id;
147+
if (!dictionary.ContainsKey(cardId))
148+
{
149+
dictionary.Add(cardId, card);
150+
}
151+
}
152+
136153
private void AddCardToListView(List<Card> cards)
137154
{
138155
foreach (var card in cards)

0 commit comments

Comments
 (0)