Beispiel #1
0
        private void DeserializeMatchData()
        {
            //Retrieving old matches
            if (File.Exists(_accountId + MATCHLISTTAG + DATAENDING))
            {
                FileStream datFileStream = new FileStream(_accountId + MATCHLISTTAG + DATAENDING, FileMode.Open, FileAccess.Read);
                var        tempMatchList = Serializer.Deserialize <CMsgGCCStrike15_v2_MatchList>(datFileStream);
                datFileStream.Close();

                mainMatchList = tempMatchList;
            }
        }
Beispiel #2
0
        public async Task <Dictionary <string, string> > GetDemoListUrl()
        {
            Dictionary <string, string> demoUrlList = new Dictionary <string, string>();

            string filePath = AppSettings.GetMatchListDataFilePath();

            if (File.Exists(filePath))
            {
                using (FileStream file = File.OpenRead(filePath))
                {
                    try
                    {
                        CMsgGCCStrike15_v2_MatchList matchList = Serializer.Deserialize <CMsgGCCStrike15_v2_MatchList>(file);
                        foreach (CDataGCCStrike15_v2_MatchInfo matchInfo in matchList.matches)
                        {
                            // old definition
                            if (matchInfo.roundstats_legacy != null)
                            {
                                CMsgGCCStrike15_v2_MatchmakingServerRoundStats roundStats = matchInfo.roundstats_legacy;
                                await ProcessRoundStats(matchInfo, roundStats, demoUrlList);
                            }
                            else
                            {
                                // new definition
                                List <CMsgGCCStrike15_v2_MatchmakingServerRoundStats> roundStatsList = matchInfo.roundstatsall;
                                foreach (CMsgGCCStrike15_v2_MatchmakingServerRoundStats roundStats in roundStatsList)
                                {
                                    await ProcessRoundStats(matchInfo, roundStats, demoUrlList);
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Logger.Instance.Log(e);
                    }
                }
            }

            return(demoUrlList);
        }
Beispiel #3
0
        //Parses The Data from MatchList to the UI Model
        public void ParseMatchData(CMsgGCCStrike15_v2_MatchList matchlist, long accountId)
        {
            for (int i = matchlist.matches.Count - 1; i >= 0; i--)
            {
                try
                {
                    //Creating new MatchData
                    MatchData matchData = new MatchData();
                    //Date
                    matchData.Date = TimeHelper.UnixTimeStampInSecondsToDateTime(matchlist.matches[i].matchtime).ToLocalTime(); //.ToString("yyyy-MM-dd hh:mm");
                    //Finding the Position of our own entries
                    int j = 0;
                    for (; j < matchlist.matches[i].roundstats.reservation.account_ids.Count; j++)
                    {
                        if (matchlist.matches[i].roundstats.reservation.account_ids[j] == (uint)accountId)
                        {
                            break;
                        }
                    }
                    //If the users AccountId is not in the Game, return
                    //TODO: Figure out how this can happen
                    if (j == 10)
                    {
                        continue;
                    }

                    //Kills, Assists, Deaths, MVP, Score, KD, Demo
                    matchData.Kills   = matchlist.matches[i].roundstats.kills[j];
                    matchData.Assists = matchlist.matches[i].roundstats.assists[j];
                    matchData.Deaths  = matchlist.matches[i].roundstats.deaths[j];
                    matchData.MVPs    = matchlist.matches[i].roundstats.mvps[j];
                    matchData.Score   = matchlist.matches[i].roundstats.scores[j];

                    if (matchData.Kills != 0 && matchData.Deaths != 0)
                    {
                        matchData.KD = ((double)((int)(((double)matchData.Kills / matchData.Deaths) * 100)) / 100);
                    }
                    else
                    {
                        matchData.KD = 0;
                    }

                    matchData.Demo = matchlist.matches[i].roundstats.map; //new DemoButtonUserControl(matchlist.matches[i].roundstats.Map);

                    //Getting DemoComment
                    if (_additionalMatchData.ContainsComment(matchData.Demo))
                    {
                        matchData.DemoComment = _additionalMatchData.GetComment(matchData.Demo);
                    }

                    //Calculating if we won the match
                    if (j < matchlist.matches[i].roundstats.reservation.account_ids.Count / 2)
                    {
                        //Overall Score, ex. 16:13
                        matchData.Result = matchlist.matches[i].roundstats.team_scores[0].ToString() + ":" + matchlist.matches[i].roundstats.team_scores[1].ToString();
                        matchData.Won    = (matchlist.matches[i].roundstats.team_scores[0] > matchlist.matches[i].roundstats.team_scores[1]);
                    }
                    else
                    {
                        //Overall Score, ex. 16:13
                        matchData.Result = matchlist.matches[i].roundstats.team_scores[1].ToString() + ":" + matchlist.matches[i].roundstats.team_scores[0].ToString();
                        matchData.Won    = (matchlist.matches[i].roundstats.team_scores[1] > matchlist.matches[i].roundstats.team_scores[0]);
                    }

                    //Calculating if we downloaded the Demo
                    UpdateDownloadedList();

                    //adding to the MainList of MatchData
                    matchDataList.Add(matchData);
                }
                catch (Exception e)
                {
                    ConsoleManager.Show();
                    Console.Write(e.Message);
                }
            }
        }