Esempio n. 1
0
        private ShardInfo GetShardInfo(ShardType shardType, CookieContainer cookie)
        {
            Account.CheckAuth();
            var uri     = new Uri(string.Format("{0}/api/v2/dispatcher?{2}={1}", CloudDomain, Account.AuthToken, "token"));
            var request = (HttpWebRequest)WebRequest.Create(uri.OriginalString);

            request.CookieContainer = Account.Cookies;
            request.Method          = "GET";
            request.ContentType     = DefaultRequestType;
            request.Accept          = "application/json";
            request.UserAgent       = UserAgent;
            using (var response = (HttpWebResponse)request.GetResponse())
            {
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    cookie = request.CookieContainer;
                    var responseText = ReadResponseAsText(response);

                    var shardTypeDescription = shardType.GetType().GetField(shardType.ToString()).GetCustomAttribute <DescriptionAttribute>(false).Description;

                    var shardResponse = Newtonsoft.Json.JsonConvert.DeserializeObject <ShardResponse>(responseText);
                    var shardElement  = shardResponse.body[shardTypeDescription][0];
                    return(new ShardInfo()
                    {
                        Type = shardType, Url = shardElement.url, Count = int.Parse(shardElement.count)
                    });
                }
                else
                {
                    throw new Exception($"{response.StatusCode}: {response.StatusDescription}");
                }
            }
        }
Esempio n. 2
0
 public ShadowlordShard(ShardType shardType, int quantity, string longName, string equipMessage) : base(quantity, longName, longName, SHARD_SPRITE)
 {
     Debug.WriteLine("Shard: " + shardType.ToString());
     Shard        = shardType;
     EquipMessage = equipMessage;
 }