Esempio n. 1
0
 private static void DownloadAllGodSkinsForStoredGods(JsonDownloader d)
 {
     foreach (var godId in new DataStore().ReadGods().Select(x => x.Id))
     {
         d.Update(filenameOrRelPath: $"godskins/godskins-{godId}.json", c => c.GetGodSkinsAsync(godId));
     }
 }
Esempio n. 2
0
    public static void Main()
    {
        var menu = new MenuLogic();

        menu.Run();

        if (menu.SendPing || menu.TestAuth || menu.DownloadData)
        {
            using var c = new RequestClient();
            if (menu.SendPing)
            {
                Console.WriteLine(c.SendPingAsync().Result);
            }
            if (menu.TestAuth || menu.DownloadData)
            {
                var auth = AuthConfigReader.Read();
                c.Configure(auth.DevId, auth.AuthKey);
                if (menu.TestAuth)
                {
                    Console.WriteLine(c.TestSessionAsync().Result);
                }
                if (menu.DownloadData)
                {
                    var downloader = new JsonDownloader(c, "data");
                    DownloadData(downloader);
                }
            }
        }
        if (menu.GenerateData)
        {
            GenerateGodsWithSkinsFromStore();
        }
        if (menu.DownloadIcons)
        {
            GodIcons.DownloadGodIcons("img/godicon");
        }
        if (menu.CheckRemoteImages)
        {
            CheckRemoteImage().Wait();
        }
        if (menu.CombineIcons)
        {
            var files = new DirectoryInfo("img/godicon").EnumerateFiles("*.jpg").OrderBy(x => x.Name);
            GodIcons.GenerateGodIconSprites(files, "img/godicons");
        }
        if (menu.GenerateHtml)
        {
            Console.WriteLine("Generating HTML...");
            GodsHtml.GenerateGodsHtml(targetFile: "smitegods.html", new DataStore().ReadGods() !, GodIcons.ReadSpriteData("img/godicons"));
            GodsSkinsHtml.GenerateGodsHtml("god-skins.html", new DataStore().ReadGodsWithSkins() !);

            GodSkinThemeHtml.Generate("god-skin-themes.html", new DataStore().ReadGodsWithSkins() !, new DataStore().ReadGodSkinThemes());

            ItemsHtml.Generate(targetFile: "smiteitems.html", items: new DataStore().ReadItems() !);
        }

        Console.WriteLine("Done. Waiting for ENTER to exit…");
        Console.ReadLine();
    }
Esempio n. 3
0
    private static void DownloadData(JsonDownloader downloader)
    {
        downloader.Update("gods.json", c => c.GetGodsAsync());

        DownloadAllGodSkinsForStoredGods(downloader);

        downloader.Update(filenameOrRelPath: "items.json", c => c.GetItemsAsync());
    }
Esempio n. 4
0
 public void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Debug.Assert(!instance);
     }
 }
Esempio n. 5
0
        private string GetIP()
        {
            JToken IPRequest = JsonDownloader.Get <JToken>("http://ll.leagueoflegends.com/services/connection_info");

            if (IPRequest == null || IPRequest["ip_address"] == null)
            {
                return("127.0.0.1");
            }

            Form1.Log("IP Address = " + (string)IPRequest["ip_address"]);
            return((string)IPRequest["ip_address"]);
        }
Esempio n. 6
0
    private static void DownloadPlayer(RequestClient c, int playerId, string dataDirPath)
    {
        var playerPath = Path.Combine(dataDirPath, "player", playerId.ToString(provider: null));
        var d          = new JsonDownloader(c, playerPath);

        d.Update(filenameOrRelPath: "player.json", c => c.GetPlayerAsync(playerId));
        d.Update(filenameOrRelPath: "godranks.json", c => c.GetPlayerGodRanksAsync(playerId));
        d.Update(filenameOrRelPath: "friends.json", c => c.GetPlayerFriendsAsync(playerId));
        d.Update(filenameOrRelPath: "achievements.json", c => c.GetPlayerAchievementsAsync(playerId));
        d.Update(filenameOrRelPath: "status.json", c => c.GetPlayerStatusAsync(playerId));
        d.Update(filenameOrRelPath: "matchhistory.json", c => c.GetPlayerMatchHistoryAsync(playerId));
    }
Esempio n. 7
0
        public async Task <ResponseContainer <T> > Get(DateTime date)
        {
            string week = date.Month.ToString();

            if (week.Length == 1)
            {
                week = $"0{week}";
            }

            var year = date.Year;

            var url = $"{BreweryDbClient.BaseAddress}feature/{year}-{week}?key={BreweryDbClient.ApplicationKey}&format=json";

            return(await JsonDownloader.DownloadSerializedJsonDataAsync <ResponseContainer <T> >(url));
        }
Esempio n. 8
0
        public async Task <ResponseContainer <List <T> > > Get(NameValueCollection nvc)
        {
            var parameterBuilder = new StringBuilder();

            foreach (var parameter in nvc)
            {
                parameterBuilder.Append(parameter.Key);
                parameterBuilder.Append("=");
                parameterBuilder.Append(parameter.Value);
                parameterBuilder.Append("&");
            }

            var url = $"{BreweryDbClient.BaseAddress}beers?{parameterBuilder}key={BreweryDbClient.ApplicationKey}&format=json";

            return(await JsonDownloader.DownloadSerializedJsonDataAsync <ResponseContainer <List <T> > >(url));
        }
