Open eazimmer opened 3 years ago
If you run initialize
, the data will come back with the actual data rather than the ids.
For example:
await LeagueAPI.initialize();
Hmm, strange. I'm already running initialize. I can tell for sure as I'm getting the "set fully loaded classes" note in my console output. It successfully expanded most ids into objects, but I still see only ids for items and runes. I had to match those ids against current ddragon jsons in order to get the names I was looking for.
Can you show me a code example? It's been a while since I used this
Here's a snippet from the relevant function. It grabs a summoner's recent games, chooses the most recent, and throws me a JSON file with the data provided via the gameInfo
object.
return await LeagueAPI.initialize()
.then(async function() {
return await LeagueAPI.getSummonerByName(player_name)
.then(async function (accountInfo) {
return await LeagueAPI.getMatchList(accountInfo);
})
.then(async function (activeGames) {
let game_id = await activeGames["matches"][0]["gameId"]; // Grab most recent game
return await LeagueAPI.getMatch(game_id)
.then(async function (gameInfo) {
const jsonString = JSON.stringify(gameInfo)
await fs.writeFile('./gameData.json', jsonString, err => {
if (err) {
console.log('Error writing file', err)
} else {
console.log('Successfully wrote file')
}
})
If you clean up that output document so it's legible you'll see this:
"participants": [ { "participantId": 1, "stats": { "participantId": 1, "win": true, "item0": 6672, "item1": 3033, "item2": 3031, "item3": 3006, "item4": 1038, "item5": 1029, "item6": 3340, "kills": 10, "deaths": 8, "assists": 11, "largestKillingSpree": 4, "largestMultiKill": 1, "killingSprees": 3, "longestTimeSpentLiving": 254, "doubleKills": 0, "tripleKills": 0, "quadraKills": 0, "pentaKills": 0, "unrealKills": 0, "totalDamageDealt": 88947, "magicDamageDealt": 2633, "physicalDamageDealt": 82667, "trueDamageDealt": 3646, "largestCriticalStrike": 669, "totalDamageDealtToChampions": 22377, "magicDamageDealtToChampions": 1793, "physicalDamageDealtToChampions": 19277, "trueDamageDealtToChampions": 1306, "totalHeal": 3752, "totalUnitsHealed": 4, "damageSelfMitigated": 11448, "damageDealtToObjectives": 10230, "damageDealtToTurrets": 8083, "visionScore": 8, "timeCCingOthers": 35, "totalDamageTaken": 18788, "magicalDamageTaken": 2555, "physicalDamageTaken": 14965, "trueDamageTaken": 1267, "goldEarned": 14560, "goldSpent": 12950, "turretKills": 1, "inhibitorKills": 0, "totalMinionsKilled": 91, "neutralMinionsKilled": 0, "neutralMinionsKilledTeamJungle": 0, "neutralMinionsKilledEnemyJungle": 0, "totalTimeCrowdControlDealt": 422, "champLevel": 16, "visionWardsBoughtInGame": 0, "sightWardsBoughtInGame": 0, "wardsPlaced": 2, "wardsKilled": 1, "firstBloodKill": false, "firstBloodAssist": false, "firstTowerKill": false, "firstTowerAssist": false, "firstInhibitorKill": false, "firstInhibitorAssist": true, "combatPlayerScore": 0, "objectivePlayerScore": 0, "totalPlayerScore": 0, "totalScoreRank": 0, "playerScore0": 0, "playerScore1": 0, "playerScore2": 0, "playerScore3": 0, "playerScore4": 0, "playerScore5": 0, "playerScore6": 0, "playerScore7": 0, "playerScore8": 0, "playerScore9": 0, "perk0": 8214, "perk0Var1": 1122, "perk0Var2": 0, "perk0Var3": 0, "perk1": 8224, "perk1Var1": 460, "perk1Var2": 0, "perk1Var3": 0, "perk2": 8210, "perk2Var1": 0, "perk2Var2": 0, "perk2Var3": 0, "perk3": 8232, "perk3Var1": 0, "perk3Var2": 50, "perk3Var3": 0, "perk4": 8463, "perk4Var1": 201, "perk4Var2": 0, "perk4Var3": 0, "perk5": 8453, "perk5Var1": 733, "perk5Var2": 97, "perk5Var3": 0, "perkPrimaryStyle": 8200, "perkSubStyle": { "id": 8400, "key": "Resolve", "icon": "perk-images/Styles/7204_Resolve.png", "name": "Resolve", "slots": [ { "runes": [ { "id": 8437, "key": "GraspOfTheUndying", "icon": "perk-images/Styles/Resolve/GraspOfTheUndying/GraspOfTheUndying.png", "name": "Grasp of the Undying", "shortDesc": "Every 4s your next attack on a champion deals bonus magic damage, heals you, and permanently increases your health.", "longDesc": "Every 4s in combat, your next basic attack on a champion will:
In this example you can see we're only getting item and rune ids instead of full objects. Now, that said, within the "perkSubStyle" section immediately you ARE giving us a full listing of every rune in the user's secondary rune tree, which we could in theory match against the "perk4" and "perk5" ids above - but even then it's a really gnarly dictionary structure - and it only contains information about the secondary tree runes. It looks to be somewhat of a copy paste from the runesReforged.json file. Maybe there's some issue with how you were splicing in data from that file into the gameInfo object against the rune/item ids? Either way, we don't have any way of matching any of the user's primary-tree rune ids (perk 1, perk 2, perk3) against their full objects since we don't have a similar "perkPrimaryStyle" object to what we get in "perkSubStyle".
That all said, within the same JSON output, lower down, you get:
"mapObject": { "MapName": "Summoner's Rift", "MapId": "11", "image": { "full": "map11.png", "sprite": "map0.png", "group": "map", "x": 0, "y": 0, "w": 48, "h": 48 } }
This is important because it was the example you used in your description of the initialize()
function on your GitHub page. If initialize()
wasn't set, I shouldn't be getting an entire object here, only a map id. The fact we see the entire object hopefully proves that the function has been set correctly on my end.
Hopefully this helps, if the formatting is too ugly here or you need more information please let me know. I'd be happy to try and help however possible, I'm super thankful for what you've built here and have been using it for a couple months now. I've only now ran into the issue.
Sorry I don't understand the issue, you are setting initialize() and looks like you are getting the full objects returned.
The full object's also have the ID
Look specifically at item0
, item1
, item2
, item3
, item4
, item5
, item6
, and perkPrimaryStyle
. They provide only ids, not full objects.
Thanks for pointing out this issue. Item0 - item6 have been fixed with the latest version (2.3). I'm going to look at 'statperk0-5' and 'perkPrimaryStyle' etc next
Thanks, I look forward to seeing the rest of the changes.
More of a question than an issue:
Regarding items, I know within 'participants' each entry has 'item0', 'item1', etc, but how would one go about translating those ids into item names? Similarly, when it comes to runes I can see entries regarding perk0, perk0var1, etc, but where can we translate those id values into the corresponding rune names?
Thanks.