// GET: pony-challenge/Maze/GUID public GameState MoveCharacters(Guid mazeId, MoveCharactersInMazeModel moveModel) { string direction = moveModel.Direction; try { if (mazeId != null && mazeId != Guid.Empty) { Maze maze = MemoryCacher.GetMazeFromCache(mazeId); CellState[] mazeCells = maze.GetCells(); int ponyLocation = maze.GetPonyId(); int mazeWidth = maze.GetMazeWidth(); int mazeHeight = maze.GetMazeHeight(); StateResult result = MazeHelper.MoveCharacter(maze, direction, CellState.Pony); if (result == StateResult.MoveAccepted) { if (DifficultyManager.CheckIfCurrentDifficultyIsAdaptible(maze)) { MemoryCacher.AppendDomokunNextMove(mazeId, direction); } string DomokunDirection = DifficultyManager.GetDomokunDirection(maze); result = MazeHelper.MoveCharacter(maze, DomokunDirection, CellState.Domokun); } MemoryCacher.UpdateMazeInCache(mazeId, maze); return(new GameState { State = State.Active, StateResult = result }); } else { HttpResponseException exception = CreateResponseException(HttpStatusCode.BadRequest, ERRORMESSAGE_MAZEID_INVALID); throw exception; } } catch (Exception ex) { HttpResponseException exception = CreateResponseException(HttpStatusCode.InternalServerError, ex.Message); throw exception; } }