示例#1
0
// use list of summoners to download game data
func updateGames(summoners <-chan SummonerInfo, dbmap *gorp.DbMap) (gameCount int) {

	var out int = 0
	gameChan1 := make(chan GameInfo)

	// dump game info into channel
	globalWg.Add(1)
	go func() {
		for s := range summoners {

			summonerGames, riotErr := goriot.RecentGameBySummoner(goriot.NA, s.ID)
			checkErr(
				riotErr,
				fmt.Sprintf(
					"Unable to get summoner's (%d) recent games",
					s.ID))

			for _, game := range summonerGames {
				gameChan1 <- GameInfo{s.ID, game}
			}
		}
		close(gameChan1)
		globalWg.Done()
	}()

	gameChan2 := updateGameInfo(gameChan1, dbmap)
	updateSummonerGames(gameChan2, dbmap)

	return out
}
示例#2
0
func CheckGames() {
	players := ols.GetPlayersDAO().All()
	matchRules := []MatchRule{CorrectPlayerTeam, CorrectOtherTeam, AlreadyChecked, CorrectGameType, CorrectGameMode}
	usedSet := map[int64]bool{}
	for _, player := range players {
		summonerId := player.Id
		games, err := goriot.RecentGameBySummoner("na", summonerId)
		if err != nil {
			log.Printf("Error: ", err.Error())
		}

		for _, game := range games {
			_, used := usedSet[game.GameID]
			if used {
				continue
			}

			allowedGame := ApplyRules(*player, game, matchRules)
			if allowedGame {
				usedSet[game.GameID] = true
				createMatch(*player, game)
			}

		}
	}

}
示例#3
0
func parseMatchHistory(w http.ResponseWriter, r *http.Request) {
	vars := w.(httptools.VarsResponseWriter).Vars()
	server, summonerId := vars["server"].(string), vars["summonerId"].(int64)

	mh, err := goriot.RecentGameBySummoner(server, summonerId)
	if err != nil {
		http.Error(w, err.Error(), http.StatusBadRequest)
		return
	}

	vars["history"] = mh
}