Beispiel #1
0
    def handle(self, *args, **options):
        print("{0}: Start".format(get_date_string()))

        games = get_latest_wg_games()

        tenhou_objects = TenhouNickname.objects.all().prefetch_related(
            "player")
        player_profiles = {}
        for tenhou_object in tenhou_objects:
            player_profiles[tenhou_object.tenhou_username] = tenhou_object

        found_players = {}
        for game in games:
            for player in game["players"]:
                # we found a player from our database
                # and this is not sanma
                if len(game["players"]
                       ) == 4 and player["name"] in player_profiles:
                    found_players[player["name"]] = player["rate"]

        for player_name, rate in found_players.items():
            tenhou_obj = player_profiles[player_name]
            stat = tenhou_obj.four_players_aggregated_statistics()
            stat.rate = rate
            stat.save()

        print("{0}: End".format(get_date_string()))
Beispiel #2
0
def get_current_tenhou_games_async(request):
    games = get_latest_wg_games()

    tenhou_objects = TenhouNickname.objects.all().prefetch_related('player')
    player_profiles = {}
    for tenhou_object in tenhou_objects:
        player_profiles[tenhou_object.tenhou_username] = tenhou_object.player

    # let's find players from our database that are playing right now
    found_players = []
    our_players_games = {}

    high_level_games = {}
    high_level_hirosima_games = {}

    for game in games:
        for player in game['players']:
            # we found a player from our database
            if player['name'] in player_profiles:
                found_players.append(player)
                our_players_games[game['game_id']] = game

            if player['dan'] >= 18:
                if len(game['players']) == 3:
                    high_level_hirosima_games[game['game_id']] = game
                else:
                    high_level_games[game['game_id']] = game

    return render(
        request, 'tenhou/tenhou_games_async.html', {
            'our_players_games': our_players_games.values(),
            'high_level_games': high_level_games.values(),
            'high_level_hirosima_games': high_level_hirosima_games.values(),
            'player_profiles': player_profiles
        })
def get_current_tenhou_games_async(request):
    games = get_latest_wg_games()

    tenhou_objects = TenhouNickname.objects.all().prefetch_related("player")
    player_profiles = {}
    for tenhou_object in tenhou_objects:
        player_profiles[tenhou_object.tenhou_username] = tenhou_object.player

    # let's find players from our database that are playing right now
    found_players = []
    our_players_games = {}

    high_level_games = {}
    high_level_sanma_games = {}

    bot_games = {}

    for game in games:
        for player in game["players"]:
            # we found a player from our database
            if player["name"] in player_profiles:
                found_players.append(player)
                our_players_games[game["game_id"]] = game

            if player["name"].startswith("ⓝ"):
                player["is_bot"] = True
                bot_games[game["game_id"]] = game

            if player["dan"] >= 18:
                if len(game["players"]) == 3:
                    high_level_sanma_games[game["game_id"]] = game
                else:
                    high_level_games[game["game_id"]] = game

    return render(
        request,
        "tenhou/tenhou_games_async.html",
        {
            "our_players_games": our_players_games.values(),
            "high_level_games": high_level_games.values(),
            "high_level_hirosima_games": high_level_sanma_games.values(),
            "bot_games": bot_games.values(),
            "player_profiles": player_profiles,
        },
    )
Beispiel #4
0
    def handle(self, *args, **options):
        print('{0}: Start'.format(get_date_string()))

        games = get_latest_wg_games()

        tenhou_objects = TenhouNickname.objects.all().prefetch_related('player')
        player_profiles = {}
        for tenhou_object in tenhou_objects:
            player_profiles[tenhou_object.tenhou_username] = tenhou_object

        found_players = {}
        for game in games:
            for player in game['players']:
                # we found a player from our database
                # and this is not hirosima
                if len(game['players']) == 4 and player['name'] in player_profiles:
                    found_players[player['name']] = player['rate']

        for player_name, rate in found_players.items():
            tenhou_obj = player_profiles[player_name]
            tenhou_obj.four_games_rate = rate
            tenhou_obj.save()

        print('{0}: End'.format(get_date_string()))