DDragon Helpers + CDragon + blahblahblah
In light of my lack of static compatibility to prevent breaking code, I'll be working also on a few things over the next few days to help out everyone, and be working on things early (pushed ChampionRotation yesterday) and so I have much more time to think about releases. I'll admit that sometimes I don't prioritize certain new things because I don't have to use them (I didn't use static endpoints for example. My app pretty much just uses matchlist+challenger league+master league+literally saved copies of static data). However, I do want kayn to be easy-to-use and have a lot of examples, docs, and copy-pastable code, + good defaults so...
- My static endpoints are already broken, and I'm sure users either swapped libraries, swapped to DDragon, etcetc. So, they will be removed eventually as it's too late anyways... But:
- CDragon will be added
- DDragon helpers will be added
- Types will be addressed
- A ton of more ES5 callback examples and ES6+ async/await examples will be added. These examples will be based on real code used by others or myself (https://github.com/cnguy/kayn/issues/46). I added an example early on how to use the new ChampionRotation endpoints and then convert it into the correct DDragon champion objects, for example.
- Improve docs so it's easier to refer to examples and endpoint APIs, coverage pic (low priority obviously), tests (these tests are simple to make, low priority)
One example of a DDragon helper is: For example, DDragon.Champion.get(266) =>
await DDragon.Champion.get(266) // If cache is enabled, DDragon.Champion.list is cached
/*
{
"version": "6.24.1",
"id": "Aatrox",
"key": "266",
"name": "Aatrox",
"title": "the Darkin Blade",
"blurb": "Aatrox is a legendary warrior, one of only five that remain of an ancient race known as the Darkin. He wields his massive blade with grace and poise, slicing through legions in a style that is hypnotic to behold. With each foe felled, Aatrox's ...",
"info": {
"attack": 8,
"defense": 4,
"magic": 3,
"difficulty": 4
},
"image": {
"full": "Aatrox.png",
"sprite": "champion0.png",
"group": "champion",
"x": 0,
"y": 0,
"w": 48,
"h": 48
},
"tags": [
"Fighter",
"Tank"
],
"partype": "BloodWell",
"stats": {
"hp": 537.8,
"hpperlevel": 85,
"mp": 105.6,
"mpperlevel": 45,
"movespeed": 345,
"armor": 24.384,
"armorperlevel": 3.8,
"spellblock": 32.1,
"spellblockperlevel": 1.25,
"attackrange": 150,
"hpregen": 6.59,
"hpregenperlevel": 0.5,
"mpregen": 0,
"mpregenperlevel": 0,
"crit": 0,
"critperlevel": 0,
"attackdamage": 60.376,
"attackdamageperlevel": 3.2,
"attackspeedoffset": -0.04,
"attackspeedperlevel": 3
}
}
*/
In v0.8.21:
DDragon.Champion.getDataById(championName: string)
DDragon.Champion.getDataByIdWithParentAsId(championName: string)
DDragon.Champion.listDataById()
DDragon.Champion.listDataByIdWithParentAsId()
DDragon.Champion.listFullDataById()
DDragon.Champion.listFullDataByIdWithParentAsId()
Currently experimenting with an optional version where the version, for each endpoint, is derived from whatever version map (Realm.list) is currently cached, or from your default region.
v0.8.22 Adding a manual version() call to DDragon requests for data (champion.json, item.json, etc) is now optional. It works off either your default region, or a manual region() call passed to the request.
Default region
const kayn = Kayn()({ region: 'euw' })
const europeanList = await kayn.DDragon.Champion.list()
Manual region call
For the current request, it overrides the default region.
const kayn = Kayn()({ region: 'na' })
const europeanList = await kayn.DDragon.Champion.list().region('euw')
@cnguy I've run into an issue related to the above optional version() call for DDragon requests. The runes reforged endpoint errors out because the realms endpoint doesn't have a version for it. I've tracked it down to the error handling around the version, would you like me to include the information here or open a new issue for it?
I'll make an issue, since this one is kinda feature-packed as well as old.