public string CreateMaze(JObject payload) { if (payload == null) { throw new Exception("Cannot call function without payload"); } try { string response = RestHandler.Request(new RequestUrl(RequestUrl.RestAction.CreateMaze), payload); _mazeId = JObject.Parse(response).Value <string>("maze_id"); var createReturn = JObject.Parse(response); return(createReturn.ToString()); } catch (WebException e) { if (e.Message == "Only ponies can play") { throw new InvalidPlayerNameException(e.Message); } throw new WebException(e.Message); } }
public string RetrieveMaze() { if (string.IsNullOrEmpty(_mazeId)) { throw new Exception("Create a maze first!"); } return(RestHandler.Request(new RequestUrl(RequestUrl.RestAction.GetMaze, _mazeId))); }
public string Move(string direction) { if (string.IsNullOrEmpty(_mazeId)) { throw new Exception("Create a maze first!"); } var directionPayload = new JObject { { "direction", direction } }; string response = RestHandler.Request(new RequestUrl(RequestUrl.RestAction.NextMove, _mazeId), directionPayload); return(ParseMoveResult(response)); }