Exemple #1
0
        public static async Task <PubgPlayerSeason> GetPlayerSeason(PubgPlayer player, PubgRegion region, PubgSeason season)
        {
            var cacheKey = new PlayerSeasonKey(player.Id, region, season.Id);

            if (cachedPlayerSeasons.ContainsKey(cacheKey) && DateTime.Now - cachedPlayerSeasons[cacheKey].Item2 < cacheTimeout)
            {
                System.Console.WriteLine("Cache hit for player season {0}", player.Name);
                return(cachedPlayerSeasons[cacheKey].Item1);
            }

            var pubgPlayerSeason = await _playerService.GetPlayerSeasonAsync(region, player.Id, season.Id);

            cachedPlayerSeasons[cacheKey] = new Tuple <PubgPlayerSeason, DateTime>(pubgPlayerSeason, DateTime.Now);
            return(pubgPlayerSeason);
        }
        public async Task GetPlayerStats()
        {
            if (Player.CurrentSeasionLastUpdate == null || Player.CurrentSeasionLastUpdate.Value <= DateTime.Now.AddMinutes(-Config.PlayerRefreshTime))
            {
                var playerSeason = await playerService.GetPlayerSeasonAsync(PubgPlatform.Steam, Player.Id, SeasonStats.CurrentSeasonID, Config.PubgToken);

                Player.SoloStats = new SeasonStats();
                Player.SoloStats.Clone(playerSeason.GameModeStats.SoloFPP);
                Player.DuoStats = new SeasonStats();
                Player.DuoStats.Clone(playerSeason.GameModeStats.DuoFPP);
                Player.SquadStats = new SeasonStats();
                Player.SquadStats.Clone(playerSeason.GameModeStats.SquadFPP);
                Player.CurrentSeasionLastUpdate = DateTime.Now;
            }
        }