public override bool IsDeserializeable(string s)
            {
                s = s.Trim();
                string[] rest;
                if (ProtocolV1_0Utils.GetParams(s, "INIT_ANSWER", out rest))
                {
                    if (rest.Length == 9)
                    {
                        int[] param;
                        if (Parser.TryParse(new ArraySegment <string>(rest, 0, 8), out param))
                        {
                            InitAnswerCommandV1_0 initAnswer = new InitAnswerCommandV1_0(param[0], param[1], param[2], param[3], param[4],
                                                                                         param[5], param[6], param[7]);



                            string[] moreString;
                            if (ProtocolV1_0Utils.Deserialize(rest[8], out moreString, ProtocolV1_0Utils.DEFAULT.NEXT))
                            {
                                initAnswer.DeserializeMore(moreString, initAnswer.MORE, SUB_COMMAND_FACTORIES);
                            }
                            cache.Cached(s, initAnswer);
                            return(true);
                        }
                    }
                }
                return(false);
            }
Beispiel #2
0
 public static bool Deserialize(string orig, Deep deep, out MineGunV1_0 deserialized)
 {
     string[] rest;
     if (ProtocolV1_0Utils.GetParams(orig, NAME, deep, out rest))
     {
         if (rest.Length == 4)
         {
             int[]    paramsInt;
             string[] zonesString;
             if (Parser.TryParse(new int[] { 0, 1, 2 }, rest, out paramsInt) &&
                 ProtocolV1_0Utils.Deserialize(rest[3], out zonesString, deep.NEXT))
             {
                 ZoneV1_0[] zones = new ZoneV1_0[zonesString.Length];
                 for (int i = 0; i < zones.Length; i++)
                 {
                     if (!ZoneV1_0.Deserialize(zonesString[i], deep.NEXT.NEXT, out zones[i]))
                     {
                         deserialized = null;
                         return(false);
                     }
                 }
                 deserialized = new MineGunV1_0(paramsInt[0], paramsInt[1], paramsInt[2], zones);
                 return(true);
             }
         }
     }
     deserialized = null;
     return(false);
 }
Beispiel #3
0
 public override bool IsDeserializeable(string s)
 {
     string[] rest;
     if (ProtocolV1_0Utils.GetParams(s, NAME, out rest))
     {
         cache.Cached(s, new PutMineCommandV1_0());
         return(true);
     }
     return(false);
 }
Beispiel #4
0
            public bool Deserialize(string s, object[] commandsMore)
            {
                String rest;

                if (ProtocolV1_0Utils.GetParams(s, COMMAND_NAME, out rest))
                {
                    String[] obtaclesString;
                    ProtocolV1_0Utils.Deserialize(rest, out obtaclesString, ProtocolV1_0Utils.DEFAULT.NEXT.NEXT);
                }
                return(false);
            }
 public override bool IsDeserializeable(string s)
 {
     string[] rest;
     if (ProtocolV1_0Utils.GetParams(s, NAME, out rest) && rest.Length == 1)
     {
         if (rest[0].Equals("0") || rest[0].Equals("1"))
         {
             cache.Cached(s, new RepairAnswerCommandV1_0(rest[0].Equals("1")));
             return(true);
         }
     }
     return(false);
 }
            public override Boolean IsDeserializable(String s)
            {
                string rest;

                if (ProtocolV1_0Utils.GetParams(s, NAME, out rest))
                {
                    if (rest.Equals("1") || rest.Equals("0"))
                    {
                        cache.Cached(s, new DriveAnswerCommandV1_0(rest.Equals("1")));
                        return(true);
                    }
                }
                return(false);
            }
Beispiel #7
0
 public override bool IsDeserializeable(string s)
 {
     string[] rest;
     if (ProtocolV1_0Utils.GetParams(s, COMMAND_NAME, out rest))
     {
         int x, y;
         if (rest.Length == 2 && int.TryParse(rest[0], out x) && int.TryParse(rest[1], out y))
         {
             cache.Cached(s, new Wall(x, y));
             return(true);
         }
     }
     return(false);
 }
