internal static void RunCorrections(MasteryListStatic masteries) { var keys = new List <int>(masteries.Masteries.Keys); foreach (int key in keys) { MasteryStatic temp = masteries.Masteries[key]; temp.StatsList = new List <StatsStatic>(); if (temp.Name.Contains("Legendary Guardian")) //Filter out legendary guardian { foreach (string sDesc in temp.Description) { temp.StatsList.Add(new StatsStatic()); //Generate blank stats for the filtered out masteries } } else { RunListOfCorrections(temp); } if (temp.StatsList.Count == 0) { temp.StatsList.Add(new StatsStatic()); } } }
private bool StoreRiotMasteryData(MasteryListStatic masteries) { bool success = false; try { string file = string.Format(@"{0}\Data\Masteries\getMasteries.{1}.bin", PublicStaticVariables.thisAppDataDir, masteries.Version); string dir = string.Format(@"{0}\Data\Masteries", 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, masteries); } success = true; } catch (Exception ex) { MessageBox.Show(ex.ToString()); success = false; } return(success); }
internal bool LoadRiotMasteryData(string version) { bool success = false; try { string file; file = string.Format(@"{0}\Data\Masteries\getMasteries.{1}.bin", PublicStaticVariables.thisAppDataDir, version); string dir = string.Format(@"{0}\Data\Masteries", 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); masteries = JsonConvert.DeserializeObject <MasteryListStatic>(parsedData.ToString()); this.version = masteries.Version; MasteryDataCorrections.RunCorrections(masteries); 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); }
public bool DownloadListOfMasteries(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) { masteries = staticApi.GetMasteries(RiotSharp.Region.na, MasteryData.all); } else { masteries = staticApi.GetMasteries(RiotSharp.Region.na, inputVersion, MasteryData.all); } version = masteries.Version; StoreRiotMasteryData(masteries); MasteryDataCorrections.RunCorrections(masteries); success = true; } catch (Exception ex) { //TODO: correctly handle errors rather than this MessageBox.Show(ex.ToString()); success = false; } return(success); }
public MasteryListStaticWrapper(MasteryListStatic masteries, Language language, string version) { MasteryListStatic = masteries; Language = language; Version = version; }
public async void RetrieveMasteriesDataTest() { MasteryListStatic masteriesData = await creepScore.RetrieveMasteriesData(CreepScore.Region.NA, StaticDataConstants.MasteryListData.All); Assert.NotNull(masteriesData.data); }
public async void RetrieveMasteriesDataNoneTest() { MasteryListStatic masteriesData = await creepScore.RetrieveMasteriesData(CreepScore.Region.NA, StaticDataConstants.MasteryListData.None); Assert.Equal("mastery", masteriesData.type); }
public MasteryListStaticWrapper(MasteryListStatic masteries, Language language, MasteryData masteryData) { MasteryListStatic = masteries; Language = language; MasteryData = masteryData; }