Ejemplo n.º 1
0
    /// <summary>
    /// The coroutine method used to fetch the champion database.
    /// </summary>
    /// <param name="region"></param>
    /// <param name="champData"></param>
    /// <returns></returns>
    private IEnumerator InitializeChampionDatabase(Region.RegionEnum region, ChampData champData)
    {
        string url = "";

        if (Application.isWebPlayer)
        {
            url = "UrfQuest.php?apiCall=" + RiotAPIConstants.CHAMPIONv1_2(region, champData);
        }
        else
        {
            url = RiotAPIConstants.CHAMPIONv1_2(region, champData);
        }
        Fetch fetch;

        if (RiotAPIConstants.READ_FROM_FILES == true)
        {
            fetch = new Fetch(InitializationSuccess, null, ChampionDB.fromJSON);
        }
        else
        {
            fetch = new Fetch(InitializationSuccess, InitializationFailure, url, ChampionDB.fromJSON);
        }

        return(fetch.WaitForUrlData());
    }
Ejemplo n.º 2
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="date"></param>
    /// <returns></returns>
    public IEnumerator GetSummonerInformation()
    {
        string url = "";

        string[] summonerNames = { summonerName.text };

        Region.RegionEnum region = (Region.RegionEnum)Enum.Parse(typeof(Region.RegionEnum), regionDropDown.options[regionDropDown.value].text.ToLower());

        if (Application.isWebPlayer)
        {
            url = "UrfQuest.php?apiCall=" + RiotAPIConstants.SUMMONERIDS_FROM_SUMMONER_NAME(summonerNames, region);
        }
        else
        {
            url = RiotAPIConstants.SUMMONERIDS_FROM_SUMMONER_NAME(summonerNames, region);
        }

        Fetch fetch = new Fetch(GetSummonerInformationSuccess,
                                GetSummonerInformationFailure,
                                url,
                                Summoner.fromJSON
                                );

        return(fetch.WaitForUrlData());
    }
Ejemplo n.º 3
0
    /// <summary>
    /// The API prefix for the majority of the API calls.
    /// </summary>
    private static String API_Prefix(Region.RegionEnum region, bool isChampionMastery = false)
    {
        string url = "https://" + region.ToString() + ".api.pvp.net/";

        if (!isChampionMastery)
        {
            url += "api/lol/";
        }

        return(url);
    }
Ejemplo n.º 4
0
    /// <summary>
    /// Returns the API Challenge match list Json String
    /// </summary>
    /// <param name="region">the region we want the matches from</param>
    /// <param name="beginDate"> the begin date we want to look at. Has to be either 0 or 5 minute intervals with no seconds.</param>
    /// <returns> API Challenge match list Json string</returns>
    public static String API_CHALLENGE_MATCH_LIST(Region.RegionEnum region, long beginDate)
    {
        long remainder = (beginDate % 100);

        if (remainder != 0)
        {
            beginDate -= remainder;
        }

        UnityEngine.Debug.Log(beginDate);

        // https;//na.api.pvp.net//api/lol/{region}/v4.1/game/ids?beginDate={beginDate}&api_key=API_KEY_SUFFIX
        return(API_Prefix(region) + region.ToString() + "/" + "v4.1/game/ids?beginDate=" + beginDate + "&api_key=" + API_KEY_SUFFIX);
    }
Ejemplo n.º 5
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="summonerNames"></param>
    /// <param name="region"></param>
    /// <returns></returns>
    public static String SUMMONERIDS_FROM_SUMMONER_NAME(string [] summonerNames, Region.RegionEnum region = Region.RegionEnum.na, string version = "1.4")
    {
        String urlString = API_Prefix(region) + region.ToString() + "/v" + version + "/summoner/by-name/";


        for (int i = 0; i < summonerNames.Length; ++i)
        {
            urlString += summonerNames[i];

            if (!i.Equals(summonerNames.Length - 1))
            {
                urlString += ",";
            }
        }

        return(urlString + "?api_key=" + API_KEY_SUFFIX);
    }
