예제 #1
0
        private List <SettingsError> FillMines(string[] data)
        {
            List <SettingsError> errors = new List <SettingsError>();

            for (int i = 3; i < data.Length; i++)
            {
                try
                {
                    var minePointStrings = data[i].Split(',');
                    var mx = int.Parse(minePointStrings[2]);
                    var my = int.Parse(minePointStrings[4]);
                    _Mines.Add(new Point {
                        X = mx, Y = my
                    });
                }

                catch
                {
                    var err = new SettingsError {
                        LineNumber = i + 1, File = this._File, Error = "Error in Mine setting Valid format is : Mine, x,#, y,#"
                    };
                    errors.Add(err);
                }
            }
            return(errors);
        }
예제 #2
0
        private SettingsError?FillStartPoint(string[] data)
        {
            SettingsError?err = null;

            try
            {
                var startPositionStrings = data[1].Split(',');
                var sx = int.Parse(startPositionStrings[2]);
                var sy = int.Parse(startPositionStrings[4]);
                StartPoint = new Point {
                    X = sx, Y = sy
                };

                var dir = startPositionStrings[6].Trim();
                if (dir.ToLower() == Direction.North.ToString().ToLower())
                {
                    Direction = Direction.North;
                }
                else if (dir.ToLower() == Direction.West.ToString().ToLower())
                {
                    Direction = Direction.West;
                }
                else if (dir.ToLower() == Direction.East.ToString().ToLower())
                {
                    Direction = Direction.East;
                }
                else if (dir.ToLower() == Direction.South.ToString().ToLower())
                {
                    Direction = Direction.South;
                }
                else
                {
                    throw new Exception("Invalid direction");
                }
            }
            catch
            {
                err = new SettingsError {
                    LineNumber = 2, File = this._File, Error = "Error in start point setting Valid format is : Starting position, x,# , y,# , dir,North,South,East,West"
                };
            }
            return(err);
        }
예제 #3
0
        private SettingsError?FillHeigtAndWidth(string[] data)
        {
            SettingsError?err = null;

            try
            {
                var sizeStrings = data[0].Split(',');
                var w           = int.Parse(sizeStrings[1]);
                this.BoardWithd = w;
                var h = int.Parse(sizeStrings[2]);
                this.BoardHeight = h;
            }
            catch
            {
                err = new SettingsError {
                    LineNumber = 1, File = this._File, Error = "Error in board size setting Valid format is : Size,#,#"
                };
            }
            return(err);
        }
예제 #4
0
        private SettingsError?FillExitPoint(string[] data)
        {
            SettingsError?err = null;

            try
            {
                var exitPointStrings = data[2].Split(',');
                var ex = int.Parse(exitPointStrings[2]);
                var ey = int.Parse(exitPointStrings[4]);
                ExitPoint = new Point {
                    X = ex, Y = ey
                };
            }
            catch
            {
                err = new SettingsError {
                    LineNumber = 3, File = this._File, Error = "Error in exit point setting Valid format is : Exit point, x,#, y,#"
                };
            }
            return(err);
        }