protected override void EmitInternal(TextWriter tw, DataStore data) { var maps = from g in data.Records.GroupBy((g) => g.Map) orderby g.Key select g.Key; var players = (data.Records.Select((r) => new { map = r.Map, P1 = r.Winner.Team, P2 = r.Loser.Team, Win = true })).Concat(data.Records.Select((r) => new { map = r.Map, P1 = r.Loser.Team, P2 = r.Winner.Team, Win = false })); var table = from tm in (from g in players.GroupBy((p) => p.P1) from map in maps select new { team = g.Key, map, wl = WL.Fill(g, (p) => p.Win, (p) => p.map == map) }).ToLookup((p) => p.team) orderby tm.Key select new Bag("team", tm.Key).MergeGrouping(tm, (x) => x.map, (x) => x.wl.ToString()); var template = new TeamMapStatistics(); template.Maps = maps; template.Rows = table; tw.Write(template.TransformText()); }
protected override void EmitInternal(TextWriter tw, DataStore data) { var matches = (data.Matches.Select((m) => new { Team = m.TeamWinner, Win = true })).Concat(data.Matches.Select((m) => new { Team = m.TeamLoser, Win = false })); var players = (data.Records.Select((r) => new { Player = r.Winner, Win = true })).Concat(data.Records.Select((r) => new { Player = r.Loser, Win = false })); var table = from g in matches.GroupBy((m) => m.Team) let allKills = (from m in data.Matches where m.Games.Count > 0 && m.TeamWinner == g.Key && m.Games.All((s) => s.Winner.Equals(m.Games.Last().Winner) || s.Winner.Team != g.Key) select m).Count() let matchCount = WL.Fill(g, (p) => p.Win) let games = (from r in data.Records where r.Winner.Team == g.Key || r.Loser.Team == g.Key select r.Winner.Team == g.Key) let gameCount = WL.Fill(games, (p) => p) let diff = gameCount.Wins - gameCount.Losses orderby matchCount.Wins descending, matchCount.Losses, diff descending select new Bag( "team", g.Key, "allkills", "{{AllKillIcon}}".Repeat(allKills), "matchCount", matchCount.Total.ToString(), "matches", matchCount.ToString(), "gameCount", gameCount.Total.ToString(), "games", gameCount.ToString(), "gameDiff", diff.ToStringWithSign(true) ); var template = new TeamStatistics(); template.IncludeAllKills = this.IncludeAllKillsColumn; template.Rows = table.Index((a, b) => false); tw.Write(template.TransformText()); }
internal static Bag TotalWinLossPercentage(this Bag bag, string id, WL wl) { bag[id + "total"] = wl.Total != 0 ? wl.Total.ToString() : "-"; bag[id + "win"] = wl.Total != 0 ? wl.Wins.ToString() : "-"; bag[id + "loss"] = wl.Total != 0 ? wl.Losses.ToString() : "-"; bag[id + "pc"] = wl.Total != 0 ? wl.Percentage.ToString("0") + "%" : "-"; return(bag); }
protected override void EmitInternal(TextWriter tw, DataStore data) { IEnumerable <Record> games = data.Records; if (this.Ace) { games = games.Where((r) => r.IsAce); } var players = (games.Select((r) => new { P1 = r.Winner, P2 = r.Loser, Win = true })).Concat(games.Select((r) => new { P1 = r.Loser, P2 = r.Winner, Win = false })); var table = from g in players.GroupBy((p) => p.P1.Team) let wl = WL.Fill(g, (p) => p.Win) let T = WL.Fill(g, (p) => p.Win, (p) => p.P1.Race == Race.Terran) let Z = WL.Fill(g, (p) => p.Win, (p) => p.P1.Race == Race.Zerg) let P = WL.Fill(g, (p) => p.Win, (p) => p.P1.Race == Race.Protoss) let vT = WL.Fill(g, (p) => p.Win, (p) => p.P2.Race == Race.Terran) let vZ = WL.Fill(g, (p) => p.Win, (p) => p.P2.Race == Race.Zerg) let vP = WL.Fill(g, (p) => p.Win, (p) => p.P2.Race == Race.Protoss) orderby wl.Percentage descending, g.Key select new { g.Key, wl, T, Z, P, vT, vZ, vP }; var ov = new { T = WL.Fill(players, (p) => p.Win, (p) => p.P1.Race == Race.Terran), Z = WL.Fill(players, (p) => p.Win, (p) => p.P1.Race == Race.Zerg), P = WL.Fill(players, (p) => p.Win, (p) => p.P1.Race == Race.Protoss), vT = WL.Fill(players, (p) => p.Win, (p) => p.P2.Race == Race.Terran), vZ = WL.Fill(players, (p) => p.Win, (p) => p.P2.Race == Race.Zerg), vP = WL.Fill(players, (p) => p.Win, (p) => p.P2.Race == Race.Protoss), }; var template = new TeamRacialStatistics(); template.Params = new Bag() .TotalWinLossPercentage("T", ov.T) .TotalWinLossPercentage("Z", ov.Z) .TotalWinLossPercentage("P", ov.P) .TotalWinLossPercentage("vT", ov.vT) .TotalWinLossPercentage("vZ", ov.vZ) .TotalWinLossPercentage("vP", ov.vP); template.Rows = table.Index((a, b) => a.wl == b.wl).Select((r) => new Bag( "index", r.Index.ToString(), "team", r.Object.Key) .TotalWinLossPercentage("T", r.Object.T) .TotalWinLossPercentage("Z", r.Object.Z) .TotalWinLossPercentage("P", r.Object.P) .TotalWinLossPercentage("vT", r.Object.vT) .TotalWinLossPercentage("vZ", r.Object.vZ) .TotalWinLossPercentage("vP", r.Object.vP) ); template.IncludeRaces = this.IncludeRacesPlayedColumns; template.IncludeVs = this.IncludeRacesAgainstColumns; tw.Write(template.TransformText()); }
protected override void EmitInternal(TextWriter tw, DataStore data) { IEnumerable <Record> games = data.Records; var playerGames = (games.Select((r) => new { Player = r.Winner, r.Loser.Race, Win = true })).Concat(games.Select((r) => new { Player = r.Loser, r.Winner.Race, Win = false })); var playerStats = (from g in playerGames.GroupBy((p) => p.Player) let wl = WL.Fill(g, (p) => p.Win) let vT = WL.Fill(g, (p) => p.Win, (p) => p.Race == Race.Terran) let vZ = WL.Fill(g, (p) => p.Win, (p) => p.Race == Race.Zerg) let vP = WL.Fill(g, (p) => p.Win, (p) => p.Race == Race.Protoss) orderby wl descending, g.Key.Id select new { g.Key, wl, vT, vZ, vP }).ToDictionary((x) => x.Key.Identifier, (x) => new { x.Key, x.wl, x.vT, x.vZ, x.vP }); var rows = (from pp in data.PlayerPlacements where pp.Key != "TBD" let stats = playerStats.GetValueOrDefault(pp.Key, null) let playerInfo = (stats != null) ? stats.Key : data.PlayerInfoMap.GetValueOrDefault(pp.Key, Player.Empty) let placement = data.PlayerPlacements.GetValueOrDefault(pp.Key, new Placement()) let pointsort = placement.Sort + ((placement.PlacementBg == "active") ? 1 : 0) orderby pointsort descending, ((stats != null) ? stats.wl : WL.Zero).Percentage descending, playerInfo.Identifier select new { pointsort = pointsort, bag = new Bag( "ppKey", pp.Key, "flag", data.PlayerInfoMap.GetValueOrDefault(pp.Key, Player.Empty).Flag, "race", playerInfo.Race.ToString().MaxSubstring(1), "player", playerInfo.IdWithLinkIfNeeded, "team", data.PlayerInfoMap.GetValueOrDefault(pp.Key, Player.Empty).Team, "placement", data.PlayerPlacements.GetValueOrDefault(pp.Key, new Placement()).ToString(), "wl", ((stats != null) ? stats.wl : WL.Zero).ToString(), "vT", ((stats != null) ? stats.vT : WL.Zero).ToString(), "vZ", ((stats != null) ? stats.vZ : WL.Zero).ToString(), "vP", ((stats != null) ? stats.vP : WL.Zero).ToString() ) }).Index((a, b) => a.pointsort == b.pointsort).Select((r) => new Indexing <Bag>(r.Index, r.Object.bag)); var template = new IndividualPlayerStatistics(); template.IncludePointsColumn = this.IncludePointsColumn; template.IncludeTeamColumn = this.IncludeTeamColumn; template.Rows = rows; tw.Write(template.TransformText()); }
internal static WL CalcWinRaceStat(this IEnumerable <P1P2Win> g, Race r1, Race r2) { return(WL.Fill(g, (p) => p.Win, (p) => p.P1.Race == r1 && p.P2.Race == r2)); }
protected override void EmitInternal(TextWriter tw, DataStore data) { IEnumerable <Record> games = data.Records; if (this.Ace) { games = games.Where((r) => r.IsAce); } var players = (games.Select((r) => new { Player = r.Winner, r.Loser.Race, Win = true })).Concat(games.Select((r) => new { Player = r.Loser, r.Winner.Race, Win = false })); var table = from g in players.GroupBy((p) => p.Player) let wl = WL.Fill(g, (p) => p.Win) let vT = WL.Fill(g, (p) => p.Win, (p) => p.Race == Race.Terran) let vZ = WL.Fill(g, (p) => p.Win, (p) => p.Race == Race.Zerg) let vP = WL.Fill(g, (p) => p.Win, (p) => p.Race == Race.Protoss) let allKills = (from m in data.Matches where m.Games.Count > 0 && m.TeamWinner == g.Key.Team && m.Games.All((s) => s.Winner.Equals(g.Key) || s.Winner.Team != g.Key.Team) select m).Count() orderby wl descending, g.Key.Id select new { g.Key, allKills, wl, vT, vZ, vP }; var rows = table.Index((a, b) => a.wl == b.wl).Select((r) => new Indexing <Bag>(r.Index, new Bag( "flag", r.Object.Key.Flag ?? (data.PlayerInfoMap.GetValueOrDefault(r.Object.Key.Identifier, Player.Empty).Flag ?? ""), "race", r.Object.Key.Race.ToString().MaxSubstring(1), "player", r.Object.Key.IdWithLinkIfNeeded, "allkills", "{{AllKillIcon}}".Repeat(r.Object.allKills), "team", string.IsNullOrWhiteSpace(r.Object.Key.Team) ? data.PlayerInfoMap.GetValueOrDefault(r.Object.Key.Identifier, Player.Empty).Team : r.Object.Key.Team, "wl", r.Object.wl.ToString(), "vT", r.Object.vT.ToString(), "vZ", r.Object.vZ.ToString(), "vP", r.Object.vP.ToString() ))); var template = new PlayerStatistics(); if (!this.AlwaysShowWholeTable && table.Count() > 15) { var top10 = new PlayerStatistics(); top10.HeaderType = "top10"; top10.IncludeAllKills = this.IncludeAllKillsColumn; top10.IncludeTeamColumn = this.IncludeTeamColumn; top10.Rows = rows.TakeTop(10); tw.WriteLine(top10.TransformText()); template.HeaderType = "top10-complete"; } else { template.HeaderType = "all"; } template.IncludeAllKills = this.IncludeAllKillsColumn; template.IncludeTeamColumn = this.IncludeTeamColumn; template.Rows = rows; tw.Write(template.TransformText()); }
protected override void EmitInternal(TextWriter tw, DataStore data) { var records = data.Records.AsQueryable(); var maps = from g in records.GroupBy((g) => g.Map) orderby g.Key select g.Key; var players = (records.Select((r) => new { map = r.Map, P1 = r.Winner, P2 = r.Loser, Win = true })) .Concat(records.Select((r) => new { map = r.Map, P1 = r.Loser, P2 = r.Winner, Win = false })); var tmlookup = (from g in players.GroupBy((p) => p.P1.Identifier) from map in maps select new { id = g.Key, player = g.First().P1, map, wl = WL.Fill(g, (p) => p.Win, (p) => p.map == map) }).ToLookup((p) => p.id); var table = from tm in tmlookup orderby tm.Key let totalplayed = (from x in tm select x.wl.Total).Sum() let mostplayed = (from x in tm where x.wl.Total > 0 orderby x.wl.Total descending select new { map = "[[" + x.map + "]]", count = x.wl.Total }).Index((x, y) => x.count == y.count).TakeTop(1) let mostplayedmap = string.Join("<br />", from obj in mostplayed select obj.Object.map) let mostplayedcount = mostplayed.First().Object.count.ToString() let bestmap = (from x in tm where x.wl.Total > 0 orderby x.wl.Difference descending select new { map = "[[" + x.map + "]]", wl = x.wl, gd = x.wl.Difference }).Index((x, y) => x.gd == y.gd).TakeTop(1) let bestmapmap = string.Join("<br />", from obj in bestmap select obj.Object.map) let bestmaprecord = string.Join("<br />", from obj in bestmap select string.Format("{0}-{1}", obj.Object.wl.Wins, obj.Object.wl.Losses)) let bestmapcount = bestmap.First().Object.gd.ToStringWithSign() let worstmap = (from x in tm where x.wl.Total > 0 orderby x.wl.Difference select new { map = "[[" + x.map + "]]", wl = x.wl, gd = x.wl.Difference }).Index((x, y) => x.gd == y.gd).TakeTop(1) let worstmapmap = string.Join("<br />", from obj in worstmap select obj.Object.map) let worstmaprecord = string.Join("<br />", from obj in worstmap select string.Format("{0}-{1}", obj.Object.wl.Wins, obj.Object.wl.Losses)) let worstmapcount = worstmap.First().Object.gd.ToStringWithSign() let playerInfo = tm.First().player //let playerInfo = data.PlayerInfoMap.GetValueOrDefault(tm.Key, Player.Empty) select new Bag( "flag", playerInfo.Flag, "race", playerInfo.Race.ToString().MaxSubstring(1), "player", playerInfo.IdWithLinkIfNeeded, "team", playerInfo.Team, "totalplayed", totalplayed.ToString(), "mostplayed.map", mostplayedmap, "mostplayed.count", mostplayedcount, "bestmap.map", bestmapmap, "bestmap.record", bestmaprecord, "bestmap.count", bestmapcount, "worstmap.map", worstmapmap, "worstmap.record", worstmaprecord, "worstmap.count", worstmapcount) .MergeGrouping(tm, (x) => x.map, (x) => x.wl.ToString()); var template = new PlayerMapStatistics(); template.Maps = maps; template.Rows = table; tw.Write(template.TransformText()); }