Example #1
0
        public static DSReplay Rep(Dsreplays rep)
        {
            DSReplay dbrep = new DSReplay();

            dbrep.REPLAY      = rep.Replay;
            dbrep.REPLAYPATH  = String.Empty;
            dbrep.GAMETIME    = rep.Gametime;
            dbrep.WINNER      = (sbyte)rep.Winner;
            dbrep.DURATION    = (int)rep.Duration;
            dbrep.MINKILLSUM  = rep.Minkillsum;
            dbrep.MAXKILLSUM  = rep.Maxkillsum;
            dbrep.MINARMY     = rep.Minarmy;
            dbrep.MININCOME   = (int)rep.Minincome;
            dbrep.PLAYERCOUNT = (byte)rep.Playercount;
            dbrep.REPORTED    = (byte)rep.Reported;
            dbrep.ISBRAWL     = rep.Isbrawl;
            dbrep.GAMEMODE    = rep.Gamemode;
            dbrep.VERSION     = rep.Version;
            dbrep.MAXLEAVER   = 0;

            List <DSPlayer> pls = new List <DSPlayer>();

            foreach (Dsplayers pl in rep.Dsplayers)
            {
                DSPlayer dbpl = new DSPlayer();
                dbpl.POS     = (byte)pl.Pos;
                dbpl.REALPOS = (byte)pl.Realpos;
                dbpl.NAME    = pl.Name;
                dbpl.RACE    = pl.Race;
                if (pl.Team == rep.Winner)
                {
                    dbpl.WIN = true;
                }
                dbpl.TEAM      = (byte)pl.Team;
                dbpl.KILLSUM   = pl.Killsum;
                dbpl.INCOME    = (int)pl.Income;
                dbpl.PDURATION = (int)pl.Pduration;
                dbpl.ARMY      = pl.Army;
                dbpl.GAS       = (byte)pl.Gas;
                Dsplayers opp = GetOpp(pl.Realpos, rep);
                if (opp != null)
                {
                    dbpl.OPPRACE = opp.Race;
                }
                int diff = dbrep.DURATION - (int)pl.Pduration;
                if (diff > dbrep.MAXLEAVER)
                {
                    dbrep.MAXLEAVER = diff;
                }

                dbpl.DSReplay = dbrep;
                pls.Add(dbpl);

                List <DbBreakpoint> bps = new List <DbBreakpoint>();
                foreach (var bp in DSdata.s_breakpoints)
                {
                    DbBreakpoint dbbp = new DbBreakpoint();
                    dbbp.Breakpoint    = bp;
                    dbbp.dsUnitsString = "";
                    foreach (var runit in pl.Dsunits.Where(x => x.Bp == bp))
                    {
                        if (runit.Name == "Gas")
                        {
                            dbbp.Gas = runit.Count;
                        }
                        else if (runit.Name == "Upgrades")
                        {
                            dbbp.Upgrades = runit.Count;
                        }
                        else if (runit.Name == "Mid")
                        {
                            dbbp.Mid = runit.Count;
                        }
                        else
                        {
                            UnitModelBase unit = DSdata.Units.FirstOrDefault(f => f.Race == pl.Race && f.Name == Fix.UnitName(runit.Name));
                            if (unit != null)
                            {
                                dbbp.dsUnitsString += unit.ID + "," + runit.Count + "|";
                            }
                            else
                            {
                                dbbp.dsUnitsString += runit.Name + "," + runit.Count + "|";
                            }
                        }
                    }
                    if (!String.IsNullOrEmpty(dbbp.dsUnitsString))
                    {
                        dbbp.dsUnitsString = dbbp.dsUnitsString.Remove(dbbp.dsUnitsString.Length - 1);
                    }
                    bps.Add(dbbp);
                }
                dbpl.Breakpoints = bps;
            }
            dbrep.DSPlayer = pls as ICollection <DSPlayer>;
            dbrep.HASH     = dbrep.GenHash();
            dbrep.Upload   = DateTime.UtcNow;


            return(dbrep);
        }
