Closed xEcEz closed 6 years ago
The reason for the role types being different is twofold:
1) In the general context of League, if you ask someone "What are the roles (or lanes) a champion can play in?" They will answer with "Top, mid, jungle, support, adc". The Riot API pollutes that answer with additional roles such as SOLO, DUO, and NONE, but those aren't roles, they are just placeholders for "ehhh we couldn't figure out what to do here".
2) More practically, a user can easily check if the roles Riot gives are valid by doing if isinstance(role, Enum)
. If that's false, Riot gave a weird result back that isn't especially useful. You can always recast the types using str(role)
if you want a string or want them to always be the same type.
I see, thanks for the answer.
I ran into the same issue of getting weird results backs, so what I am doing is to combine both pieces of information to reconstruct something meaningful out of it. However, I understand the reason for exposing this information as is.
If you want better values for roles you can also check out our code here: https://github.com/meraki-analytics/role-identification
You need a champion.gg API key but after you have that you can use the role-id code like this:
roles = get_team_roles(match.blue_team, champion_roles)
print({role.name: champion.name for role, champion in roles.items()})
{'top': 'Pantheon', 'jungle': 'Nunu', 'mid': 'Akali', 'adc': 'Caitlyn', 'support': 'Morgana'}
Ok, thanks for sharing this.
Participants' role attribute can be of different types. Maybe having an enum that covers every case would be more consistent.