public void LoadHTML() { DSfilter dsfil = new DSfilter(MW); List <dsreplay> filtered_replays = new List <dsreplay>(); filtered_replays = dsfil.Filter(MW.replays); dsradar myradar = new dsradar(); //string myhtml = myradar.GetHTML("Swann", filtered_replays); //Console.WriteLine(myhtml); //wb_chart.NavigateToString(myhtml); }
public List <dsunits_grid> Sum(string interest, string vs, string gametime) { string sum = ""; DSfilter dsfil = new DSfilter(MW); List <dsreplay> filtered_replays = new List <dsreplay>(); filtered_replays = dsfil.Filter(MW.replays); List <dsreplay> replay_sorted = new List <dsreplay>(); replay_sorted = filtered_replays.Where(x => x.RACES.Contains(interest)).OrderBy(o => o.GAMETIME).ToList(); Dictionary <string, double> unit_sum = new Dictionary <string, double>(); int mingametime = 0; if (gametime == "5min") { mingametime = MIN5; } if (gametime == "10min") { mingametime = MIN10; } if (gametime == "15min") { mingametime = MIN15; } int i = 0; int wins = 0; double duration = 0; foreach (dsreplay rep in replay_sorted) { if (mingametime > 0 && rep.DURATION < mingametime) { continue; } //if (UNITLIST.ContainsKey(rep.REPLAY)) //{ foreach (dsplayer pl in rep.PLAYERS) { if (pl.RACE == interest) { if ((MW.cb_player.IsChecked == true && MW.player_list.Contains(pl.NAME)) || MW.cb_player.IsChecked == false) { /** * List<dsunits_player> pl_units = UNITLIST[rep.REPLAY].Where(x => int.Parse(x.PLAYERID) == pl.POS).ToList(); * if (pl_units.Count > 0) * { * if (pl_units.ElementAt(0).UNITS.ContainsKey(gametime)) * { **/ if (pl.UNITS.ContainsKey(gametime)) { //List<KeyValuePair<string, int>> units = pl_units.ElementAt(0).UNITS[gametime]; Dictionary <string, int> units = new Dictionary <string, int>(pl.UNITS[gametime]); if (units.Count > 0) { if (vs != null) { if (rep.GetOpp(pl.REALPOS).RACE != vs) { continue; } } i++; if (pl.TEAM == rep.WINNER) { wins++; } duration += rep.DURATION; foreach (KeyValuePair <string, int> unit in units) { if (unit_sum.ContainsKey(unit.Key)) { unit_sum[unit.Key] += unit.Value; } else { unit_sum[unit.Key] = unit.Value; } } } //} } } } } //} } double wr = 0; if (i > 0) { wr = (double)wins * 100 / (double)i; wr = Math.Round(wr, 2); duration /= i; duration /= 22.4; duration = Math.Round(duration, 2); } TimeSpan t = TimeSpan.FromSeconds(duration); INFO = new List <dsunits_info>(); WR = wr; INFO.Add(new dsunits_info("winrate", wr.ToString())); GAMES = i; INFO.Add(new dsunits_info("games", i.ToString())); DURATION = t.Minutes + ":" + t.Seconds.ToString("D2") + " min"; INFO.Add(new dsunits_info("duration", DURATION)); GAMETIME = "startdate: " + MW.otf_startdate.SelectedDate.Value.ToString("yyyyMMdd") + "; enddate: " + MW.otf_enddate.SelectedDate.Value.ToString("yyyyMMdd"); INFO.Add(new dsunits_info("gametime", GAMETIME)); char average = '\u2300'; sum = "cmdr: " + interest + "; gametime: " + gametime + "; games: " + i.ToString(); if (vs != null) { sum += "; vs: " + vs; } sum += Environment.NewLine; sum += "startdate: " + MW.otf_startdate.SelectedDate.Value.ToString("yyyyMMdd") + "; enddate: " + MW.otf_enddate.SelectedDate.Value.ToString("yyyyMMdd") + Environment.NewLine; sum += "winrate: " + wr + "%; " + average.ToString() + " duration: " + t.Minutes + ":" + t.Seconds.ToString("D2") + " min" + Environment.NewLine; sum += "-----------------------------------------------------" + Environment.NewLine; MW.Dispatcher.Invoke(() => { MW.tb_build.Text = sum; }); var list = unit_sum.Keys.ToList(); list.Sort(); List <dsunits_grid> list_grid = new List <dsunits_grid>(); foreach (string unit in list) { if (unit.StartsWith("Hybrid")) { continue; } if (unit.StartsWith("MercCamp")) { continue; } if (i > 0) { double unit_count = 0; unit_count = (double)unit_sum[unit] / (double)i; unit_count = Math.Round(unit_count, 2); if (MW.cb_build_sum.IsChecked == true) { unit_count = unit_sum[unit]; } //sum += unit + " => " + unit_count.ToString() + Environment.NewLine; dsunits_grid dsgrid = new dsunits_grid(); dsgrid.UNIT = unit; dsgrid.COUNT = unit_count; list_grid.Add(dsgrid); } } MW.dg_build.ItemsSource = list_grid; MW.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.ApplicationIdle, new Action(ProcessRows_units)); return(list_grid); }