Beispiel #1
0
        public Maze.State GetCurState(string token)
        {
            var pro = _context.MazeProcesses.FirstOrDefault(p => string.Equals(p.Token, token));

            if (pro != null)
            {
                return new Maze.State {
                           walls = Maze.Map[pro.x][pro.y], x = pro.x, y = pro.y
                }
            }
            ;
            else
            {
                MazeProcess process = new MazeProcess
                {
                    Token = token,
                    x     = 0,
                    y     = 0
                };

                _context.MazeProcesses.Add(process);
                _context.SaveChanges();
                return(new Maze.State {
                    walls = Maze.Map[0][0], x = 0, y = 0
                });
            }
        }
Beispiel #2
0
        public int Reset(string token)
        {
            var pro = _context.MazeProcesses.FirstOrDefault(p => string.Equals(p.Token, token));

            if (pro != null)
            {
                pro.x = 0;
                pro.y = 0;
                _context.SaveChanges();
                return(Maze.Map[0][0]);
            }
            else
            {
                MazeProcess process = new MazeProcess
                {
                    Token = token,
                    x     = 0,
                    y     = 0
                };
                _context.MazeProcesses.Add(process);
                _context.SaveChanges();
                return(Maze.Map[0][0]);
            }
        }