public LeagueAPI_DataCollector(string apiKey, LeagueAPISettingsFile leagueAPISettingsFile, string gameVersion, int queue)
 {
     LeagueAPIClient = new LeagueAPIClient(apiKey);
     SetUpNonAPIClientSettings(leagueAPISettingsFile, gameVersion, queue);
 }
 public LeagueAPI_DataCollector(LeagueAPIClient leagueAPIClient, LeagueAPISettingsFile leagueAPISettingsFile, string gameVersionToLookFor, int queueToLookFor)
 {
     LeagueAPIClient = leagueAPIClient;
     SetUpNonAPIClientSettings(leagueAPISettingsFile, gameVersionToLookFor, queueToLookFor);
 }
        /// <summary>Gets matches for a player account.</summary>
        /// <remarks>Run in a loop in <see cref="CollectMatchesData(int)"/>. Boolean result determines if we want to stop or continue collecting data.</remarks>
        /// <returns>Returns true if data collection is to be stopped, false if it is to continue.</returns>
        private async Task <bool> GetMatches(string playerAccountId)
        {
            int          initialMatchesCount = Matches.Count;
            MatchlistDto matchlist           = await LeagueAPIClient.GetMatchlist(playerAccountId);

            //Stop scanning this account if it has no history (but don't stop collecting from other accounts).
            if (matchlist.matches == null)
            {
                return(false);
            }

            HashSet <ParticipantIdentityDto> participantIdentities = new HashSet <ParticipantIdentityDto>();

            foreach (MatchReferenceDto matchRef in matchlist.matches)
            {
                if (matchRef.queue != QueueToLookFor || ScannedGameIds.Contains(matchRef.gameId))
                {
                    continue;
                }
                MatchDto match = await LeagueAPIClient.GetMatch(matchRef.gameId);

                ScannedGameIds.Add(matchRef.gameId);
                if (match == null || match.gameId == 0)
                {
                    continue;
                }
                int shouldScanContinueDependingOnGameVersion = ShouldScanContinueDependingOnGameVersion(match.gameVersion);
                if (shouldScanContinueDependingOnGameVersion == 2)
                {
                    break;
                }
                if (shouldScanContinueDependingOnGameVersion == 1)
                {
                    continue;
                }
                Matches.Add(match);
                Debug.WriteLine(Matches.Count);
                foreach (ParticipantIdentityDto identity in match.participantIdentities)
                {
                    participantIdentities.Add(identity);
                }
            }

            if (Matches.Count > initialMatchesCount)
            {
                //Record progress
                LeagueAPI_Variables apiVars = await ReadLocalVarsFile();

                string currentProgress = GetProgressMessage();
                apiVars.CurrentProgress = currentProgress;
                await UpdateLocalVarsFile(apiVars);
            }

            foreach (ParticipantIdentityDto participantIdentity in participantIdentities)
            {
                string playerAccount = participantIdentity.player.accountId;
                if (AccountsAddedForScanning.Contains(playerAccount))
                {
                    continue;
                }
                AccountsToScan.Enqueue(playerAccount);
                AccountsAddedForScanning.Add(playerAccount);
            }

            return(await ReadVarsFileAndDetermineIfDataCollectionShouldStop());
        }