Exemplo n.º 1
0
 static void SetBp(string breakpoint, int min, int gameloop, dsplayer pl, Dictionary <string, int> units)
 {
     if (units.ContainsKey("Mid"))
     {
         int temp = min - gameloop;
         units["Mid"] += temp;
         if (units["Mid"] < 0)
         {
             units["Mid"] = 0;
         }
     }
     pl.UNITS[breakpoint] = units;
 }
Exemplo n.º 2
0
        // WebDatabase Replay
        // LocalDatabase Replay
        // DecodedReplay
        // OldReplay
        public static DSReplay Rep(dsreplay rep, string id = "player")
        {
            DSReplay dbrep = new DSReplay();

            dbrep.REPLAYPATH = rep.REPLAY;
            using (var md5 = MD5.Create())
            {
                string dirHash  = BitConverter.ToString(md5.ComputeHash(Encoding.UTF8.GetBytes(Path.GetDirectoryName(rep.REPLAY)))).Replace("-", "").ToLowerInvariant();
                string fileHash = BitConverter.ToString(md5.ComputeHash(Encoding.UTF8.GetBytes(Path.GetFileName(rep.REPLAY)))).Replace("-", "").ToLowerInvariant();
                dbrep.REPLAY = dirHash + fileHash;
            }
            string   gametime = rep.GAMETIME.ToString();
            int      year     = int.Parse(gametime.Substring(0, 4));
            int      month    = int.Parse(gametime.Substring(4, 2));
            int      day      = int.Parse(gametime.Substring(6, 2));
            int      hour     = int.Parse(gametime.Substring(8, 2));
            int      min      = int.Parse(gametime.Substring(10, 2));
            int      sec      = int.Parse(gametime.Substring(12, 2));
            DateTime gtime    = new DateTime(year, month, day, hour, min, sec);

            dbrep.GAMETIME = gtime;
            dbrep.WINNER   = (sbyte)rep.WINNER;
            TimeSpan d = TimeSpan.FromSeconds(rep.DURATION / 22.4);

            dbrep.DURATION    = (int)d.TotalSeconds;
            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 (dsplayer pl in rep.PLAYERS)
            {
                DSPlayer dbpl = new DSPlayer();
                dbpl.POS     = (byte)pl.POS;
                dbpl.REALPOS = (byte)pl.REALPOS;
                if (pl.NAME == "player")
                {
                    dbpl.NAME = id;
                }
                else
                {
                    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)TimeSpan.FromSeconds(pl.PDURATION / 22.4).TotalSeconds;
                dbpl.ARMY      = pl.ARMY;
                dbpl.GAS       = (byte)pl.GAS;
                dsplayer opp = rep.GetOpp(pl.REALPOS);
                if (opp != null)
                {
                    dbpl.OPPRACE = opp.RACE;
                }
                int diff = dbrep.DURATION - dbpl.PDURATION;
                if (diff > dbrep.MAXLEAVER)
                {
                    dbrep.MAXLEAVER = diff;
                }

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

                List <DbBreakpoint> bps = new List <DbBreakpoint>();
                foreach (var bp in pl.UNITS.Keys)
                {
                    DbBreakpoint dbbp = new DbBreakpoint();
                    dbbp.Breakpoint    = bp;
                    dbbp.dsUnitsString = "";

                    foreach (var name in pl.UNITS[bp].Keys)
                    {
                        if (name == "Gas")
                        {
                            dbbp.Gas = pl.UNITS[bp][name];
                        }
                        else if (name == "Upgrades")
                        {
                            dbbp.Upgrades = pl.UNITS[bp][name];
                        }
                        else if (name == "Mid")
                        {
                            dbbp.Mid = pl.UNITS[bp][name];
                        }
                        else
                        {
                            UnitModelBase unit = DSdata.Units.FirstOrDefault(f => f.Race == pl.RACE && f.Name == Fix.UnitName(name));
                            if (unit != null)
                            {
                                dbbp.dsUnitsString += unit.ID + "," + pl.UNITS[bp][name] + "|";
                            }
                            else
                            {
                                dbbp.dsUnitsString += name + "," + pl.UNITS[bp][name] + "|";
                            }
                        }
                    }
                    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);
        }
Exemplo n.º 3
0
        public static void ReadJson(string file)
        {
            Console.WriteLine("Working on " + Path.GetFileName(file));
            string filename = Path.GetFileNameWithoutExtension(file);
            string plhash   = filename.Substring(filename.Length - 64);
            int    i        = 0;
            int    j        = 0;

            foreach (var line in File.ReadAllLines(file, Encoding.UTF8))
            {
                dsreplay replay = System.Text.Json.JsonSerializer.Deserialize <dsreplay>(line);
                if (replay != null)
                {
                    i++;
                    replay.Init();
                    replay.GenHash();

                    dsplayer pl = replay.PLAYERS.FirstOrDefault(s => s.NAME == "player");
                    if (pl != null)
                    {
                        pl.NAME = plhash;
                        replay.PLDupPos[plhash] = pl.REALPOS;
                    }

                    dsreplay crep = sReplays.SingleOrDefault(s => s.HASH == replay.HASH);

                    if (crep == null)
                    {
                        sReplays.Add(replay);
                        Hashs.Add(replay.HASH);
                    }
                    else
                    {
                        j++;
                        if (new Version(replay.VERSION) >= new Version(crep.VERSION))
                        {
                            foreach (var ent in crep.PLAYERS.Select(s => new { s.NAME, s.REALPOS }))
                            {
                                try
                                {
                                    if (ent.NAME.Length == 64 && replay.PLAYERS.Single(x => x.REALPOS == ent.REALPOS).NAME.Length < 64)
                                    {
                                        replay.PLAYERS.Single(x => x.REALPOS == ent.REALPOS).NAME = ent.NAME;
                                    }
                                }
                                catch
                                {
                                    Console.WriteLine("???");
                                }
                            }
                            sReplays.Remove(crep);
                            sReplays.Add(replay);
                        }
                        else
                        {
                            foreach (var ent in replay.PLAYERS.Select(s => new { s.NAME, s.REALPOS }))
                            {
                                try
                                {
                                    if (ent.NAME.Length == 64 && crep.PLAYERS.Single(x => x.REALPOS == ent.REALPOS).NAME.Length < 64)
                                    {
                                        crep.PLAYERS.Single(x => x.REALPOS == ent.REALPOS).NAME = ent.NAME;
                                    }
                                }
                                catch (Exception e)
                                {
                                    Console.WriteLine(":( " + e.Message);
                                }
                            }
                        }
                    }
                }
            }
            Console.WriteLine($"{i} ({j})");
        }
Exemplo n.º 4
0
        public static int GetPlayer(GameMapModel _map, dsreplay replay, Player pl, int gameloop = 0)
        {
            dsplayer dspl = replay.PLAYERS.SingleOrDefault(x => x.REALPOS == pl.Pos);

            if (dspl == null)
            {
                return(gameloop);
            }

            pl.SoftReset();
            if (pl.Name == "")
            {
                pl.Name = dspl.NAME;
                pl.Pos  = dspl.REALPOS;
                UnitRace race = UnitRace.Terran;
                if (dspl.RACE == "Protoss")
                {
                    race = UnitRace.Protoss;
                }
                else if (dspl.RACE == "Zerg")
                {
                    race = UnitRace.Zerg;
                }
                pl.Race  = race;
                pl.Units = UnitPool.Units.Where(x => x.Race == race && x.Cost > 0).ToList();
            }

            if (gameloop == 0)
            {
                gameloop = _map.plSpawns[pl.Pos].OrderBy(o => o).First();
            }

            foreach (var unit in _map.Spawns[gameloop].Where(x => x.Owner == pl.Pos))
            {
                Unit myunit = unit.DeepCopy();
                if (pl.Pos <= 3)
                {
                    //myunit.PlacePos = UnitService.mirrorImage(myunit.PlacePos);
                    //myunit.PlacePos = new Vector2(Battlefield.Xmax - myunit.PlacePos.X, myunit.PlacePos.Y);
                    myunit.PlacePos = new Vector2(myunit.PlacePos.X, 2 * 5 - myunit.PlacePos.Y - 1);
                }
                UnitService.NewUnit(pl, myunit);
                pl.Units.Add(myunit);
                pl.MineralsCurrent -= myunit.Cost;
            }

            foreach (var dic in _map.Upgrades[pl.Pos].OrderBy(x => x.Key))
            {
                if (dic.Key > gameloop)
                {
                    break;
                }
                foreach (var upgrade in dic.Value)
                {
                    pl.MineralsCurrent -= UnitService.UpgradeUnit(upgrade.Upgrade, pl);
                }
            }
            foreach (var dic in _map.AbilityUpgrades[pl.Pos].OrderBy(x => x.Key))
            {
                if (dic.Key > gameloop)
                {
                    break;
                }
                foreach (var upgrade in dic.Value)
                {
                    pl.MineralsCurrent -= UnitService.AbilityUpgradeUnit(upgrade, pl);
                }
            }
            pl.MineralsCurrent = 10000;
            return(gameloop);
        }
Exemplo n.º 5
0
        public static dsreplay GetDetails(string replay_file, dynamic details_dec)
        {
            string id             = Path.GetFileNameWithoutExtension(replay_file);
            string reppath        = Path.GetDirectoryName(replay_file);
            var    plainTextBytes = Encoding.UTF8.GetBytes(reppath);
            MD5    md5            = new MD5CryptoServiceProvider();
            string reppath_md5    = System.BitConverter.ToString(md5.ComputeHash(plainTextBytes));
            string repid          = reppath_md5 + "/" + id;


            dsreplay replay = new dsreplay();

            replay.REPLAY = repid;
            Program.Log("Replay id: " + repid);
            int failsafe_pos = 0;

            foreach (var player in details_dec["m_playerList"])
            {
                if (player["m_observe"] > 0)
                {
                    continue;
                }

                failsafe_pos++;
                string name = "";
                Bytes  bab  = null;
                try
                {
                    bab = player["m_name"];
                }
                catch { }

                if (bab != null)
                {
                    name = Encoding.UTF8.GetString(bab.ToByteArray());
                }
                else
                {
                    name = player["m_name"].ToString();
                }

                Match m2 = s2parse.rx_subname.Match(name);
                if (m2.Success)
                {
                    name = m2.Groups[1].Value;
                }
                Program.Log("Replay playername: " + name);
                dsplayer pl = new dsplayer();

                pl.NAME = name;
                pl.RACE = player["m_race"].ToString();
                Program.Log("Replay race: " + pl.RACE);
                pl.RESULT = int.Parse(player["m_result"].ToString());
                pl.TEAM   = int.Parse(player["m_teamId"].ToString());
                try
                {
                    //pl.POS = int.Parse(player["m_workingSetSlotId"].ToString()) + 1;
                    pl.POS = failsafe_pos;
                }
                catch
                {
                    pl.POS = failsafe_pos;
                }
                replay.PLAYERS.Add(pl);
            }

            replay.PLAYERCOUNT = replay.PLAYERS.Count();

            long offset  = long.Parse(details_dec["m_timeLocalOffset"].ToString());
            long timeutc = long.Parse(details_dec["m_timeUTC"].ToString());

            long     georgian = timeutc + offset;
            DateTime gametime = DateTime.FromFileTime(georgian);

            replay.GAMETIME = double.Parse(gametime.ToString("yyyyMMddhhmmss"));
            Program.Log("Replay gametime: " + replay.GAMETIME);

            return(replay);
        }
Exemplo n.º 6
0
        public static dsreplay GetTrackerevents(string replay_file, dynamic trackerevents_dec, dsreplay replay)
        {
            bool fix = false;

            if (replay.GAMETIME <= 20190121000000)
            {
                fix = true;
            }

            bool             isBrawl_set = false;
            HashSet <string> Mutation    = new HashSet <string>();

            foreach (PythonDictionary pydic in trackerevents_dec)
            {
                if (pydic.ContainsKey("m_unitTypeName"))
                {
                    if (pydic.ContainsKey("m_controlPlayerId"))
                    {
                        int playerid = (int)pydic["m_controlPlayerId"];
                        int gameloop = (int)pydic["_gameloop"];
                        if (playerid == 0 || playerid > 6)
                        {
                            continue;
                        }
                        dsplayer pl = replay.PLAYERS.Where(x => x.POS == playerid).FirstOrDefault();
                        if (pl == null)
                        {
                            continue;
                        }

                        Match m = rx_race2.Match(pydic["m_unitTypeName"].ToString());
                        if (m.Success && m.Groups[1].Value.Length > 0)
                        {
                            replay.PLAYERS[playerid - 1].RACE = m.Groups[1].Value;
                        }
                        else if (pydic.ContainsKey("m_creatorAbilityName") && pydic["m_creatorAbilityName"] == null)
                        {
                            if (gameloop < 480)
                            {
                                continue;
                            }
                            if (pydic["_event"].ToString() == "NNet.Replay.Tracker.SUnitBornEvent")
                            {
                                string born_unit = pydic["m_unitTypeName"].ToString();

                                if (born_unit == "TrophyRiftPremium")
                                {
                                    continue;
                                }
                                if (born_unit == "MineralIncome")
                                {
                                    continue;
                                }
                                if (born_unit == "ParasiticBombRelayDummy")
                                {
                                    continue;
                                }
                                if (born_unit == "Biomass")
                                {
                                    continue;
                                }

                                int fixloop = gameloop;

                                if (pl.SPAWNS.Count() > 0)
                                {
                                    int maxloop = pl.SPAWNS.ElementAt(pl.SPAWNS.Count() - 1).Key;
                                    if ((gameloop - maxloop) <= 470)
                                    {
                                        fixloop = maxloop;
                                    }
                                }

                                if (!pl.SPAWNS.ContainsKey(fixloop))
                                {
                                    pl.SPAWNS.Add(fixloop, new Dictionary <string, int>());
                                }
                                if (!pl.SPAWNS[fixloop].ContainsKey(born_unit))
                                {
                                    pl.SPAWNS[fixloop].Add(born_unit, 1);
                                }
                                else
                                {
                                    pl.SPAWNS[fixloop][born_unit]++;
                                }

                                if (pl.REALPOS == null || pl.REALPOS == 0)
                                {
                                    int pos = 0;

                                    if (replay.PLAYERCOUNT == 2)
                                    {
                                        pos = 1;
                                    }
                                    else if ((gameloop - 480) % 1440 == 0)
                                    {
                                        pos = 1;
                                    }
                                    else if ((gameloop - 481) % 1440 == 0)
                                    {
                                        pos = 1;
                                    }
                                    else if ((gameloop - 960) % 1440 == 0)
                                    {
                                        pos = 2;
                                    }
                                    else if ((gameloop - 961) % 1440 == 0)
                                    {
                                        pos = 2;
                                    }
                                    else if ((gameloop - 1440) % 1440 == 0)
                                    {
                                        pos = 3;
                                    }
                                    else if ((gameloop - 1441) % 1440 == 0)
                                    {
                                        pos = 3;
                                    }

                                    if (replay.PLAYERCOUNT == 4 && pos == 3)
                                    {
                                        pos = 1;
                                    }

                                    if (pos > 0)
                                    {
                                        int team = REParea.GetTeam((int)pydic["m_x"], (int)pydic["m_y"]);
                                        if (team == 1)
                                        {
                                            pl.REALPOS = pos;
                                        }
                                        else if (team == 2)
                                        {
                                            pl.REALPOS = pos + 3;
                                        }
                                        pl.TEAM = team - 1;
                                    }
                                }
                            }
                        }
                    }
                }
                else if (pydic.ContainsKey("m_unitTagIndex") && (int)pydic["m_unitTagIndex"] == 20 && pydic.ContainsKey("_event") && pydic["_event"].ToString() == "NNet.Replay.Tracker.SUnitOwnerChangeEvent")
                {
                    int gameloop = (int)pydic["_gameloop"];
                    int upkeepid = (int)pydic["m_upkeepPlayerId"];

                    KeyValuePair <int, int> Mid = new KeyValuePair <int, int>(0, 0);
                    if (upkeepid == 13)
                    {
                        Mid = new KeyValuePair <int, int>(gameloop, 0);
                    }
                    else if (upkeepid == 14)
                    {
                        Mid = new KeyValuePair <int, int>(gameloop, 1);
                    }

                    if (Mid.Key > 0)
                    {
                        replay.MIDDLE.Add(Mid);
                    }
                }
                else if (pydic.ContainsKey("m_stats"))
                {
                    int playerid = (int)pydic["m_playerId"];
                    int gameloop = (int)pydic["_gameloop"];
                    if (playerid == 0 || playerid > 6)
                    {
                        continue;
                    }
                    dsplayer pl = replay.PLAYERS.Where(x => x.POS == playerid).FirstOrDefault();
                    if (pl == null)
                    {
                        continue;
                    }

                    if (isBrawl_set == false)
                    {
                        isBrawl_set = true;
                    }

                    PythonDictionary pystats = pydic["m_stats"] as PythonDictionary;
                    M_stats          m_stats = new M_stats();
                    m_stats.m_scoreValueFoodMade = (int)pystats["m_scoreValueFoodMade"];
                    m_stats.m_scoreValueFoodUsed = (int)pystats["m_scoreValueFoodUsed"];
                    m_stats.m_scoreValueMineralsCollectionRate         = (int)pystats["m_scoreValueMineralsCollectionRate"];
                    m_stats.m_scoreValueMineralsCurrent                = (int)pystats["m_scoreValueMineralsCurrent"];
                    m_stats.m_scoreValueMineralsFriendlyFireArmy       = (int)pystats["m_scoreValueMineralsFriendlyFireArmy"];
                    m_stats.m_scoreValueMineralsFriendlyFireEconomy    = (int)pystats["m_scoreValueMineralsFriendlyFireEconomy"];
                    m_stats.m_scoreValueMineralsFriendlyFireTechnology = (int)pystats["m_scoreValueMineralsFriendlyFireTechnology"];
                    m_stats.m_scoreValueMineralsKilledArmy             = (int)pystats["m_scoreValueMineralsKilledArmy"];
                    m_stats.m_scoreValueMineralsKilledEconomy          = (int)pystats["m_scoreValueMineralsKilledEconomy"];
                    m_stats.m_scoreValueMineralsKilledTechnology       = (int)pystats["m_scoreValueMineralsKilledTechnology"];
                    m_stats.m_scoreValueMineralsLostArmy               = (int)pystats["m_scoreValueMineralsLostArmy"];
                    m_stats.m_scoreValueMineralsLostEconomy            = (int)pystats["m_scoreValueMineralsLostEconomy"];
                    m_stats.m_scoreValueMineralsLostTechnology         = (int)pystats["m_scoreValueMineralsLostTechnology"];
                    m_stats.m_scoreValueMineralsUsedActiveForces       = (int)pystats["m_scoreValueMineralsUsedActiveForces"];
                    m_stats.m_scoreValueMineralsUsedCurrentArmy        = (int)pystats["m_scoreValueMineralsUsedCurrentArmy"];
                    m_stats.m_scoreValueMineralsUsedCurrentEconomy     = (int)pystats["m_scoreValueMineralsUsedCurrentEconomy"];
                    m_stats.m_scoreValueMineralsUsedCurrentTechnology  = (int)pystats["m_scoreValueMineralsUsedCurrentTechnology"];

                    /**
                     * m_stats.m_scoreValueMineralsUsedInProgressArmy = (int)pystats["m_scoreValueMineralsUsedInProgressArmy"];
                     * m_stats.m_scoreValueMineralsUsedInProgressEconomy = (int)pystats["m_scoreValueMineralsUsedInProgressEconomy"];
                     * m_stats.m_scoreValueMineralsUsedInProgressTechnology = (int)pystats["m_scoreValueMineralsUsedInProgressTechnology"];
                     * m_stats.m_scoreValueVespeneCollectionRate = (int)pystats["m_scoreValueVespeneCollectionRate"];
                     * m_stats.m_scoreValueVespeneCurrent = (int)pystats["m_scoreValueVespeneCurrent"];
                     * m_stats.m_scoreValueVespeneFriendlyFireArmy = (int)pystats["m_scoreValueVespeneFriendlyFireArmy"];
                     * m_stats.m_scoreValueVespeneFriendlyFireEconomy = (int)pystats["m_scoreValueVespeneFriendlyFireEconomy"];
                     * m_stats.m_scoreValueVespeneFriendlyFireTechnology = (int)pystats["m_scoreValueVespeneFriendlyFireTechnology"];
                     * m_stats.m_scoreValueVespeneKilledArmy = (int)pystats["m_scoreValueVespeneKilledArmy"];
                     * m_stats.m_scoreValueVespeneKilledEconomy = (int)pystats["m_scoreValueVespeneKilledEconomy"];
                     * m_stats.m_scoreValueVespeneKilledTechnology = (int)pystats["m_scoreValueVespeneKilledTechnology"];
                     * m_stats.m_scoreValueVespeneLostArmy = (int)pystats["m_scoreValueVespeneLostArmy"];
                     * m_stats.m_scoreValueVespeneLostEconomy = (int)pystats["m_scoreValueVespeneLostEconomy"];
                     * m_stats.m_scoreValueVespeneLostTechnology = (int)pystats["m_scoreValueVespeneLostTechnology"];
                     * m_stats.m_scoreValueVespeneUsedActiveForces = (int)pystats["m_scoreValueVespeneUsedActiveForces"];
                     * m_stats.m_scoreValueVespeneUsedCurrentArmy = (int)pystats["m_scoreValueVespeneUsedCurrentArmy"];
                     * m_stats.m_scoreValueVespeneUsedCurrentEconomy = (int)pystats["m_scoreValueVespeneUsedCurrentEconomy"];
                     * m_stats.m_scoreValueVespeneUsedCurrentTechnology = (int)pystats["m_scoreValueVespeneUsedCurrentTechnology"];
                     * m_stats.m_scoreValueVespeneUsedInProgressArmy = (int)pystats["m_scoreValueVespeneUsedInProgressArmy"];
                     * m_stats.m_scoreValueVespeneUsedInProgressEconomy = (int)pystats["m_scoreValueVespeneUsedInProgressEconomy"];
                     * m_stats.m_scoreValueVespeneUsedInProgressTechnology = (int)pystats["m_scoreValueVespeneUsedInProgressTechnology"];
                     * m_stats.m_scoreValueWorkersActiveCount = (int)pystats["m_scoreValueWorkersActiveCount"];
                     **/
                    pl.STATS[gameloop] = m_stats;

                    replay.DURATION = gameloop;
                    pl.PDURATION    = gameloop;

                    int gas    = 0;
                    int income = pl.STATS[gameloop].m_scoreValueMineralsCollectionRate;
                    pl.INCOME += (double)income / 9.15;

                    KeyValuePair <int, int> lastMid = GetMiddle(replay);
                    if (lastMid.Key > 160 && lastMid.Value == pl.TEAM)
                    {
                        income -= 60;
                    }

                    if (income < 470)
                    {
                        gas = 0;               // base income
                    }
                    else if (income < 500)
                    {
                        gas = 1;
                    }
                    else if (income < 530 && gameloop > 2240)
                    {
                        gas = 2;
                    }
                    else if (income < 560 && gameloop > 4480)
                    {
                        gas = 3;
                    }
                    else if (income < 600 && gameloop > 13440)
                    {
                        gas = 4;
                    }
                    if (gas > pl.GAS)
                    {
                        pl.GAS = gas;
                    }

                    int pos = 0;
                    if ((gameloop - 480) % 1440 == 0)
                    {
                        pos = 1;
                    }
                    else if ((gameloop - 960) % 1440 == 0)
                    {
                        pos = 2;
                    }
                    else if ((gameloop - 1440) % 1440 == 0)
                    {
                        pos = 3;
                    }

                    if (pos > 0)
                    {
                        if (replay.PLAYERCOUNT == 4 && pos == 3)
                        {
                            pos = 1;
                        }

                        if (pl.REALPOS == pos || pl.REALPOS == pos + 3 || replay.PLAYERCOUNT == 2)
                        {
                            int fixloop = gameloop;

                            if (!pl.SPAWNS.ContainsKey(fixloop))
                            {
                                pl.SPAWNS.Add(fixloop, new Dictionary <string, int>());
                            }

                            pl.SPAWNS[fixloop]["Gas"] = pl.GAS;
                            if (pl.TEAM == 0)
                            {
                                pl.SPAWNS[fixloop]["Mid"] = GetMiddle(replay, true).Key;
                            }
                            else
                            {
                                pl.SPAWNS[fixloop]["Mid"] = GetMiddle(replay, true).Value;
                            }

                            if (pl.STATS.Count() > 0)
                            {
                                pl.SPAWNS[fixloop]["Upgrades"] = pl.STATS.ElementAt(pl.STATS.Count() - 1).Value.m_scoreValueMineralsUsedCurrentTechnology;
                                pl.ARMY += pl.STATS.ElementAt(pl.STATS.Count() - 1).Value.m_scoreValueMineralsUsedActiveForces;
                            }
                        }
                    }
                }
                else if (isBrawl_set == false && pydic.ContainsKey("_gameloop") && (int)pydic["_gameloop"] == 0 && pydic.ContainsKey("m_upgradeTypeName"))
                {
                    if (pydic["m_upgradeTypeName"].ToString().StartsWith("Mutation"))
                    {
                        Mutation.Add(pydic["m_upgradeTypeName"].ToString());
                    }
                }
            }

            if (Mutation.Contains("MutationCovenant"))
            {
                replay.GAMEMODE = "GameModeSwitch";
            }
            else if (Mutation.Contains("MutationEquipment"))
            {
                replay.GAMEMODE = "GameModeGear";
            }
            else if (Mutation.Contains("MutationExile") &&
                     Mutation.Contains("MutationRescue") &&
                     Mutation.Contains("MutationShroud") &&
                     Mutation.Contains("MutationSuperscan"))
            {
                replay.GAMEMODE = "GameModeSabotage";
            }
            else if (Mutation.Contains("MutationCommanders"))
            {
                replay.GAMEMODE = "GameModeCommanders"; // fail safe
                if (Mutation.Count() == 3 && Mutation.Contains("MutationExpansion") && Mutation.Contains("MutationOvertime"))
                {
                    replay.GAMEMODE = "GameModeCommandersHeroic";
                }
                else if (Mutation.Count() == 2 && Mutation.Contains("MutationOvertime"))
                {
                    replay.GAMEMODE = "GameModeCommanders";
                }
                else if (Mutation.Count() >= 3)
                {
                    replay.GAMEMODE = "GameModeBrawlCommanders";
                }
            }
            else
            {
                if (replay.GAMEMODE == "unknown" && Mutation.Count() == 0)
                {
                    replay.GAMEMODE = "GameModeStandard";
                }
                else if (replay.GAMEMODE == "unknown" && Mutation.Count() > 0)
                {
                    replay.GAMEMODE = "GameModeBrawlStandard";
                }
            }

            replay.ISBRAWL = true;
            if (replay.GAMEMODE == "GameModeCommanders" || replay.GAMEMODE == "GameModeCommandersHeroic" || replay.GAMEMODE == "GameModeStandard")
            {
                replay.ISBRAWL = false;
            }



            GetMiddle(replay);
            SetUnits(replay);

            // fail safe
            FixPos(replay);
            FixWinner(replay);


            return(replay);
        }