public DbRefinery(int gameloop, int index, int recycletag, DSPlayer pl) : this() { Gameloop = gameloop; Index = index; RecycleTag = recycletag; Player = pl; }
public void SetMid(DSReplay replay, string Breakpoint) { double bpgameloop = BreakpointMid[Breakpoint]; if (replay.Middle == null || !replay.Middle.Any()) { DSPlayer mpl1 = replay.DSPlayer.FirstOrDefault(f => f.TEAM == 0); if (mpl1 != null) { DbBreakpoint bp = mpl1.Breakpoints.FirstOrDefault(x => x.Breakpoint == Breakpoint); if (bp != null) { Mid[0] = Math.Round(bp.Mid * 100 / bpgameloop, 2).ToString("00.00") + "%"; } } DSPlayer mpl2 = replay.DSPlayer.FirstOrDefault(f => f.TEAM == 1); if (mpl2 != null) { DbBreakpoint bp = mpl2.Breakpoints.FirstOrDefault(x => x.Breakpoint == Breakpoint); if (bp != null) { Mid[1] = Math.Round(bp.Mid * 100 / bpgameloop, 2).ToString("00.00") + "%"; } } } else { int midt1 = replay.GetMiddle((int)bpgameloop, 0); int midt2 = replay.GetMiddle((int)bpgameloop, 1); Mid[0] = Math.Round(midt1 * 100 / bpgameloop, 2).ToString("00.00") + "%"; Mid[1] = Math.Round(midt2 * 100 / bpgameloop, 2).ToString("00.00") + "%"; } }
public void Init(DSReplay replay, DSoptions _options) { DSPlayer pl = null; if (DSdata.Config.Players.Any()) { List <string> activePlayers = _options.Players.Where(x => x.Value == true).Select(s => s.Key).ToList(); pl = replay.DSPlayer.Where(x => activePlayers.Contains(x.NAME)).FirstOrDefault(); } else { pl = replay.DSPlayer.Where(x => x.NAME.Length == 64).FirstOrDefault(); } Id = $"ID {replay.ID} - {replay.GAMETIME.ToString("yyyy/MM/dd")}"; Duration = "Duration " + (TimeSpan.FromSeconds(replay.DURATION).Hours > 0 ? TimeSpan.FromSeconds(replay.DURATION).ToString(@"hh\:mm\:ss") + " h" : TimeSpan.FromSeconds(replay.DURATION).ToString(@"mm\:ss") + " min"); if (pl != null) { Player = "Player #" + pl.REALPOS; } MVP = "MVP #" + replay.DSPlayer.Where(x => x.KILLSUM == replay.MAXKILLSUM).First().REALPOS; Mode = "Mode: " + replay.GAMEMODE.Substring(8); BreakpointMid = new Dictionary <string, double>(DSdata.BreakpointMid); BreakpointMid["ALL"] = replay.DURATION * 22.4; SetMid(replay, _options.GameBreakpoint); _options.GameBreakpoint = "ALL"; foreach (DSPlayer bpl in replay.DSPlayer) { HashSet <string> ups = new HashSet <string>(); Upgrades[bpl.REALPOS] = new Dictionary <string, HashSet <string> >(); Units[bpl.REALPOS] = new Dictionary <string, Dictionary <string, int> >(); List <string> bpdelete = new List <string>(); foreach (var ent in BreakpointMid.OrderBy(o => o.Value)) { if (ent.Value > BreakpointMid["ALL"]) { bpdelete.Add(ent.Key); continue; } ups.UnionWith(GetUpgrades(bpl.Breakpoints.FirstOrDefault(f => f.Breakpoint == ent.Key)).ToHashSet()); Upgrades[bpl.REALPOS][ent.Key] = new HashSet <string>(ups); Units[bpl.REALPOS][ent.Key] = new Dictionary <string, int>(GetUnits(bpl.Breakpoints.FirstOrDefault(f => f.Breakpoint == ent.Key))); } foreach (string dkey in bpdelete) { BreakpointMid.Remove(dkey); } } }
public string GenHash() { string md5 = ""; string hashstring = ""; foreach (DSPlayer pl in DSPlayer.OrderBy(o => o.POS)) { hashstring += pl.POS + pl.RACE; } hashstring += MINARMY + MINKILLSUM + MININCOME + MAXKILLSUM; using (MD5 md5Hash = MD5.Create()) { md5 = GetMd5Hash(md5Hash, hashstring); } return(md5); }
public DbUpgrade(int gameloop, string upgrade, DSPlayer pl) : this() { Gameloop = gameloop; Upgrade = upgrade; Player = pl; }
public List <UnitModel> GetDbUnits(DSPlayer pl, DbBreakpoint bp, int objective) { List <UnitModel> Units = new List <UnitModel>(); if (bp == null || String.IsNullOrEmpty(bp.dbUnitsString)) { return(Units); } foreach (string unitstring in bp.dbUnitsString.Split("|")) { var ent = unitstring.Split(","); UnitModel unit = new UnitModel(); unit.Name = ent[0]; unit.Race = pl.RACE; unit.Pos = new Vector2(int.Parse(ent[1]), int.Parse(ent[2])); int id = 0; if (int.TryParse(ent[0], out id)) { UnitModelBase bunit = DSdata.Units.FirstOrDefault(f => f.ID == id); if (bunit != null) { unit.Name = bunit.Name; } } Vector2 vec = Fix.RotatePoint(unit.Pos, center, -45); float newx = 0; float newy = 0; // Rotated Nexus/CC // 1 // 77.08831, 114.34315 // 173.25484, 120 // 2 // 77.08831, 125.656685 // 167.59798, 125.656685 if (pl.REALPOS > 3) { newx = (vec.X - 62.23907f) / 2; } else { newx = (vec.X - 176.79037f) / 2; } newy = vec.Y - 107.97919f; if (objective == 2) { newy -= 11.313535f / 2; newx += 5.65686f / 2; } unit.RotatePos = new Vector2(newx, newy); Units.Add(unit); } return(Units); }