Пример #1
0
def match_map_start(matchid, mapnumber):
    match = Match.query.get_or_404(matchid)
    match_api_check(request, match)

    if match.start_time is None:
        match.start_time = datetime.datetime.utcnow()

    map_name = request.values.get('mapname')

    # Create mapstats object if needed
    MapStats.get_or_create(matchid, mapnumber, map_name)
    db.session.commit()

    return 'Success'
Пример #2
0
def match_map_start(matchid, mapnumber):
    match = Match.query.get_or_404(matchid)
    match_api_check(request, match)

    if match.start_time is None:
        match.start_time = datetime.datetime.utcnow()

    map_name = request.values.get('mapname')

    # Create mapstats object if needed
    MapStats.get_or_create(matchid, mapnumber, map_name)
    db.session.commit()

    return 'Success'
Пример #3
0
def match_forfeit(matchid, teamwinner):
    match = Match.query.get_or_404(matchid)
    super_admintools_check(match)
    if teamwinner == 1:
        winnerId = match.team1_id
    elif teamwinner == 2:
        winnerId = match.team2_id
    else:
        raise BadRequestError('Did not select a proper team.')

    match.winner = winnerId
    map_stats = MapStats.get_or_create(match.id, 0, '', '')
    if teamwinner == 1:
        match.team1_score = 1
        match.team2_score = 0
        map_stats.team1_score = 16
    else:
        match.team1_score = 0
        match.team2_score = 1
        map_stats.team2_score = 16
    match.start_time = datetime.now()
    match.end_time = datetime.now()
    match.forfeit = 1
    map_stats.end_time = datetime.now()
    map_stats.winner = winnerId
    server = GameServer.query.get(match.server_id)
    if server:
        server.in_use = False

    db.session.commit()

    try:
        server.send_rcon_command('get5_endmatch', raise_errors=True)
    except util.RconError as e:
        flash('Failed to cancel match: ' + str(e))

    return redirect('/mymatches')