本文整理汇总了C#中Hearthstone_Deck_Tracker.Hearthstone.Deck类的典型用法代码示例。如果您正苦于以下问题:C# Deck类的具体用法?C# Deck怎么用?C# Deck使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Deck类属于Hearthstone_Deck_Tracker.Hearthstone命名空间,在下文中一共展示了Deck类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Import
public static async Task<Deck> Import(string url)
{
try
{
var doc = await ImportingHelper.GetHtmlDoc(url);
var deck = new Deck {IsArenaDeck = true};
var cardNodes = doc.DocumentNode.SelectSingleNode(".//ul[@class='deckList']");
var nameNodes = cardNodes.SelectNodes(".//span[@class='name']");
var countNodes = cardNodes.SelectNodes(".//span[@class='quantity']");
var numberOfCards = nameNodes.Count;
for(var i = 0; i < numberOfCards; i++)
{
var nameRaw = nameNodes.ElementAt(i).InnerText;
var name = HttpUtility.HtmlDecode(nameRaw);
var card = Database.GetCardFromName(name);
card.Count = int.Parse(countNodes.ElementAt(i).InnerText);
deck.Cards.Add(card);
if(string.IsNullOrEmpty(deck.Class) && card.PlayerClass != "Neutral")
deck.Class = card.PlayerClass;
}
if(DeckList.Instance.AllTags.Contains("Arena"))
deck.Tags.Add("Arena");
deck.Name = Helper.ParseDeckNameTemplate(Config.Instance.ArenaDeckNameTemplate, deck);
return deck;
}
catch(Exception e)
{
Log.Error(e);
return null;
}
}
示例2: SetDeckName
public static async Task SetDeckName(Deck deck, ExportingInfo info)
{
if(Config.Instance.ExportSetDeckName && !deck.TagList.ToLower().Contains("brawl"))
{
var name = deck.Name;
if(Config.Instance.ExportAddDeckVersionToName)
name += " " + deck.SelectedVersion.ShortVersionString;
Logger.WriteLine("Setting deck name...", "DeckExporter");
var nameDeckPos = new Point((int)Helper.GetScaledXPos(Config.Instance.ExportNameDeckX, info.HsRect.Width, info.Ratio),
(int)(Config.Instance.ExportNameDeckY * info.HsRect.Height));
await MouseActions.ClickOnPoint(info.HsHandle, nameDeckPos);
//send enter and second click to make sure the current name gets selected
SendKeys.SendWait("{ENTER}");
await MouseActions.ClickOnPoint(info.HsHandle, nameDeckPos);
if(Config.Instance.ExportPasteClipboard)
{
Clipboard.SetText(name);
SendKeys.SendWait("^v");
}
else
SendKeys.SendWait(name);
SendKeys.SendWait("{ENTER}");
}
}
示例3: SetDeckName
public static async Task SetDeckName(Deck deck, ExportingInfo info)
{
if(Config.Instance.ExportSetDeckName && !deck.TagList.ToLower().Contains("brawl"))
{
var name = Regex.Replace(deck.Name, @"[\(\)\{\}]", "");
if(name != deck.Name)
Logger.WriteLine("Removed parenthesis/braces from deck name. New name: " + name, "DeckExporter");
if(Config.Instance.ExportAddDeckVersionToName)
{
var version = " " + deck.SelectedVersion.ShortVersionString;
if(name.Length + version.Length > MaxLengthDeckName)
name = name.Substring(0, MaxLengthDeckName - version.Length);
name += version;
}
Logger.WriteLine("Setting deck name...", "DeckExporter");
var nameDeckPos = new Point((int)Helper.GetScaledXPos(Config.Instance.ExportNameDeckX, info.HsRect.Width, info.Ratio),
(int)(Config.Instance.ExportNameDeckY * info.HsRect.Height));
await ClickOnPoint(info.HsHandle, nameDeckPos);
//send enter and second click to make sure the current name gets selected
SendKeys.SendWait("{ENTER}");
await ClickOnPoint(info.HsHandle, nameDeckPos);
if(Config.Instance.ExportPasteClipboard)
{
Clipboard.SetText(name);
SendKeys.SendWait("^v");
}
else
SendKeys.SendWait(name);
SendKeys.SendWait("{ENTER}");
}
}
示例4: Import
public static async Task<Deck> Import(string url)
{
try
{
var doc = await ImportingHelper.GetHtmlDoc(url);
var deck = new Deck();
var deckName = HttpUtility.HtmlDecode(doc.DocumentNode.SelectSingleNode("//div[contains(@class, 'deck-info')]//h1").InnerText);
deck.Name = deckName;
var cardNodes = doc.DocumentNode.SelectNodes("//ul[@class='listado mazo-cartas']/li");
foreach(var cardNode in cardNodes)
{
var count = int.Parse(cardNode.SelectSingleNode(".//span[@class='cantidad']").InnerText);
var name = HttpUtility.HtmlDecode(cardNode.SelectSingleNode(".//span[@class='nombreCarta']").InnerText);
var card = Database.GetCardFromName(name);
card.Count = count;
deck.Cards.Add(card);
if(string.IsNullOrEmpty(deck.Class) && card.PlayerClass != "Neutral")
deck.Class = card.PlayerClass;
}
return deck;
}
catch(Exception e)
{
Log.Error(e);
return null;
}
}
示例5: Import
public static async Task<Deck> Import(string url)
{
try
{
var doc = await ImportingHelper.GetHtmlDoc(url);
var deck = new Deck();
var deckName = HttpUtility.HtmlDecode(doc.DocumentNode.SelectSingleNode("//h1[contains(@class,'page-title')]").FirstChild.InnerText);
deck.Name = deckName;
var cardNameNodes = doc.DocumentNode.SelectNodes("//div[contains(@class,'name')]");
var cardCountNodes = doc.DocumentNode.SelectNodes("//div[contains(@class,'qty')]");
var cardNames = cardNameNodes.Select(cardNameNode => HttpUtility.HtmlDecode(cardNameNode.InnerText));
var cardCosts = cardCountNodes.Select(countNode => int.Parse(countNode.InnerText));
var cardInfo = cardNames.Zip(cardCosts, (n, c) => new {Name = n, Count = c});
foreach(var info in cardInfo)
{
var card = Database.GetCardFromName(info.Name);
card.Count = info.Count;
deck.Cards.Add(card);
if(string.IsNullOrEmpty(deck.Class) && card.PlayerClass != "Neutral")
deck.Class = card.PlayerClass;
}
return deck;
}
catch(Exception e)
{
Logger.WriteLine(e.ToString(), "DeckImporter");
return null;
}
}
示例6: Import
public static async Task<Deck> Import(string url)
{
try
{
var doc = await ImportingHelper.GetHtmlDoc(url);
var deck = new Deck
{
Name =
HttpUtility.HtmlDecode(doc.DocumentNode.SelectSingleNode("//*[@id='content']/div[contains(@class, 'deck')]/h1").InnerText).Trim()
};
var nodes = doc.DocumentNode.SelectNodes("//a[@real_id]");
foreach(var cardNode in nodes)
{
var id = cardNode.Attributes["real_id"].Value;
var count = int.Parse(cardNode.Attributes["nb_card"].Value);
var card = Database.GetCardFromId(id);
card.Count = count;
deck.Cards.Add(card);
if(string.IsNullOrEmpty(deck.Class) && card.PlayerClass != "Neutral")
deck.Class = card.PlayerClass;
}
return deck;
}
catch(Exception e)
{
Log.Error(e);
return null;
}
}
示例7: MoveGamesToOtherDeckWithoutConfirmation
internal static void MoveGamesToOtherDeckWithoutConfirmation(Deck targetDeck, SerializableVersion targetVersion,
params GameStats[] games)
{
if(games == null)
return;
foreach(var game in games)
{
var defaultDeck = DefaultDeckStats.Instance.DeckStats.FirstOrDefault(ds => ds.Games.Contains(game));
if(defaultDeck != null)
{
defaultDeck.Games.Remove(game);
DefaultDeckStats.Save();
}
else
{
var deck = DeckList.Instance.Decks.FirstOrDefault(d => game.DeckId == d.DeckId);
deck?.DeckStats.Games.Remove(game);
}
game.PlayerDeckVersion = targetVersion;
game.HearthStatsDeckVersionId = targetDeck.GetVersion(targetVersion).HearthStatsDeckVersionId;
game.DeckId = targetDeck.DeckId;
game.DeckName = targetDeck.Name;
targetDeck.DeckStats.Games.Add(game);
if(HearthStatsAPI.IsLoggedIn && Config.Instance.HearthStatsAutoUploadNewGames)
HearthStatsManager.MoveMatchAsync(game, targetDeck, background: true).Forget();
}
DeckStatsList.Save();
DeckList.Save();
Core.MainWindow.DeckPickerList.UpdateDecks();
}
示例8: Import
public static async Task<Deck> Import(string url)
{
try
{
var doc = await ImportingHelper.GetHtmlDocGzip(url);
var deck = new Deck
{
Name =
HttpUtility.HtmlDecode(doc.DocumentNode.SelectSingleNode("//header[@class='panel-heading']/h1[@class='panel-title']").InnerText)
.Trim()
};
var nodes = doc.DocumentNode.SelectNodes("//table[@class='table table-bordered table-hover table-db']/tbody/tr");
foreach(var cardNode in nodes)
{
var name = HttpUtility.HtmlDecode(cardNode.SelectSingleNode(".//a").Attributes[3].Value);
var temp = HttpUtility.HtmlDecode(cardNode.SelectSingleNode(".//a/small").InnerText[0].ToString());
var count = int.Parse(temp);
var card = Database.GetCardFromName(name);
card.Count = count;
deck.Cards.Add(card);
if(string.IsNullOrEmpty(deck.Class) && card.PlayerClass != "Neutral")
deck.Class = card.PlayerClass;
}
return deck;
}
catch(Exception e)
{
Logger.WriteLine(e.ToString(), "DeckImporter");
return null;
}
}
示例9: ExportDeck
private async void ExportDeck(Deck deck)
{
var export = true;
if(Config.Instance.ShowExportingDialog)
{
var message =
string.Format(
"1) create a new, empty {0}-Deck {1}.\n\n2) leave the deck creation screen open.\n\n3)do not move your mouse or type after clicking \"export\"",
deck.Class, (Config.Instance.AutoClearDeck ? "(or open an existing one to be cleared automatically)" : ""));
if(deck.GetSelectedDeckVersion().Cards.Any(c => c.Name == "Stalagg" || c.Name == "Feugen"))
{
message +=
"\n\nIMPORTANT: If you own golden versions of Feugen or Stalagg please make sure to configure\nOptions > Other > Exporting";
}
var settings = new MessageDialogs.Settings {AffirmativeButtonText = "export"};
var result =
await
this.ShowMessageAsync("Export " + deck.Name + " to Hearthstone", message, MessageDialogStyle.AffirmativeAndNegative, settings);
export = result == MessageDialogResult.Affirmative;
}
if(export)
{
var controller = await this.ShowProgressAsync("Creating Deck", "Please do not move your mouse or type.");
Topmost = false;
await Task.Delay(500);
await DeckExporter.Export(deck);
await controller.CloseAsync();
if(deck.MissingCards.Any())
this.ShowMissingCardsMessage(deck);
}
}
示例10: Import
public static async Task<Deck> Import(string url)
{
try
{
var doc = await ImportingHelper.GetHtmlDoc(url);
var titleNode = doc.DocumentNode.SelectSingleNode("//div[contains(@class,'header__title internal')]/div[contains(@class,'container')]/h1");
var cardNodes = doc.DocumentNode.SelectNodes("//ul[contains(@class,'list-unstyled cartas_list')]/li");
var deck = new Deck();
deck.Name = HttpUtility.HtmlDecode(titleNode.ChildNodes.FirstOrDefault(x => x.Name == "#text").InnerText);
foreach (var node in cardNodes)
{
var nameNode = node.SelectSingleNode("span[contains(@class,'cartas__name')]/a");
var countNode = node.SelectSingleNode("span[contains(@class,'cartas__qtd')]");
var validChild = countNode?.ChildNodes.SingleOrDefault(c => c.Name == "#text");
var id = nameNode.Attributes.FirstOrDefault(a => a.Name == "data-hcfw-card-id").Value;
var count = validChild != null ? int.Parse(countNode.InnerText) : 1;
var card = Database.GetCardFromId(id);
card.Count = count;
deck.Cards.Add(card);
if (string.IsNullOrEmpty(deck.Class) && card.PlayerClass != "Neutral")
deck.Class = card.PlayerClass;
}
return deck;
}
catch (Exception e)
{
Log.Error(e);
return null;
}
}
示例11: Import
public static async Task<Deck> Import(string url)
{
try
{
var doc = await ImportingHelper.GetHtmlDoc(url);
var deck = new Deck();
var deckName = HttpUtility.HtmlDecode(doc.DocumentNode.SelectSingleNode("//h2[contains(@class, 'dname')]").InnerText);
deck.Name = deckName;
var cardNodes = doc.DocumentNode.SelectNodes("//ul[@class='vminionslist' or @class='vspellslist']/li");
foreach(var cardNode in cardNodes)
{
var count = int.Parse(cardNode.SelectSingleNode(".//span[@class='cantidad']").InnerText);
var name =
HttpUtility.HtmlDecode(
cardNode.SelectSingleNode(
".//span[@class='nombreCarta rarity_legendary' or @class='nombreCarta rarity_epic' or @class='nombreCarta rarity_rare' or @class='nombreCarta rarity_common' or @class='nombreCarta rarity_basic']")
.InnerText);
var card = Database.GetCardFromName(name);
card.Count = count;
deck.Cards.Add(card);
if(string.IsNullOrEmpty(deck.Class) && card.PlayerClass != "Neutral")
deck.Class = card.PlayerClass;
}
return deck;
}
catch(Exception e)
{
Logger.WriteLine(e.ToString(), "DeckImporter");
return null;
}
}
示例12: Import
public static async Task<Deck> Import(string url)
{
try
{
var doc = await ImportingHelper.GetHtmlDoc(url);
var deck = new Deck();
var deckName = HttpUtility.HtmlDecode(doc.DocumentNode.SelectSingleNode("//span[contains(@class, 'deckName')]").InnerText).Trim();
deck.Name = deckName;
var cardNodes = doc.DocumentNode.SelectNodes("//table[@class='deck_card_list']/tbody/tr/td/a[@class='real_id']");
foreach(var cardNode in cardNodes)
{
var id = cardNode.Attributes["real_id"].Value;
var count = int.Parse(cardNode.Attributes["nb_card"].Value);
var card = Database.GetCardFromId(id);
card.Count = count;
deck.Cards.Add(card);
if(string.IsNullOrEmpty(deck.Class) && card.PlayerClass != "Neutral")
deck.Class = card.PlayerClass;
}
return deck;
}
catch(Exception e)
{
Logger.WriteLine(e.ToString(), "DeckImporter");
return null;
}
}
示例13: TryFindDeck
public static async Task<Deck> TryFindDeck(string url)
{
try
{
var doc = await ImportingHelper.GetHtmlDoc(url);
var deck = new Deck();
var metaNodes = doc.DocumentNode.SelectNodes("//meta");
if(!metaNodes.Any())
return null;
deck.Name = GetMetaProperty(metaNodes, "x-hearthstone:deck");
deck.Url = GetMetaProperty(metaNodes, "x-hearthstone:deck:url") ?? url;
var heroId = GetMetaProperty(metaNodes, "x-hearthstone:deck:hero");
if(!string.IsNullOrEmpty(heroId))
deck.Class = Database.GetCardFromId(heroId).PlayerClass;
var cardList = GetMetaProperty(metaNodes, "x-hearthstone:deck:cards").Split(',');
foreach(var idGroup in cardList.GroupBy(x => x))
{
var card = Database.GetCardFromId(idGroup.Key);
card.Count = idGroup.Count();
deck.Cards.Add(card);
if(deck.Class == null && card.IsClassCard)
deck.Class = card.PlayerClass;
}
return deck;
}
catch(Exception e)
{
Log.Error(e);
return null;
}
}
示例14: SubtractOperator001
public void SubtractOperator001()
{
Deck d1 = new Deck();
Deck d2 = new Deck();
//just in d1
d1.Cards.Add(new Card("ID_1", "", Rarity.FREE, "", "ID 1", 0, "", 0, 1, "", "", 0, 0, "", new string[] { }, 0, "", ""));
//in both but diff count
d1.Cards.Add(new Card("ID_2", "", Rarity.FREE, "", "ID 2", 0, "", 0, 2, "", "", 0, 0, "", new string[] { }, 0, "", ""));
d2.Cards.Add(new Card("ID_2", "", Rarity.FREE, "", "ID 2", 0, "", 0, 3, "", "", 0, 0, "", new string[] { }, 0, "", ""));
//just in d2
d2.Cards.Add(new Card("ID_3", "", Rarity.FREE, "", "ID 3", 0, "", 0, 2, "", "", 0, 0, "", new string[] { }, 0, "", ""));
//in bth and same cont
d1.Cards.Add(new Card("ID_4", "", Rarity.FREE, "", "ID 4", 0, "", 0, 5, "", "", 0, 0, "", new string[] { }, 0, "", ""));
d2.Cards.Add(new Card("ID_4", "", Rarity.FREE, "", "ID 4", 0, "", 0, 5, "", "", 0, 0, "", new string[] { }, 0, "", ""));
IEnumerable<Card> result = d1 - d2;
Assert.IsNotNull(result);
foreach (Card c in result)
{
Console.Out.WriteLine(c.ToString());
}
Assert.AreEqual(3, result.Count());
Assert.AreEqual(1, result.Where(c => c.Id == "ID_1" && c.Count == 1).Count(), "ID 1, expected count 1");
Assert.AreEqual(1, result.Where(c => c.Id == "ID_2" && c.Count == -1).Count(), "ID 2, expected count -1");
Assert.AreEqual(1, result.Where(c => c.Id == "ID_3" && c.Count == -2).Count(), "ID 3, expected count -2");
}
示例15: ExportDeck
private async void ExportDeck(Deck deck)
{
var export = true;
if(Config.Instance.ShowExportingDialog)
{
var message = $"1) Create a new (or open an existing) {deck.Class} deck.\n\n2) Leave the deck creation screen open.\n\n3) Click 'Export' and do not move your mouse or type until done.";
var settings = new MessageDialogs.Settings {AffirmativeButtonText = "Export"};
var result = await this.ShowMessageAsync("Export " + deck.Name + " to Hearthstone", message, MessageDialogStyle.AffirmativeAndNegative, settings);
export = result == MessageDialogResult.Affirmative;
}
if(export)
{
var controller = await this.ShowProgressAsync("Creating Deck", "Please do not move your mouse or type.");
Topmost = false;
await Task.Delay(500);
var success = await DeckExporter.Export(deck);
await controller.CloseAsync();
if(success)
{
var hsDeck = HearthMirror.Reflection.GetEditedDeck();
if(hsDeck != null)
{
var existingHsId = DeckList.Instance.Decks.Where(x => x.DeckId != deck.DeckId).FirstOrDefault(x => x.HsId == hsDeck.Id);
if(existingHsId != null)
existingHsId.HsId = 0;
deck.HsId = hsDeck.Id;
DeckList.Save();
}
}
if(deck.MissingCards.Any())
this.ShowMissingCardsMessage(deck);
}
}