本文整理汇总了C#中Hearthstone_Deck_Tracker.Hearthstone.Deck.GetVersion方法的典型用法代码示例。如果您正苦于以下问题:C# Deck.GetVersion方法的具体用法?C# Deck.GetVersion怎么用?C# Deck.GetVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hearthstone_Deck_Tracker.Hearthstone.Deck
的用法示例。
在下文中一共展示了Deck.GetVersion方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
示例2: UploadDeckAsync
public static async Task<PostResult> UploadDeckAsync(Deck deck, bool saveFilesAfter = true, bool background = false)
{
Log.Info("trying to upload deck " + deck);
if(!HearthStatsAPI.IsLoggedIn)
{
Log.Error("not logged in");
return PostResult.Failed;
}
if(background)
AddBackgroundActivity();
var first = deck.GetVersion(1, 0);
if(!first.IsArenaDeck && first.HasHearthStatsId && !deck.HasHearthStatsId && !deck.HearthStatsIdsAlreadyReset)
{
first.HearthStatsId = first.HearthStatsIdForUploading;
await HearthStatsAPI.DeleteDeckAsync(first);
await Task.Delay(1000);
//reset everything
foreach(var version in deck.VersionsIncludingSelf.Select(deck.GetVersion))
{
version.ResetHearthstatsIds();
foreach(var game in version.DeckStats.Games)
{
game.HearthStatsDeckId = null;
game.HearthStatsDeckVersionId = null;
game.HearthStatsId = null;
}
}
}
var result = await HearthStatsAPI.PostDeckAsync(first, deck);
if(!result.Success && result.Retry)
{
await Task.Delay(RetryDelay);
Log.Info("try #2 to upload deck " + deck);
result = await HearthStatsAPI.PostDeckAsync(first, deck);
}
if(result.Success)
{
var versions =
deck.VersionsIncludingSelf.Where(v => v != new SerializableVersion(1, 0))
.Select(deck.GetVersion)
.Where(d => d != null && !d.HasHearthStatsDeckVersionId)
.ToList();
if(versions.Any())
{
foreach(var v in versions)
{
await Task.Delay(VersionDelay);
await UploadVersionAsync(v, first.HearthStatsIdForUploading, false);
}
deck.HearthStatsId = first.HearthStatsId;
first.HearthStatsId = "";
first.HearthStatsIdForUploading = deck.HearthStatsId;
}
if(saveFilesAfter)
DeckList.Save();
if(background)
RemoveBackgroundActivity();
Log.Info("success uploading deck " + deck);
return PostResult.WasSuccess;
}
if(background)
RemoveBackgroundActivity();
return PostResult.Failed;
}