Esempio n. 9
0
        public async Task <ResponseContainer <List <T> > > GetAll(int pageNumber)
        {
            var url = $"{BreweryDbClient.BaseAddress}features?p={pageNumber}&key={BreweryDbClient.ApplicationKey}&format=json";

            return(await JsonDownloader.DownloadSerializedJsonDataAsync <ResponseContainer <List <T> > >(url));
        }
Esempio n. 10
0
        public async Task <ResponseContainer <T> > ThisWeeks()
        {
            var url = $"{BreweryDbClient.BaseAddress}featured?key={BreweryDbClient.ApplicationKey}&format=json";

            return(await JsonDownloader.DownloadSerializedJsonDataAsync <ResponseContainer <T> >(url));
        }
Esempio n. 11
0
        private string GetAuthCode(string Username, string Password, string LoginQueue)
        {
            NameValueCollection query = new NameValueCollection();

            query.Add("payload", string.Format("user={0},password={1}", Username, Password));
            JToken login = JsonDownloader.Post <JToken>(LoginQueue + "login-queue/rest/queue/authenticate", query);

            string Status = (string)login["status"];

            if (Status == "FAILED")
            {
                throw new Exception("Error logging in: " + (string)login["reason"]);
            }

            if (Status == "LOGIN")
            {
                Form1.Log("Auth Token = " + login["token"]);
                return((string)login["token"]);
            }

            int    node  = (int)login["node"];
            string champ = (string)login["champ"];
            int    rate  = (int)login["rate"];
            int    delay = (int)login["delay"];

            int id  = 0;
            int cur = 0;

            JArray tickers = (JArray)login["tickers"];

            foreach (JToken token in tickers)
            {
                int tnode = (int)token["node"];
                if (tnode != node)
                {
                    continue;
                }

                id  = (int)token["id"];
                cur = (int)token["current"];
                break;
            }

            Form1.Log("In login queue for " + Region + ", #" + (id - cur) + " in line");

            while (id - cur > rate)
            {
                Thread.Sleep(delay);
                JToken result = JsonDownloader.Get <JToken>(LoginQueue + "login-queue/rest/queue/ticker/" + champ);
                if (result == null)
                {
                    continue;
                }

                cur = Convert.ToInt32((string)result[node.ToString()], 16);
                Form1.Log("In login queue for " + Region + ", #" + (int)Math.Max(1, id - cur) + " in line");
            }

            JToken login2 = JsonDownloader.Get <JToken>(LoginQueue + "login-queue/rest/queue/authToken/" + Username.ToLower());

            while (login2 == null || login2["token"] == null)
            {
                Thread.Sleep(delay / 10);
                login2 = JsonDownloader.Get <JToken>(LoginQueue + "login-queue/rest/queue/authToken/" + Username.ToLower());
            }

            Form1.Log("Auth Token = " + login2["token"]);
            return((string)login2["token"]);
        }
        public async Task <ResponseContainer <T> > Get(string id)
        {
            var url = $"{BreweryDbClient.BaseAddress}adjunct/{id}?key={BreweryDbClient.ApplicationKey}&format=json";

            return(await JsonDownloader.DownloadSerializedJsonDataAsync <ResponseContainer <T> >(url));
        }
Esempio n. 13
0
        public async Task <ResponseContainer <List <T> > > Search(string keyword)
        {
            var url = $"{BreweryDbClient.BaseAddress}search?q={keyword}&type=beer&withBreweries=y&withSocialAccounts=y&withGuilds=y&withLocations=y&withAlternateNames=y&hasLabels=y&withIngredients=y&key={BreweryDbClient.ApplicationKey}&format=json";

            return(await JsonDownloader.DownloadSerializedJsonDataAsync <ResponseContainer <List <T> > >(url));
        }
Esempio n. 14
0
        public async Task <ResponseContainer <List <T> > > GetAll()
        {
            var url = $"{BreweryDbClient.BaseAddress}socialsites?key={BreweryDbClient.ApplicationKey}&format=json";

            return(await JsonDownloader.DownloadSerializedJsonDataAsync <ResponseContainer <List <T> > >(url));
        }
Esempio n. 15
0
        public async Task <ResponseContainer <List <T> > > GetBeerListWithFilter(string filterStr)
        {
            var url = $"{BreweryDbAPICall.BaseAddress}beers?{filterStr}&key={BreweryDbAPICall.ApplicationKey}&format=json";

            return(await JsonDownloader.DownloadSerializedJsonDataAsync <ResponseContainer <List <T> > >(url));
        }
Esempio n. 16
0
        public async Task <ResponseContainer <T> > Get(string id)
        {
            var url = $"{BreweryDbAPICall.BaseAddress}beer/{id}?withBreweries=y&key={BreweryDbAPICall.ApplicationKey}&format=json";

            return(await JsonDownloader.DownloadSerializedJsonDataAsync <ResponseContainer <T> >(url));
        }