KnutZuidema / golio

League of Legends, Legends of Runeterra and Valorant API client library for Go
MIT License
72 stars 29 forks source link

client.DataDragon.GetChampion() fails for Champions with spaces or apostrophes #45

Closed ghost closed 3 years ago

ghost commented 3 years ago

Currently client.DataDragon.GetChampion() fails for specific champions, or at least for me, I went ahead and tested it with a slightly changed version of your example code:

package main

import (
    "fmt"

    "github.com/KnutZuidema/golio"
    "github.com/KnutZuidema/golio/api"
    "github.com/KnutZuidema/golio/riot/lol"
    "github.com/sirupsen/logrus"
)

func main() {
    client := golio.NewClient("",
        golio.WithRegion(api.RegionEuropeWest),
        golio.WithLogger(logrus.New().WithField("foo", "bar")))
    summoner, _ := client.Riot.Summoner.GetByName("Herndl")
    fmt.Printf("%s is a level %d summoner\n", summoner.Name, summoner.SummonerLevel)
    champion, _ := client.DataDragon.GetChampion("Kai'Sa") // Doesn't work with Kai'Sa, Kaisa, KaiSa, or kaisa
    mastery, err := client.Riot.ChampionMastery.Get(summoner.ID, champion.Key)
    if err != nil {
        fmt.Printf("%s has not played any games on %s\n", summoner.Name, champion.ChampionData.Name)
    } else {
        fmt.Printf("%s has mastery level %d with %d points on %s\n", summoner.Name, mastery.ChampionLevel,
            mastery.ChampionPoints, champion.Name)
    }
    challengers, _ := client.Riot.League.GetChallenger(lol.QueueRankedSolo)
    rank1 := challengers.GetRank(0)
    fmt.Printf("%s is the highest ranked player with %d league points\n", rank1.SummonerName, rank1.LeaguePoints)
}

Output for Kai'Sa:

Herndl is a level 455 summoner
Herndl has not played any games on 
Destined 2 Win is the highest ranked player with 1311 league points

Output for Ashe:

Herndl is a level 455 summoner
Herndl has mastery level 5 with 43637 points on Ashe
Destined 2 Win is the highest ranked player with 1311 league points
KnutZuidema commented 3 years ago

Hi @Saz4nd0ra, thanks for opening the issue. I've opened #46 to fix this issue. Can you maybe verify that it does in fact fix your issue?

ghost commented 3 years ago

It kinda does.. now it works flawlessly with champions that have spaces, and some with apostrophes, for example Vel'Koz, Kha'Zix and Kog'Maw work, but Kai'Sa doesn't? Still using the example that I provided in the issue.

ghost commented 3 years ago

One little update since I kept on trying things out and worked on something, right now it seems like only Kai'Sa isn't working, but the error that I get is json: cannot unmarshal array into Go struct field .spells.vars.coeff of type float64, which seems to be caused by the Q spell having an array instead of an float64.. maybe that helps!