Ejemplo n.º 6
0
    public static PlatformID GetPlatformID(Region.RegionEnum region)
    {
        int regionInt = (int)region;

        return(regionToPlatformArray[regionInt]);
    }
Ejemplo n.º 7
0
 /// <summary>
 /// Return a match with a specified ID in a specified region.
 /// </summary>
 /// <param name="region">the region you wish to retrieve from. </param>
 /// <param name="matchID">the match id of the match you wish to retrieve. </param>
 /// <returns>a matches Json string</returns>
 public static String MATCHv2_2(Region.RegionEnum region, long matchID)
 {
     // "/api/lol/{region}/v2.2/match/{matchID}?api_key=API_KEY_SUFFIX"
     return(API_Prefix(region) + region.ToString() + "/" + "v2.2/match/" + matchID + "?api_key=" + API_KEY_SUFFIX);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Returns a Champions data Json string. The results depend upon what type of data you are requesting about the champion (See: ChampData)
 /// </summary>
 /// <param name="region"> the region you are looking to retrieve from </param>
 /// <param name="champData">the information about the champion you wish to retrieve. (See: ChampData)</param>
 /// <returns>Champion data Json string</returns>
 public static String CHAMPIONv1_2(Region.RegionEnum region, ChampData champData)
 {
     // https;//global.api.pvp.net/api/lol/static-data/na/v1.2/champion?champData=stats&api_key=API_KEY_SUFFIX
     return(Global_API_Prefix + "static-data/" + region.ToString() + "/" + "v1.2/champion?champData=" + champData.ToString() + "&api_key=" + API_KEY_SUFFIX);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Returns a champions details JSON string.
 /// </summary>
 /// <param name="id"> The champion ID. </param>
 /// <param name="region"> The region we are looking to grab from. </param>
 /// <returns>cahmpion details json string</returns>
 public static String CHAMPION_STATIC_DATA(int id = 17, ChampData champData = ChampData.minimal, Region.RegionEnum region = Region.RegionEnum.na)
 {
     // EXAMPLE: https;//global.api.pvp.net/api/lol/static-data/na/v1.2/champion/30?api_key=1069372c-3d2d-4734-964c-53434511b8f8
     if (champData == ChampData.minimal)
     {
         return(API_Prefix(region) + "static-data/" + region.ToString() + "/" + "v1.2/champion/" + id.ToString() + "&api_key=" + API_KEY_SUFFIX);
     }
     else
     {
         return(API_Prefix(region) + "static-data/" + region.ToString() + "/" + "v1.2/champion/" + id.ToString() + "?champData=" + champData.ToString() + "&api_key=" + API_KEY_SUFFIX);
     }
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Returns the total mastery score for a summoner.
 /// </summary>
 /// <param name="summonerId"> ID of the summoner we are looking up for. </param>
 /// <param name="region"> the region the summoner is in. </param>
 /// <returns></returns>
 public static String CHAMPIONMASTERY_TOTAL_MASTERY_SCORE(long summonerId, Region.RegionEnum region = Region.RegionEnum.na)
 {
     return(API_Prefix(region, true) + "championmastery/location/" + Region.GetPlatformID(region) + "/player/" + summonerId + "/score?api_key=" + API_KEY_SUFFIX);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Returns a list of top champions masteries for a given summoner.
 /// </summary>
 /// <param name="summonerId"> ID of the summoner we are looking up for. </param>
 /// <param name="region"> the region the summoner is in. </param>
 /// <param name="count"> number of champions to return. </param>
 /// <returns></returns>
 public static String CHAMPIONMASTERY_TOP_CHAMPIONS(long summonerId, Region.RegionEnum region = Region.RegionEnum.na, int count = 3)
 {
     return(API_Prefix(region, true) + "championmastery/location/" + Region.GetPlatformID(region) + "/player/" + summonerId + "/topchampions?count=" + count + "&api_key=" + API_KEY_SUFFIX);
 }