예제 #1
0
        public GameData MarkCell(string userId, string gameId, int row, int col, CellMarkType mark)
        {
            this.CreateClient();

            string resource = "minesweeper/users/{user_id}/games/{game_id}/mark";
            var    req      = new RestRequest(resource, Method.PUT, DataFormat.Json);

            req.AddParameter("user_id", userId, ParameterType.UrlSegment);
            req.AddParameter("game_id", gameId, ParameterType.UrlSegment);

            var args = new MarkCellRequest()
            {
                Col = col, Row = row
            };

            args.Flag     = mark == CellMarkType.CellMarkType_Flag;
            args.None     = mark == CellMarkType.CellMarkType_None;
            args.Question = mark == CellMarkType.CellMarkType_Question;
            string body = Newtonsoft.Json.JsonConvert.SerializeObject(args);

            req.AddJsonBody(body);


            IRestResponse res = this.Client.Put(req);

            if (res.IsSuccessful)
            {
                var output = Newtonsoft.Json.JsonConvert.DeserializeObject <GameData>(res.Content);
                return(output);
            }
            else
            {
                ErrorResponse err = Newtonsoft.Json.JsonConvert.DeserializeObject <ErrorResponse>(res.Content);
                throw new Exception(err.Message);
            }
        }
 public GameData MarkCell(string userId, string gameId, int row, int col, CellMarkType mark)
 {
     return(this.ActiveGame);
 }