Example #2
0
        public static Dsplayers GetOpp(int pos, Dsreplays rep)
        {
            Dsplayers plopp = new Dsplayers();

            if (rep.Playercount == 6)
            {
                if (pos == 1)
                {
                    plopp = rep.Dsplayers.FirstOrDefault(x => x.Realpos == 4);
                }
                if (pos == 2)
                {
                    plopp = rep.Dsplayers.FirstOrDefault(x => x.Realpos == 5);
                }
                if (pos == 3)
                {
                    plopp = rep.Dsplayers.FirstOrDefault(x => x.Realpos == 6);
                }
                if (pos == 4)
                {
                    plopp = rep.Dsplayers.FirstOrDefault(x => x.Realpos == 1);
                }
                if (pos == 5)
                {
                    plopp = rep.Dsplayers.FirstOrDefault(x => x.Realpos == 2);
                }
                if (pos == 6)
                {
                    plopp = rep.Dsplayers.FirstOrDefault(x => x.Realpos == 3);
                }
                //opp = plopp.RACE;
            }
            else if (rep.Playercount == 4)
            {
                if (pos == 1)
                {
                    plopp = rep.Dsplayers.FirstOrDefault(x => x.Realpos == 4);
                }
                if (pos == 2)
                {
                    plopp = rep.Dsplayers.FirstOrDefault(x => x.Realpos == 5);
                }
                if (pos == 4)
                {
                    plopp = rep.Dsplayers.FirstOrDefault(x => x.Realpos == 1);
                }
                if (pos == 5)
                {
                    plopp = rep.Dsplayers.FirstOrDefault(x => x.Realpos == 2);
                }
            }
            else if (rep.Playercount == 2)
            {
                if (pos == 1)
                {
                    plopp = rep.Dsplayers.FirstOrDefault(x => x.Realpos == 4);
                }
                if (pos == 4)
                {
                    plopp = rep.Dsplayers.FirstOrDefault(x => x.Realpos == 1);
                }
            }

            return(plopp);
        }
Example #3
0
 public DsReplayDto GetDto()
 {
     return(new DsReplayDto()
     {
         DSPlayer = Dsplayers.Select(s => new DSPlayerDto()
         {
             Breakpoints = s.Breakpoints.Select(b => new BreakpointDto()
             {
                 Breakpoint = b.Breakpoint1,
                 Gas = b.Gas,
                 Income = b.Income,
                 Army = b.Army,
                 Kills = b.Kills,
                 Upgrades = b.Upgrades,
                 Tier = b.Tier,
                 Mid = b.Mid,
                 dsUnitsString = b.DsUnitsString,
                 dbUnitsString = b.DbUnitsString,
                 dbUpgradesString = b.DbUpgradesString
             }).ToList(),
             POS = s.Pos,
             REALPOS = s.Realpos,
             NAME = s.Name,
             RACE = ((Commander)s.Race).ToString(),
             OPPRACE = ((Commander)s.Opprace).ToString(),
             WIN = s.Win,
             TEAM = s.Team,
             KILLSUM = s.Killsum,
             INCOME = s.Income,
             PDURATION = s.Pduration,
             ARMY = s.Army,
             GAS = s.Gas,
             isPlayer = s.isPlayer
         }).ToList(),
         Middle = Middles.Select(m => new MiddleDto()
         {
             Gameloop = m.Gameloop,
             Team = m.Team
         }).ToList(),
         REPLAY = Replay,
         GAMETIME = Gametime,
         WINNER = Winner,
         DURATION = Duration,
         MINKILLSUM = Minkillsum,
         MAXKILLSUM = Maxkillsum,
         MINARMY = Minarmy,
         MININCOME = Minincome,
         MAXLEAVER = Maxleaver,
         PLAYERCOUNT = Playercount,
         REPORTED = Reported,
         ISBRAWL = Isbrawl,
         GAMEMODE = ((Gamemode)Gamemode).ToString(),
         VERSION = Version,
         HASH = Hash,
         REPLAYPATH = Replaypath,
         OBJECTIVE = Objective,
         Upload = Upload,
         Bunker = Bunker,
         Cannon = Cannon,
         Mid1 = Mid1,
         Mid2 = Mid2
     });
 }