diff --git a/datadragon/data_dragon.go b/datadragon/data_dragon.go index 64ddccd..7b2c8ec 100644 --- a/datadragon/data_dragon.go +++ b/datadragon/data_dragon.go @@ -142,6 +142,20 @@ func (c *Client) GetChampionByID(id string) (ChampionDataExtended, error) { return champion, nil } +// GetChampion returns information about the champion with the given key +func (c *Client) GetChampionByKey(key string) (ChampionDataExtended, error) { + champions, err := c.GetChampions() + if err != nil { + return ChampionDataExtended{}, err + } + for _, champion := range champions { + if champion.Key == key { + return c.GetChampionByID(champion.ID) + } + } + return ChampionDataExtended{}, api.ErrNotFound +} + // GetChampion returns information about the champion with the given name func (c *Client) GetChampion(name string) (ChampionDataExtended, error) { champions, err := c.GetChampions() diff --git a/riot/lol/model.go b/riot/lol/model.go index 47d1783..c8635c4 100644 --- a/riot/lol/model.go +++ b/riot/lol/model.go @@ -608,7 +608,7 @@ type CurrentGameParticipant struct { // GetChampion returns the champion played by this participant func (p *CurrentGameParticipant) GetChampion(client *datadragon.Client) (datadragon.ChampionDataExtended, error) { - return client.GetChampionByID(strconv.Itoa(p.ChampionID)) + return client.GetChampionByKey(strconv.Itoa(p.ChampionID)) } // GetSpell1 returns the first summoner spell of this participant