Exemple #1
0
def get_filtered_teams(teams_to_remove):
    teams = []
    for team_pickle in db.get_all_teams():
        this_team = jsonpickle.decode(team_pickle[0], keys=True, classes=team)
        if this_team.name not in teams_to_remove:
            teams.append(this_team)
    return teams
Exemple #2
0
def get_all_teams_scores():
    team_scores = []
    all_teams = db.get_all_teams()
    for row in all_teams:
        # name, score, last_solve
        team = TeamScore(row[0], row[1])
        team_scores.append(team)
    return team_scores
Exemple #3
0
def main():
    pools = []
    teams = list(database.get_all_teams())
    game_played = {}

    # Set the number of game played to 0
    for team in teams:
        game_played[team.id] = 0

    # Create the pools
    number_teams = len(teams)
    number_games = int(math.ceil((number_teams * game_for_player) / 4))
    games_with_bot = int(math.modf(number_teams * game_for_player / 4)[0] * 4)
    for i in range(number_games):
        pool = []
        while len(pool) != 4:
            # Check if need we need to fill the game with a bot
            if (len(pool) == 3
                    and games_with_bot > 0) or (i == number_games - 1
                                                and games_with_bot > 0):
                selected_player = bot
                games_with_bot -= 1
            else:
                selected_player = teams[random.randint(0, number_teams - 1)]

            # Check if the player has already played a game
            if not selected_player.bot:
                has_already_played = False
                for team, number_game_played in game_played.items():
                    if number_game_played < game_played[selected_player.id]:
                        has_already_played = True
                        break
                if has_already_played:
                    continue

            # Check if player already in game
            already_in_game = False
            for player in pool:
                if player.id == selected_player.id:
                    already_in_game = True
                    break
            if already_in_game:
                continue

            pool.append(selected_player)

            if not selected_player.bot:
                game_played[selected_player.id] += 1

        pools.append(pool)

    for i in range(len(pools)):
        print("Pool {}".format(i))

        for team in pools[i]:
            print(team.name)

        print("************")
Exemple #4
0
def setup_teams():
    teams = {}
    vs_teams = {}
    games = db.get_all_teams()
    for g in games:
        teams[g['team']] = 0
        vs_teams[g['team']] = {'teams': 0, 'stats': 0}

    for t in teams:
        vs_teams[t]['teams'] = teams
        vs_teams[t]['stats'] = {'elo': 1000, 'games': 0, 'wins': 0, 'score': 0, 'score_against': 0,'momentum':0,'ts':trueskill.Rating()}

    return vs_teams
def get_all_teams():
    teams = []
    for team_pickle in db.get_all_teams():
        this_team = jsonpickle.decode(team_pickle[0], keys=True, classes=team)
        teams.append(this_team)
    return teams
Exemple #6
0
def is_team_code_unique(team_code):
    all_teams = db.get_all_teams()
    for row in all_teams:
        if (team_code == row[1]):
            return False
    return True