Beispiel #1
0
        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();
            }
        }
Beispiel #2
0
 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);
 }
Beispiel #3
0
        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();
        }
Beispiel #4
0
        public async Task <LevelUpRewardsResponse> Execute(PokeRoadieClient ctx)
        {
            var Result = await GetLevelUpRewards(LevelForRewards);

            return(Result);
        }
Beispiel #5
0
 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));
 }
Beispiel #6
0
 public Navigation(PokeRoadieClient client)
 {
     _client = client;
 }
 public PokeRoadieInventory(PokeRoadieClient client, PokeRoadieSettings settings)
 {
     _client   = client;
     _settings = settings;
 }