Beispiel #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            apikey = apikeyBox.Text;

            try
            {
                // Get static data
                Champions    = Get_Champions(apikey);
                ChampionsInv = Get_Champions(apikey, databyid: true);
                Masteries    = Get_Masteries(apikey);
                Runes        = Get_Runes(apikey);
                Items        = Get_Items(apikey);
                List <string> ver = Get_Version(apikey);
                verLabel.Text = ver.First();

                // Get images/initalize image boxes
                Get_Mastery_Images();
                initPictureBoxes();
            }
            catch (Exception error)
            {
                Show_Error(error.Message);
            }

            // Temp fix of placement errors

            // Add options to combobox
            selectFunctionComboBox.BeginUpdate();
            selectFunctionComboBox.Items.Add("Mastery Page By Summoner Champion");
            selectFunctionComboBox.Items.Add("Mastery Page By Summoner");
            selectFunctionComboBox.Items.Add("Rune Page By Summoner");
            selectFunctionComboBox.EndUpdate();
        }
Beispiel #2
0
        public static Champion[] getChampionList()
        {
            Champion[] champions;
            string     sURL;

            sURL = "https://"
                   + Constants.globalEndPoint
                   + Constants.championList;

            try
            {
                WebClient webClient = new WebClient();
                webClient.QueryString.Add("api_key", Constants.apikey);
                string result = webClient.DownloadString(sURL);

                ChampionListDto championlistdto = JsonConvert.DeserializeObject <ChampionListDto>(result);

                champions = championlistdto.data.Values.ToArray();
            }
            catch (System.Net.WebException)
            {
                return(null);
            }


            return(champions);
        }
Beispiel #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            apikey = apikeyBox.Text;

            try
            {
                // Get static data
                Champions = Get_Champions(apikey);
                ChampionsInv = Get_Champions(apikey, databyid: true);
                Masteries = Get_Masteries(apikey);
                Runes = Get_Runes(apikey);
                Items = Get_Items(apikey);
                List<string> ver = Get_Version(apikey);
                verLabel.Text = ver.First();

                // Get images/initalize image boxes
                Get_Mastery_Images();
                initPictureBoxes();
            }
            catch (Exception error)
            {
                Show_Error(error.Message);
            }

            // Temp fix of placement errors

            // Add options to combobox
            selectFunctionComboBox.BeginUpdate();
            selectFunctionComboBox.Items.Add("Mastery Page By Summoner Champion");
            selectFunctionComboBox.Items.Add("Mastery Page By Summoner");
            selectFunctionComboBox.Items.Add("Rune Page By Summoner");
            selectFunctionComboBox.EndUpdate();
        }
Beispiel #4
0
        //Retrieve all champions
        public async Task <ChampionListDto> GetChampionsAsync()
        {
            ChampionListDto champions = null;
            string          request   = "/lol/platform/" + C_VERSION + "/champions";
            string          response  = await GET(request);

            champions = JsonConvert.DeserializeObject <ChampionListDto>(response);
            return(champions);
        }
