Exemple #1
0
        public void DeserializeReplay(DataAnalysis da, BattleReplay r)
        {
            da.ID = r.ID;

            var info = new DataAnalysisInfo();

            info.User1     = r.Usr1;
            info.User2     = r.Usr2;
            info.UserName1 = r.UsrName1;
            info.UserName2 = r.UsrName2;

            info.Date = r.Date;

            var secs = r.Length * 100 / 1000;
            var min  = secs / 60;

            secs = secs - min * 60;
            var time = (min.ToString().PadLeft(2, '0')) + ":" + (secs.ToString().PadLeft(2, '0'));

            info.Length = time;

            foreach (var para in r.Msgs)
            {
                if (para.Value.Available <= 0)
                {
                    continue;
                }

                if (para.Key == "BattleEnd")
                {
                    info.Winner = para.Value.ReadString();
                }
                else if (para.Key == "DropSoldierFromCarrier")
                {
                    var player = para.Value.ReadInt();
                    if (player == 1)
                    {
                        info.SoldierCarrierCount1++;
                    }
                    else if (player == 2)
                    {
                        info.SoldierCarrierCount2++;
                    }
                }
                else if (para.Key == "AddBattleUnitAt")
                {
                    DeserializeReplayMag(info, para.Value);
                }
            }

            da.Info = info;
        }
Exemple #2
0
        private void DeserializeReplayMag(DataAnalysisInfo info, IReadableBuffer buff)
        {
            var player = buff.ReadInt();
            var type   = buff.ReadString();

            switch (type)
            {
            case "Dog":
                if (player == 1)
                {
                    info.DogCount1++;
                }
                else if (player == 2)
                {
                    info.DogCount2++;
                }
                break;

            case "Soldier":
                if (player == 1)
                {
                    info.SoldierCount1++;
                }
                else if (player == 2)
                {
                    info.SoldierCount2++;
                }
                break;

            case "Firebat":
                if (player == 1)
                {
                    info.FirebatCount1++;
                }
                else if (player == 2)
                {
                    info.FirebatCount2++;
                }
                break;

            case "MagSpider":
                if (player == 1)
                {
                    info.MagSpiderCount1++;
                }
                else if (player == 2)
                {
                    info.MagSpiderCount2++;
                }
                break;

            case "Robot":
                if (player == 1)
                {
                    info.RobotCount1++;
                }
                else if (player == 2)
                {
                    info.RobotCount2++;
                }
                break;

            case "Tank":
                if (player == 1)
                {
                    info.TankCount1++;
                }
                else if (player == 2)
                {
                    info.TankCount2++;
                }
                break;

            case "Thor":
                if (player == 1)
                {
                    info.ThorCount1++;
                }
                else if (player == 2)
                {
                    info.ThorCount2++;
                }
                break;

            case "Hammer":
                if (player == 1)
                {
                    info.HammerCount1++;
                }
                else if (player == 2)
                {
                    info.HammerCount2++;
                }
                break;

            case "Warplane":
                if (player == 1)
                {
                    info.WarplaneCount1++;
                }
                else if (player == 2)
                {
                    info.WarplaneCount2++;
                }
                break;

            case "MotherShip":
                if (player == 1)
                {
                    info.MotherShipCount1++;
                }
                else if (player == 2)
                {
                    info.MotherShipCount2++;
                }
                break;
            }
        }