/// <summary>
        /// Get seasonal stats for the provided <see cref="UbisoftAccount"/>s
        /// </summary>
        /// <param name="client">The <see cref="Dragon6Client"/> to use</param>
        /// <param name="accounts">The <see cref="UbisoftAccount"/>s to get stats for</param>
        /// <param name="seasonId">The season id. Defaults to the current season</param>
        /// <param name="board">The leaderboard to get rankings for</param>
        /// <param name="region">The region to get stats for. Seasons after ~17 do not need to set this</param>
        /// <param name="token">Optional cancellation token</param>
        public static Task <SeasonalStatsResponse> GetSeasonalStatsAsync(this Dragon6Client client, IEnumerable <UbisoftAccount> accounts, int seasonId = -1, BoardType board = BoardType.Ranked, Region region = Region.EMEA, CancellationToken token = default)
        {
            var platformRequests = accounts.GroupBy(x => x.Platform).Select(x =>
            {
                var request = new SeasonalStatsRequest(x, board, seasonId, region);
                return(client.PerformAsync <JObject>(request, token));
            });

            return(Task.WhenAll(platformRequests).ContinueWith(t =>
            {
                var json = t.Result.Aggregate((a, b) =>
                {
                    a.Merge(b);
                    return a;
                });

                return json.ToObject <SeasonalStatsResponse>();
            }, TaskContinuationOptions.OnlyOnRanToCompletion));
        }
Example #2
0
 /// <summary>
 /// Gets the <see cref="LegacyWeaponStats"/> for the <see cref="UbisoftAccount"/>s provided
 /// </summary>
 /// <param name="client">The <see cref="Dragon6Client"/> to use</param>
 /// <param name="accounts">The <see cref="UbisoftAccount"/>s to get stats for</param>
 /// <param name="token">Optional cancellation token</param>
 /// <returns><see cref="ILookup{TKey,TElement}"/> of <see cref="LegacyWeaponStats"/> for the provided <see cref="UbisoftAccount"/></returns>
 public static Task <ILookup <string, LegacyWeaponStats> > GetLegacyWeaponStatsAsync(this Dragon6Client client, IEnumerable <UbisoftAccount> accounts, CancellationToken token = default)
 {
     return(GetLegacyStatsAsync(client, accounts, a => new LegacyStatsRequest(a, LegacyStatTypes.Weapons), LegacyStatsDeserializer.DeserializeWeaponStats, token));
 }
Example #3
0
 /// <summary>
 /// Gets the <see cref="LegacyWeaponStats"/> for the <see cref="UbisoftAccount"/> provided
 /// </summary>
 /// <param name="client">The <see cref="Dragon6Client"/> to use</param>
 /// <param name="account">The <see cref="UbisoftAccount"/> to get stats for</param>
 /// <param name="token">Optional cancellation token</param>
 /// <returns><see cref="IEnumerable{T}"/> of <see cref="LegacyWeaponStats"/> for the provided <see cref="UbisoftAccount"/></returns>
 public static Task <IEnumerable <LegacyWeaponStats> > GetLegacyWeaponStatsAsync(this Dragon6Client client, UbisoftAccount account, CancellationToken token = default)
 {
     return(GetLegacyWeaponStatsAsync(client, account.Yield(), token).ContinueWith(t => t.Result.For(account), TaskContinuationOptions.OnlyOnRanToCompletion));
 }
Example #4
0
        /// <summary>
        /// Gets the <see cref="LegacyStats"/> for the <see cref="UbisoftAccount"/>s provided
        /// </summary>
        /// <param name="client">The <see cref="Dragon6Client"/> to use</param>
        /// <param name="accounts">The <see cref="UbisoftAccount"/>s to get stats for</param>
        /// <param name="token">Optional cancellation token</param>
        /// <returns><see cref="IReadOnlyDictionary{TKey,TValue}"/> mapping the user profile id to the corresponding <see cref="LegacyStats"/></returns>
        public static Task <IReadOnlyDictionary <string, LegacyStats> > GetLegacyStatsAsync(this Dragon6Client client, IEnumerable <UbisoftAccount> accounts, CancellationToken token = default)
        {
            const LegacyStatTypes generalStats = LegacyStatTypes.All & ~(LegacyStatTypes.Operators | LegacyStatTypes.Weapons);

            return(GetLegacyStatsAsync(client, accounts, a => new LegacyStatsRequest(a, generalStats), LegacyStatsDeserializer.DeserializeGeneralStats, token));
        }
Example #5
0
 /// <summary>
 /// Gets the <see cref="LegacyLevelStats"/> for the <see cref="UbisoftAccount"/>s provided
 /// </summary>
 /// <param name="client">The <see cref="Dragon6Client"/> to use</param>
 /// <param name="accounts">The <see cref="UbisoftAccount"/>s to get stats for</param>
 /// <param name="token">Optional cancellation token</param>
 /// <returns><see cref="IReadOnlyDictionary{TKey,TValue}"/> of <see cref="LegacyWeaponStats"/> for the provided <see cref="UbisoftAccount"/></returns>
 public static Task <IReadOnlyDictionary <string, LegacyLevelStats> > GetLegacyLevelAsync(this Dragon6Client client, IEnumerable <UbisoftAccount> accounts, CancellationToken token = default)
 {
     return(GetLegacyStatsAsync(client, accounts, a => new PlayerLevelStatsRequest(a), LegacyStatsDeserializer.DeserializePlayerLevelStats, token));
 }