Beispiel #5
0
 protected override bool NeedToUpdate()
 {
     try
     {
         var oldVersion = ChampionList.version;
         ChampionList = Request.GetStaticData("na/v1.2/champion?champData=image&locale=" + Request.ApiLanguage, typeof(ChampionListDto), DirectoryPath + InfoFile);
         return(ChampionList.version.CompareTo(oldVersion) != 0);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Beispiel #6
0
        private async void buttonFilterChampion_Click(object sender, RoutedEventArgs e)
        {
            buttonFilterChampion.IsEnabled = false;
            List <string> filters = new List <string>();

            if (filterChampionAssassin.IsChecked == true)
            {
                filters.Add("Assassin");
            }
            if (filterChampionFigther.IsChecked == true)
            {
                filters.Add("Fighter");
            }
            if (filterChampionMarksman.IsChecked == true)
            {
                filters.Add("Marksman");
            }
            if (filterChampionTank.IsChecked == true)
            {
                filters.Add("Tank");
            }
            if (filterChampionSupport.IsChecked == true)
            {
                filters.Add("Support");
            }
            if (filterChampionMage.IsChecked == true)
            {
                filters.Add("Mage");
            }
            if (ChampionListDto.AllChampions == null)
            {
                await ChampionListDto.LoadAllChampions();
            }
            ChampionsList.Items.Clear();
            foreach (ChampionDto champion in ChampionListDto.AllChampions)
            {
                foreach (string tag in champion.Tags)
                {
                    if (filters.Contains(tag))
                    {
                        ChampionSelected item = new ChampionSelected();
                        item.Champion = champion;
                        item.Tap     += item_Tap;
                        ChampionsList.Items.Add(item);
                        break;
                    }
                }
            }
            buttonFilterChampion.IsEnabled = true;
        }
Beispiel #7
0
        // ---------------------------------------------------------

        private async Task <List <ChampionDto> > GetMatchingChampions(string name)
        {
            name = name.ToLower();
            ChampionListDto championList = await this._riotStaticData.GetChampionsAsync();

            List <ChampionDto> matches = new List <ChampionDto>();

            if (championList != null)
            {
                matches = championList.Data.Values
                          .Where(x => x.Name.ToLower().Contains(name) || StripName(x.Name).ToLower().Contains(name)).ToList();
            }
            matches.Sort((a, b) => a.Name.CompareTo(b.Name));
            return(matches);
        }
Beispiel #8
0
        public static ChampionDto ReadChampionFromStaticFile(string name)
        {
            if (StaticFileExists(StaticData.Champions))
            {
                ChampionListDto champs = ReadFromStaticFile <ChampionListDto>(StaticData.Champions);

                foreach (ChampionDto champ in champs.data.Values)
                {
                    if (champ.name == name)
                    {
                        return(champ);
                    }
                }
            }
            return(new ChampionDto());
        }
Beispiel #9
0
        public static List <Champion> ToChampions(this ChampionListDto champListDto)
        {
            var champions = new List <Champion>();

            foreach (KeyValuePair <string, ChampionDto> entry in champListDto.Data)
            {
                var champ = entry.Value;
                champions.Add(new Champion()
                {
                    Id             = champ.Id,
                    Name           = champ.Name,
                    SearchName     = Regex.Replace(champ.Name.ToUpper(), @"[^\w\.@-]", ""), //strip special characters
                    Title          = champ.Title,
                    SquareImageUrl = string.Format(ServiceConstants.ChampionSquareImageUrl, champ.Image.Full),
                    Skins          = GetSkins(champ.Key, champ.Name, champ.Skins)
                });
            }
            return(champions.OrderBy(c => c.Name).ToList());
        }
Beispiel #10
0
 private async void buttonFilterFreeWeek_Click(object sender, RoutedEventArgs e)
 {
     buttonFilterFreeWeek.IsEnabled = false;
     if (ChampionListDto.AllChampions == null)
     {
         await ChampionListDto.LoadAllChampions();
     }
     ChampionsList.Items.Clear();
     foreach (ChampionDto champion in ChampionListDto.AllChampions)
     {
         if (champion.FreeToPlay)
         {
             ChampionSelected item = new ChampionSelected();
             item.Champion = champion;
             item.Tap     += item_Tap;
             ChampionsList.Items.Add(item);
         }
     }
     buttonFilterFreeWeek.IsEnabled = true;
 }
Beispiel #11
0
    private IEnumerator SetupChampions()
    {
        Debug.Log("requesting " + championRestUrl);
        WWW www = new WWW(championRestUrl);

        yield return(www);

        if (www.error != null)
        {
            error = true;
        }
        else
        {
            //ChampionListDto champions = JsonUtility.FromJson<ChampionListDto>(www.text);
            var N = SimpleJSON.JSON.Parse(www.text);

            ChampionListDto champions = new ChampionListDto();
            champions.Type    = N["type"];
            champions.Version = N["version"];

            SimpleJSON.JSONNode data = N["data"];
            champions.Data = new ChampionDto[data.Count];
            for (int i = 0; i < data.Count; i++)
            {
                champions.Data[i]       = new ChampionDto();
                champions.Data[i].Id    = data[i]["id"].AsInt;
                champions.Data[i].Key   = data[i]["key"];
                champions.Data[i].Name  = data[i]["name"];
                champions.Data[i].Title = data[i]["title"];
                champions.Data[i].Tags  = new string[data[i]["tags"].Count];
                for (int j = 0; j < data[i]["tags"].Count; j++)
                {
                    champions.Data[i].Tags[j] = data[i]["tags"][j];
                }
            }

            GameWorld.Instance.Champions = champions;
        }
    }
Beispiel #12
0
 protected override void ReadInfo()
 {
     ChampionList = Request.ReadFromFile(DirectoryPath + InfoFile, typeof(ChampionListDto));
     DecodeData();
 }
Beispiel #13
0
 public override bool UpdateInfo()
 {
     ChampionList = Request.GetStaticData("na/v1.2/champion?champData=image&locale=" + Request.ApiLanguage, typeof(ChampionListDto), DirectoryPath + InfoFile);
     return(ChampionList != null);
 }