def test_get_live_league_games(self): """ Get list of currently live league games """ j = api.get_live_league_games() self.assertIn("result", j) self.assertIn("games", j["result"])
async def send_live_games(self, message, content): league_games = api.get_live_league_games()['result'] response_list = [] for game in league_games['games']: if 'radiant_team' not in game: continue if 'dire_team' not in game: continue radi_team = game['radiant_team']['team_name'] dire_team = game['dire_team']['team_name'] match_id = str(game['match_id']) game_num = str(game['game_number']) league_name = self.get_league_name(game['league_id']) duration = 0 if 'scoreboard' in game: duration = game['scoreboard']['duration'] mins = int(duration / 60) seconds = int(duration % 60) dur_str = '%d:%02d' % (mins, seconds) response_list.append(league_name + ' - **' + radi_team + '** vs. **' + dire_team + '**' + ' - ' + dur_str) response = '\n'.join(response_list) await self.client.send_message(message.channel, response)
def main(): telaInicial() chave = input("\n Entre com a chave de desenvolvedor: ") infos = GetInfos(chave) picks = infos.columns["hero_id"] performance = infos.columns["gold_per_min"] + infos.columns["xp_per_min"] clear() while True: option = menuInicial() if option == '1': clear() modelo = ajusteModelo(picks, performance) input("\n Aperte 'Enter' tecla para continuar... ") pass elif option == '2': system("clear") escolha = menuOnline() if escolha == '1': while True: games = [i for i in api.get_live_league_games()["result"]["games"]] choose = tableGames(games) if type(choose) == int: break else: while True: game = LeagueGame( chave, choose ) clear() game.showAll(modelo) acao = input("\n Deseja Atualizar[A], Previsão Recusiva[R], Sair[S]: ") if acao == "R": game.recursiveShow(modelo) elif acao == "S": break input("\n Aperte 'Enter' para voltar: ") elif option == '3': system("clear") if 'draft' not in dir(): draft = Draft(chave) draft.makeDraft() else: if input("\n Deseja limpar a seleção de herois?[S/n]: ").lower() == "s": draft.clearDraft() draft.makeDraft() else: draft.makeDraft() clear() draft.showDraft() if 'modelo' in dir(): draft.makeDataFrame() predict = modelo.predict(XB=draft.DataFrame.get_values())[0] team = ["radiant", "dire"] print("\n A estimativa e que o time "+ team[predict] + " ganhe.") input("\n Aperte 'Enter' tecla para continuar... ") pass elif option == '4': break
def recursiveShow(self, modelo): while True: clear() games = [i for i in api.get_live_league_games()["result"]["games"] if self.game["match_id"] == i["match_id"]] if len(games) > 0: self.game = games[0] self.teams = [ Team(game=self.game, faction="radiant", heroes=self.heroes), Team(game=self.game, faction="dire", heroes=self.heroes)] self.showAll(modelo) time.sleep(8)
def match_live(): live_games = api.get_live_league_games() numbers = list() for i in xrange(0,len(live_games["result"]["games"])): try: rad_team = live_games["result"]["games"][i]["radiant_team"] dire_team = live_games["result"]["games"][i]["dire_team"] except KeyError,e : numbers.insert(0,i)
async def predict(self, message, content): if message.channel != None and not message.channel.is_private: self.default_channel = message.channel if len(content) < 3: return fp_amount = 0 try: fp_amount = int(content[1]) except ValueError: return team_name = ' '.join(content[2:]) user_name = message.author.name if fp_amount < 1: return # construct reverse map from team name to lobby league_games = api.get_live_league_games()['result'] team_to_lobby = {} for game in league_games['games']: if 'radiant_team' not in game: continue if 'dire_team' not in game: continue radi_team = game['radiant_team']['team_name'].lower() dire_team = game['dire_team']['team_name'].lower() team_to_lobby[radi_team] = game team_to_lobby[dire_team] = game # find game if team_name.lower() not in team_to_lobby: return game = team_to_lobby[team_name.lower()] duration = 0 if 'scoreboard' in game: duration = game['scoreboard']['duration'] if duration > 0: response = 'The game has already begun, betting is now closed.' await self.client.send_message(message.channel, response) return preds = self.predictions[game['match_id']] prev_fp = 0 prev_team = None avail_fp = self.get_available_fp(user_name) + prev_fp preds['info'] = game radi_team = game['radiant_team']['team_name'] dire_team = game['dire_team']['team_name'] team_name_match = '' if team_name.lower() == radi_team.lower(): team_name_match = radi_team else: team_name_match = dire_team if user_name in preds['predictions']: prev_team = preds['predictions'][user_name]['radiant'] # bet on other team if prev_team != None and (team_name_match == radi_team) != prev_team: response = 'You already bet on the other team!' await self.client.send_message(message.channel, response) return # not enough fp if fp_amount > avail_fp: response = 'You do not have enough FP. (%d)' % (avail_fp,) await self.client.send_message(message.channel, response) return # bet higher if user_name in preds['predictions']: prev_fp = preds['predictions'][user_name]['fp'] if fp_amount <= prev_fp: response = 'You must bet higher than your previous amount. (%d)' % (prev_fp,) await self.client.send_message(message.channel, response) return preds['predictions'][user_name] = {'fp': fp_amount, 'radiant': (team_name_match == radi_team)} response = '%s has wagered **%d FP** on **%s** in %s vs. %s!' \ % (user_name, fp_amount, team_name_match, radi_team, dire_team) await self.client.send_message(message.channel, response) return