Example #6
0
        public static Task <ModernModeStatsContainer <WeaponSlot> > GetModernWeaponStatsAsync(this Dragon6Client client, UbisoftAccount account, PlaylistType playlistType = PlaylistType.All, OperatorType operatorType = OperatorType.Independent, DateTimeOffset?startDate = null, DateTimeOffset?endDate = null)
        {
            var request = new ModernWeaponStatsRequest(account)
            {
                Playlist     = playlistType,
                OperatorType = operatorType
            };

            ValueUtils.ApplyValue(startDate, s => request.StartDate = s);
            ValueUtils.ApplyValue(endDate, e => request.EndDate     = e);

            return(client.PerformAsync <JObject>(request)
                   .ContinueWith(t => t.Result.ProcessData <WeaponSlot>(request), TaskContinuationOptions.OnlyOnRanToCompletion));
        }
        /// <summary>
        /// Get seasonal stats for the provided <see cref="UbisoftAccount"/>
        /// </summary>
        /// <param name="client">The <see cref="Dragon6Client"/> to use</param>
        /// <param name="account">The <see cref="UbisoftAccount"/> to get stats for</param>
        /// <param name="seasonId">The season id. Defaults to the current season</param>
        /// <param name="board">The leaderboard to get rankings for</param>
        /// <param name="region">The region to get stats for. Seasons after ~17 do not need to set this</param>
        /// <param name="token">Optional cancellation token</param>
        public static Task <SeasonalStats> GetSeasonalStatsAsync(this Dragon6Client client, UbisoftAccount account, int seasonId = -1, BoardType board = BoardType.Ranked, Region region = Region.EMEA, CancellationToken token = default)
        {
            var request = new SeasonalStatsRequest(account.Yield(), board, seasonId, region);

            return(client.PerformAsync <SeasonalStatsResponse>(request, token).ContinueWith(t => t.Result.For(account), TaskContinuationOptions.OnlyOnRanToCompletion));
        }
Example #8
0
        public static Task <ModernModeStatsContainer <IEnumerable <ModernSeasonStats> > > GetModernSeasonStatsAsync(this Dragon6Client client, UbisoftAccount account, PlaylistType playlistType = PlaylistType.All)
        {
            var request = new ModernSeasonalStatsRequest(account)
            {
                Playlist = playlistType
            };

            return(client.PerformAsync <JObject>(request)
                   .ContinueWith(t => t.Result.ProcessData <IEnumerable <ModernSeasonStats> >(request), TaskContinuationOptions.OnlyOnRanToCompletion));
        }
        /// <summary>
        /// Retrieves the play statistics for multiple <see cref="UbisoftAccount"/>s
        /// </summary>
        /// <param name="client">The <see cref="Dragon6Client"/> to use</param>
        /// <param name="accounts">The <see cref="UbisoftAccount"/>s to get play stats for</param>
        /// <returns>A <see cref="UbisoftAccountActivity"/> for each account that owns the game</returns>
        public static Task <IReadOnlyDictionary <string, UbisoftAccountActivity> > GetAccountActivityAsync(this Dragon6Client client, IEnumerable <UbisoftAccount> accounts)
        {
            var request = new UbisoftAccountActivityRequest(accounts);

            return(client.PerformAsync <JObject>(request).ContinueWith(t => t.Result.DeserializeUbisoftAccountActivity()));
        }
        /// <summary>
        /// Retrieves the play statistics for a <see cref="UbisoftAccount"/>
        /// </summary>
        /// <param name="client">The <see cref="Dragon6Client"/> to use</param>
        /// <param name="account">The <see cref="UbisoftAccount"/> to get play stats for</param>
        /// <returns>The <see cref="UbisoftAccountActivity"/> for the account, or <c>null</c> if the user does not own the game</returns>
        public static Task <UbisoftAccountActivity> GetAccountActivityAsync(this Dragon6Client client, UbisoftAccount account)
        {
            var request = new UbisoftAccountActivityRequest(account);

            return(client.PerformAsync <JObject>(request).ContinueWith(t => t.Result.DeserializeUbisoftAccountActivity().For(account), TaskContinuationOptions.OnlyOnRanToCompletion));
        }
        /// <summary>
        /// Retrieves the public information for multiple Ubisoft Accounts
        /// </summary>
        /// <param name="client">The <see cref="Dragon6Client"/> to use</param>
        /// <param name="queries">The account identifiers to use</param>
        /// <param name="platform">The platform the identifiers are for</param>
        /// <param name="identifierType">The type of identifier the <see cref="queries"/> represent</param>
        /// <returns>The <see cref="UbisoftAccount"/> information for discovered accounts</returns>
        public static Task <IEnumerable <UbisoftAccount> > GetAccountsAsync(this Dragon6Client client, IEnumerable <string> queries, Platform platform, IdentifierType identifierType)
        {
            var request = new UbisoftAccountRequest(queries, platform, identifierType);

            return(client.PerformAsync <JObject>(request).ContinueWith(t => t.Result.DeserializeUbisoftAccounts(), TaskContinuationOptions.OnlyOnRanToCompletion));
        }
        /// <summary>
        /// Retrieves the public information for a Ubisoft Account
        /// </summary>
        /// <param name="client">The <see cref="Dragon6Client"/> to use</param>
        /// <param name="query">The account identifier</param>
        /// <param name="platform">The account's platform</param>
        /// <param name="identifierType">The type of identifier</param>
        /// <returns>The <see cref="UbisoftAccount"/> information, or null if not found</returns>
        public static Task <UbisoftAccount> GetAccountAsync(this Dragon6Client client, string query, Platform platform, IdentifierType identifierType)
        {
            var request = new UbisoftAccountRequest(query, platform, identifierType);

            return(client.PerformAsync <JObject>(request).ContinueWith(t => t.Result.DeserializeUbisoftAccounts().SingleOrDefault(), TaskContinuationOptions.OnlyOnRanToCompletion));
        }