Ejemplo n.º 1
0
func tiers() {

	session, err := mgo.Dial(MongoLocation)
	if err != nil {
		panic(err)
	}

	db := session.DB(DatabaseName)
	var players ols.Players
	db.C("players").Find(map[string]string{}).All(&players)

	for _, player := range players {
		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("player: ", player)
		db.C("players").Update(map[string]int64{"id": player.Id}, player)
	}

}
Ejemplo n.º 2
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
}