public static async Task <GetInventoryResponse> GetCachedInventory(PokeRoadieClient _client, bool request = false) { var now = DateTime.UtcNow; var ss = new SemaphoreSlim(10); if (!IsDirty && _lastRefresh > now && request == false) { return(_cachedInventory); } await ss.WaitAsync(); try { _lastRefresh = now.AddSeconds(30); //_cachedInventory = await Context.Client.GetInventory(); try { _cachedInventory = await _client.Inventory.GetInventory(); IsDirty = false; } catch { // ignored } return(_cachedInventory); } finally { ss.Release(); } }
public Context(PokeRoadieSettings settings) { Settings = settings; Directories = new Directories(); Utility = new Utility(this); Session = new Session(this); ApiFailureStrategy = new ApiFailureStrategy(this); Client = new PokeRoadieClient(this); Inventory = new PokeRoadieInventory(this); Statistics = new Statistics(this); Navigation = new Navigation(this); Logic = new PokeRoadieLogic(this); }
public async void UpdateConsoleTitle(PokeRoadieClient _client, PokeRoadieInventory _inventory) { if (nextTitleUpdate > DateTime.Now) { return; } nextTitleUpdate.AddSeconds(1); //appears to give incorrect info? var pokes = await _inventory.GetPokemons(); TotalPokesInBag = pokes.Count(); var inventory = await PokeRoadieInventory.GetCachedInventory(_client); if (inventory.InventoryDelta != null) { TotalPokesInPokedex = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.PokedexEntry).Where(x => x != null && x.TimesCaptured >= 1).OrderBy(k => k.PokemonId).ToArray().Length; CurrentLevelInfos = await _getcurrentLevelInfos(); } Console.Title = ToString(); }
public async Task <LevelUpRewardsResponse> Execute(PokeRoadieClient ctx) { var Result = await GetLevelUpRewards(LevelForRewards); return(Result); }
public string GetUsername(PokeRoadieClient client, GetPlayerResponse profile) { return(PlayerName = client.Settings.AuthType == AuthType.Ptc ? client.Settings.Username : (profile == null || profile.PlayerData == null ? client.Settings.Username : profile.PlayerData.Username)); }
public Navigation(PokeRoadieClient client) { _client = client; }
public PokeRoadieInventory(PokeRoadieClient client, PokeRoadieSettings settings) { _client = client; _settings = settings; }