Beispiel #8
0
 public override bool IsDeserializeable(string s)
 {
     string[] rest;
     if (ProtocolV1_0Utils.GetParams(s, NAME, out rest))
     {
         int param1; GameType param2;
         if (rest.Length == 2 && int.TryParse(rest[0], out param1) && Enum.TryParse(rest[1], true, out param2))
         {
             cache.Cached(s, new GameTypeCommandV1_0(param1, param2));
             return(true);
         }
     }
     return(false);
 }
 public override bool IsDeserializeable(string s)
 {
     string[] rest;
     if (ProtocolV1_0Utils.GetParams(s, NAME, out rest))
     {
         ProtocolDouble[] param;
         if (rest.Length == 2 && Parser.TryParse(rest, out param))
         {
             cache.Cached(s, new DriveCommandV1_0(param[0], param[1]));
             return(true);
         }
     }
     return(false);
 }
 public override bool IsDeserializeable(string s)
 {
     string[] rest;
     if (ProtocolV1_0Utils.GetParams(s, NAME, out rest))
     {
         ProtocolDouble angle, range;
         if (ProtocolDouble.TryParse(rest[0], out range) && ProtocolDouble.TryParse(rest[1], out angle))
         {
             cache.Cached(s, new ShootCommandV10(range, angle));
             return(true);
         }
     }
     return(false);
 }
 public override bool IsDeserializeable(string s)
 {
     string[] rest;
     if (ProtocolV1_0Utils.GetParams(s, NAME, out rest) && rest.Length == 1)
     {
         int mineId;
         if (int.TryParse(rest[0], out mineId))
         {
             cache.Cached(s, new DetonateMineCommandV1_0(mineId));
             return(true);
         }
     }
     return(false);
 }
Beispiel #12
0
 public override bool IsDeserializeable(string s)
 {
     string[] rest;
     if (ProtocolV1_0Utils.GetParams(s, COMMAND_NAME, out rest) && rest.Length == 3)
     {
         RobotType robotType;
         if (Enum.TryParse(rest[2], true, out robotType))
         {
             InitCommandV1_0 init = new InitCommandV1_0(rest[0], rest[1], robotType);
             cache.Cached(s, init);
             return(true);
         }
     }
     return(false);
 }
Beispiel #13
0
 public static bool Deserialize(string orig, Deep deep, out ZoneV1_0 deserialized)
 {
     string[] rest;
     int[]    param;
     if (ProtocolV1_0Utils.GetParams(orig, NAME, deep, out rest))
     {
         if (rest.Length == 2 && Parser.TryParse(rest, out param))
         {
             deserialized = new ZoneV1_0(param[0], param[1]);
             return(true);
         }
     }
     deserialized = null;
     return(false);
 }
 public override Boolean IsDeserializable(String s)
 {
     string[] rest;
     if (ProtocolV1_0Utils.GetParams(s, COMMAND_NAME, out rest))
     {
         if (rest.Length == 2)
         {
             int x, y;
             if (int.TryParse(rest[0], out x) && int.TryParse(rest[1], out y))
             {
                 cache.Cached(s, new OuterShildingV1_0(x, y));
             }
         }
     }
     return(false);
 }
Beispiel #15
0
 public static bool Deserialize(String orig, Deep deep, out ArmorV1_0 deserialized)
 {
     string[] rest;
     if (ProtocolV1_0Utils.GetParams(orig, NAME, deep, out rest))
     {
         if (rest.Length == 3)
         {
             int[] paramsInt;
             if (Parser.TryParse(rest, out paramsInt))
             {
                 deserialized = new ArmorV1_0(paramsInt[0], paramsInt[1], paramsInt[2]);
                 return(true);
             }
         }
     }
     deserialized = null;
     return(false);
 }
Beispiel #16
0
        public static bool Deserialize(string orig, Deep deep, out EndLapCommandV1_0 deserialized)
        {
            string[] rest;
            if (ProtocolV1_0Utils.GetParams(orig, COMMAND_NAME, deep, out rest))
            {
                if (rest.Length == 3)
                {
                    int      gold, score;
                    LapState lapState;

                    if (Enum.TryParse(rest[0], true, out lapState) && int.TryParse(rest[1], out gold) && int.TryParse(rest[2], out score))
                    {
                        deserialized = new EndLapCommandV1_0(lapState, gold, score);
                        return(true);
                    }
                }
            }
            deserialized = null;
            return(false);
        }
