Beispiel #1
0
        private bool StoreRiotRuneData(RuneListStatic runes)
        {
            bool success = false;

            try
            {
                string file = string.Format(@"{0}\Data\Runes\getRunes.{1}.bin", PublicStaticVariables.thisAppDataDir, runes.Version);
                string dir  = string.Format(@"{0}\Data\Runes", PublicStaticVariables.thisAppDataDir);

                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }

                using (FileStream fs = File.Open(file, FileMode.Create))
                    using (StreamWriter sw = new StreamWriter(fs))
                        using (JsonWriter jw = new JsonTextWriter(sw))
                        {
                            jw.Formatting = Formatting.Indented;

                            JsonSerializer serializer = new JsonSerializer();
                            serializer.Serialize(jw, runes);
                        }
                success = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                success = false;
            }
            return(success);
        }
Beispiel #2
0
        public bool DownloadListOfRunes(string inputVersion = null)
        {
            bool success = false;

            // Get all Items for NA
            try
            {
                // Setup RiotApi
                var staticApi = StaticRiotApi.GetInstance(Resources.App.ApiKey);

                //Get all Items
                if (inputVersion == null)
                {
                    runes = staticApi.GetRunes(RiotSharp.Region.na, RuneData.all);
                }
                else
                {
                    runes = staticApi.GetRunes(RiotSharp.Region.na, inputVersion, RuneData.all);
                }

                StoreRiotRuneData(runes);

                SortRiotRuneData(runes);

                success = true;
            }
            catch (Exception ex)
            {
                //TODO: correctly handle errors rather than this
                MessageBox.Show(ex.ToString());
                success = false;
            }
            return(success);
        }
Beispiel #3
0
        internal bool LoadRiotRuneData(string version)
        {
            bool success = false;

            try
            {
                string file;
                file = string.Format(@"{0}\Data\Runes\getRunes.{1}.bin", PublicStaticVariables.thisAppDataDir, version);


                string dir = string.Format(@"{0}\Data\Runes", PublicStaticVariables.thisAppDataDir);

                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }

                StreamReader re = new StreamReader(file);
                try
                {
                    JsonTextReader reader = new JsonTextReader(re);

                    JsonSerializer se         = new JsonSerializer();
                    object         parsedData = se.Deserialize(reader);

                    RuneListStatic runes = JsonConvert.DeserializeObject <RuneListStatic>(parsedData.ToString());

                    SortRiotRuneData(runes);

                    success = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                    success = false;
                }
                finally
                {
                    re.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                success = false;
            }
            return(success);
        }
Beispiel #4
0
        private void SortRiotRuneData(RuneListStatic runes)
        {
            //This was the only way I could seem to filter out the random rare runes
            RuneListStatic runesThinned = new RuneListStatic();

            runesThinned.Version   = runes.Version;
            runesThinned.BasicData = runes.BasicData;
            runesThinned.Type      = runes.Type;
            runesThinned.Runes     = new Dictionary <int, RuneStatic>();
            foreach (KeyValuePair <int, RuneStatic> iRune in runes.Runes)
            {
                string iName = iRune.Value.Image.Full;
                if (iName.StartsWith("r") || iName.StartsWith("y") || iName.StartsWith("b"))
                {
                    runesThinned.Runes.Add(iRune.Key, iRune.Value);
                }
            }
            this.runes = runesThinned;

            //Sort
            runeSorted = new List <KeyValuePair <int, RuneStatic> >();
            foreach (RuneStatic runeS in this.runes.Runes.Values)
            {
                runeSorted.Add(new KeyValuePair <int, RuneStatic>(runeS.Id, runeS));
            }
            runeSorted.Sort((firstPair, nextPair) =>
            {
                return(firstPair.Key.CompareTo(nextPair.Key));
            }
                            );

            //Temp function to generate list keyvalue pair used in runeStatic
            //GenerateRuneDictionaryList(runeSorted);

            this.version = runes.Version;
        }
 public RuneListStaticWrapper(RuneListStatic runes, Language language, string version)
 {
     RuneListStatic = runes;
     Language       = language;
     Version        = version;
 }
Beispiel #6
0
        public async void RetrieveRunesDataNoneTest()
        {
            RuneListStatic runesData = await creepScore.RetrieveRunesData(CreepScore.Region.NA, StaticDataConstants.RuneListData.None);

            Assert.Equal("rune", runesData.type);
        }
 public RuneListStaticWrapper(RuneListStatic runes, Language language, RuneData runeData)
 {
     RuneListStatic = runes;
     Language       = language;
     RuneData       = runeData;
 }
 public RuneListStaticWrapper(RuneListStatic runes, Language language, RuneData runeData)
 {
     RuneListStatic = runes;
     Language = language;
     RuneData = runeData;
 }