-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathArenaTrial.cs
More file actions
49 lines (40 loc) · 1.78 KB
/
Copy pathArenaTrial.cs
File metadata and controls
49 lines (40 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System.Threading.Tasks;
using HearthMirror.Enums;
using Hearthstone_Deck_Tracker.Hearthstone;
using Hearthstone_Deck_Tracker.Utility;
using HSReplay.Responses;
namespace Hearthstone_Deck_Tracker.HsReplay;
public static class ArenaTrial
{
static ArenaTrial()
{
Watchers.ArenaStateWatcher.OnClientStateChanged += (state) =>
{
if(state.ClientState is not (ArenaClientStateType.None or ArenaClientStateType.Normal_Landing or ArenaClientStateType.Underground_Landing))
Clear();
};
}
private static ArenaTrialStatus? _status;
public static (int StarterTrialsRemaining, int RecurringTrialsRemaining)? RemainingTrials => _status != null ? (_status.StarterTrialsRemaining, _status.RecurringTrialsRemaining) : null;
public static int? MaxRecurringTrials => _status?.MaxRecurringTrials;
public static int? HoursUntilReset => _status?.HoursUntilReset;
internal static string FormatDiagnostics(int starterTrials, int recurringTrials, int? hoursUntilReset)
=> $"starter={starterTrials}, recurring={recurringTrials}, total={starterTrials + recurringTrials}, "
+ $"resetInHours={hoursUntilReset?.ToString() ?? "n/a"}";
public static string? TimeRemaining => _status?.HoursUntilReset == null ? null
: string.Format(LocUtil.Get("BattlegroundsPreLobby_Trial_ResetTimeRemaining_DaysHours"), _status.HoursUntilReset / 24, _status.HoursUntilReset % 24);
public static bool IsDeckResumable(long deckId) => _status?.ResumableDeckIds.Contains(deckId) ?? false;
public static async Task Update(ulong accountHi, ulong accountLo)
{
_status ??= await ApiWrapper.GetArenaTrialStatus(accountHi, accountLo);
}
public static async Task EnsureLoaded(ulong accountHi, ulong accountLo)
{
if(_status == null)
await Update(accountHi, accountLo);
}
public static void Clear()
{
_status = null;
}
}