Esempio n. 1
0
func NewPlayer(name, ign string) *ols.Player {
	player := ols.Player{Name: name}

	leaguePlayerMap, err := goriot.SummonerByName("na", goriot.NormalizeSummonerName(ign)[0])
	if err != nil {
		fmt.Println(err)
		return nil
	}
	leaguePlayer := leaguePlayerMap[goriot.NormalizeSummonerName(ign)[0]]
	player.Ign = leaguePlayer.Name
	player.Id = leaguePlayer.ID
	player.NormalizedIgn = goriot.NormalizeSummonerName(leaguePlayer.Name)[0]
	id := player.Id
	leagues_by_id, err := goriot.LeagueBySummoner("na", id)
	if err != nil {
		fmt.Println("wat: ", err.Error())
		player.Tier = "None"
	}
	league, ok := leagues_by_id[id]
	if ok {
		player.Tier = getBestLeague(league, player)
	}
	fmt.Println("New Player added: ", player)
	ols.GetPlayersDAO().Save(player)
	return &player
}
Esempio n. 2
0
func nameErrors() {
	players := ols.GetPlayersDAO().All()
	for _, player := range players {
		_, err := goriot.SummonerByName("na", goriot.NormalizeSummonerName(player.NormalizedIgn)...)
		if err != nil {
			fmt.Println("Error with: ", player.Ign, " : ", err)
		}

	}
}