Beispiel #17
0
 public static bool Deserialize(String orig, Deep deep, out MotorV1_0 deserialized)
 {
     string[] rest;
     if (ProtocolV1_0Utils.GetParams(orig, NAME, deep, out rest))
     {
         if (rest.Length == 7)
         {
             ProtocolDouble[] paramsDouble;
             int[]            paramsInt;
             if (Parser.TryParse(new int[] { 0, 1, 2, 3, 4 }, rest, out paramsDouble) &&
                 Parser.TryParse(new int[] { 5, 6 }, rest, out paramsInt))
             {
                 deserialized = new MotorV1_0(paramsDouble[0], paramsDouble[1], paramsDouble[2], paramsDouble[3], paramsDouble[4], paramsInt[0], paramsInt[1]);
                 return(true);
             }
         }
     }
     deserialized = null;
     return(false);
 }
 public override bool IsDeserializeable(string s)
 {
     s = s.Trim();
     string[] rest;
     if (ProtocolV1_0Utils.GetParams(s, NAME, ProtocolV1_0Utils.DEFAULT, out rest))
     {
         if (rest.Length == 1 && ProtocolV1_0Utils.Deserialize(rest[0], out rest, ProtocolV1_0Utils.DEFAULT.NEXT))
         {
             GunV1_0[] guns = new GunV1_0[rest.Length];
             for (int i = 0; i < guns.Length; i++)
             {
                 if (!GunV1_0.Deserialize(rest[i], ProtocolV1_0Utils.DEFAULT.NEXT.NEXT, out guns[i]))
                 {
                     return(false);
                 }
             }
             cache.Cached(s, new GetGunsAnswerCommandV1_0(guns));
             return(true);
         }
     }
     return(false);
 }
 public override Boolean IsDeserializable(String s)
 {
     s = s.Trim();
     string[] rest;
     if (ProtocolV1_0Utils.GetParams(s, NAME, ProtocolV1_0Utils.DEFAULT, out rest))
     {
         if (rest.Length == 1 && ProtocolV1_0Utils.Deserialize(rest[0], out rest, ProtocolV1_0Utils.DEFAULT.NEXT))
         {
             MotorV1_0[] motors = new MotorV1_0[rest.Length];
             for (int i = 0; i < motors.Length; i++)
             {
                 if (!MotorV1_0.Deserialize(rest[i], ProtocolV1_0Utils.DEFAULT.NEXT.NEXT, out motors[i]))
                 {
                     return(false);
                 }
             }
             cache.Cached(s, new GetMotorsAnwerCommandV1_0(motors));
             return(true);
         }
     }
     return(false);
 }
            public bool Deserialize(string s, object[] commandsMore)
            {
                string[] basesString;
                if (ProtocolV1_0Utils.Deserialize(s, out basesString, ProtocolV1_0Utils.DEFAULT.NEXT.NEXT))
                {
                    List <Base> bases = new List <Base>();
                    foreach (var baseString in basesString)  // parametrs are separated by DEFAULT.NEXT.NEXT.NEXT
                    {
                        string[] baseParam;

                        if (ProtocolV1_0Utils.GetParams(baseString, COMMAND_BASE_NAME,
                                                        ProtocolV1_0Utils.DEFAULT.NEXT.NEXT.NEXT, out baseParam))
                        {
                            if (baseParam.Length == 6)
                            {
                                ProtocolDouble x, y;
                                int            maxProgress, teamId, progress, progressTeamId;
                                if (ProtocolDouble.TryParse(baseParam[0], out x) &&
                                    ProtocolDouble.TryParse(baseParam[1], out y) &&
                                    int.TryParse(baseParam[2], out maxProgress) &&
                                    int.TryParse(baseParam[3], out progress) &&
                                    int.TryParse(baseParam[4], out teamId) &&
                                    int.TryParse(baseParam[5], out progressTeamId))
                                {
                                    Base @base = new Base(x, y, maxProgress);
                                    @base.Progress       = progress;
                                    @base.TeamId         = teamId;
                                    @base.ProgressTeamId = progressTeamId;

                                    bases.Add(@base);
                                }
                            }
                        }
                    }
                    commandsMore[POSITION_IN_ROBOT_STATE_COMMAND] = bases.ToArray();
                }
                return(false);
            }
            public override bool IsDeserializeable(string s)
            {
                string[] rest;
                if (ProtocolV1_0Utils.GetParams(s, COMMAND_NAME, out rest))
                {
                    if (rest.Length == 10)
                    {
                        ProtocolDouble[] paramsPDoubles;
                        int[]            paramInts;
                        int[]            arrayIdsOfLifeRobots;

                        if (Parser.TryParse(new int[] { 0, 1, 3 }, rest, out paramsPDoubles) &&
                            Parser.TryParse(new int[] { 2, 4, 5, 6 }, rest, out paramInts) &&
                            ProtocolV1_0Utils.Deserialize(rest[7], out arrayIdsOfLifeRobots, ProtocolV1_0Utils.DEFAULT.NEXT)
                            )
                        {
                            EndLapCommandV1_0 endLapCommand;
                            EndLapCommandV1_0.Deserialize(rest[8], ProtocolV1_0Utils.DEFAULT.NEXT, out endLapCommand);

                            RobotStateCommandV1_0 robotStateCommand = new RobotStateCommandV1_0(paramsPDoubles[0], paramsPDoubles[1],
                                                                                                paramInts[0], paramsPDoubles[2],
                                                                                                paramInts[1], paramInts[2],
                                                                                                paramInts[3],
                                                                                                arrayIdsOfLifeRobots, endLapCommand);
                            string[] moreString;
                            if (ProtocolV1_0Utils.Deserialize(rest[9], out moreString, ProtocolV1_0Utils.DEFAULT.NEXT))
                            {
                                robotStateCommand.DeserializeMore(moreString, robotStateCommand.MORE, SUB_COMMAND_FACTORIES);
                            }
                            cache.Cached(s, robotStateCommand);
                            return(true);
                        }
                    }
                }
                return(false);
            }
Beispiel #22
0
 public override bool IsDeserializeable(string s)
 {
     if (ProtocolV1_0Utils.GetParams(s, NAME, out string[] rest))