Exemplo n.º 1
0
        public async Task <bool> GetGardenStats()
        {
            Uri url = new Uri(Url + "garden/get/" + Data["token"]);

            try
            {
                Client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                var authenticationResponse = await Client.GetStringAsync(url);

                JObject json = JObject.Parse(authenticationResponse);
                if (json.Root["success"].ToString() == "True")
                {
                    garden = new Garden
                    {
                        Fight     = int.Parse(json.Root["garden"]["fights"].ToString()),
                        Opponents = new List <Leek>()
                    };
                    Console.WriteLine("[GARDEN][STATS]: Success | " + garden.Fight.ToString() + " remaining fights");
                    return(true);
                }
                else
                {
                    Console.WriteLine("[GARDEN][STATS]: FAILED");
                    return(false);
                }
            }
            catch (Exception)
            {
                Console.WriteLine("[GARDEN][STATS]: FAILED");
                return(false);
            }
        }
Exemplo n.º 2
0
 private void Init()
 {
     player   = new Farmer();
     _handler = new HttpClientHandler();
     _handler.CookieContainer = _cookiesContainer;
     Client  = new HttpClient(_handler);
     Cookies = new List <Cookie>();
     Data    = new Dictionary <string, string>();
     garden  = new Garden();
 }