示例#1
0
文件: main.py 项目: mRokita/DPLeague
def on_roundstarted(arg, server):
    global data
    teams = main_server.Teams()
    if data.match_started == 3: # Inicjalizacja analizy błędów w balansie teamów
        players = main_server.rcon_players()
        for player in players:
            if (player['id'] in teams[data.team1_color]) or (player['id'] in teams[data.team2_color]):
                db.add_scores(data.match_id, player['dplogin'])
    if ((data.team1_color not in teams) # Szukanie błędów w balansie teamów
        or (data.team2_color not in teams)
        or (len(teams[data.team1_color]) != config.league_type)
        or (len(teams[data.team2_color]) != config.league_type)):
            if data.match_started == 2:
                main_server.Say("{C}BERROR: Teams aren't {n} vs {n}. Restarting...".format(n=config.league_type))
                main_server.rcon("map " + data.map_info['mapname'])
            elif data.match_started == 3:
                if data.wrong_rounds < config.league_max_wrong_rounds:
                    main_server.Say("{C}BERROR: Teams aren't {n} vs {n}.".format(n=config.league_type))
                    main_server.Say("{C}BMatch is going to end after {l} rounds."
                                    .format(l=(config.league_max_wrong_rounds-data.wrong_rounds)))
                    data.wrong_rounds += 1
                else:
                    if len(teams[data.team1_color]) > len(teams[data.team2_color]):
                        main_server.Say("{C}B%s gets the map by a forfeit" % data.team1_info['name'])
                        main_server.rcon("sv newmap pbcup")
                        db.set_current(data.match_id, 3)
                        db.give_map(data.team1_id, data.map_info['mapname'])
                    elif len(teams[data.team1_color]) < len(teams[data.team2_color]):
                        main_server.Say("{C}B%s defends the map by a forfeit" % data.team1_info['name'])
                        main_server.rcon("sv newmap pbcup")
                        db.set_current(data.match_id, 3)
                        db.map_defended(data.map_info['mapname'])
                    elif len(teams[data.team1_color]) == len(teams[data.team2_color]):
                        main_server.Say("{C}Match canceled." % data.team1_info['name'])
                        db.set_current(data.match_id, 4)
                    default_vars()
    else:
        if not data.match_started == 3: #Rozpoczecie meczu
            data.match_started = 3
            main_server.Say("{C}BMatch started!")
            db.set_current(data.match_id, 2)
            players = main_server.rcon_players()
            for player in players:
                if (player['id'] in teams[data.team1_color]) or (player['id'] in teams[data.team2_color]):
                    db.add_scores(data.match_id, player['dplogin'])
        data.wrong_rounds = 0
示例#2
0
文件: main.py 项目: mRokita/DPLeague
def on_mapchange(arg, server):
    global data
    if data.match_started == 1:
        data.colors = server.Scores().keys()
        shuffle(data.colors)
        data.team1_color = data.colors[0]
        data.team2_color = data.colors[1]
        data.match_started = 2
    if data.match_started == 3: # zakończenie meczu i dodanie danych do bazy
        if data.team1_score > data.team2_score:
            main_server.rcon("sv newmap pbcup")
            db.set_current(data.match_id, 3)
            db.give_map(data.team1_id, data.map_info['mapname'])
            default_vars()
            sleep(8)
            main_server.Say("{C}B%s gets the map." % data.team1_info['name'])
        else:
            main_server.rcon("sv newmap pbcup")
            db.set_current(data.match_id, 3)
            db.map_defended(data.map_info['mapname'])
            default_vars()
            sleep(8)
            main_server.Say("{C}B%s defended the map. +20 points." % data.team1_info['name'])