Beispiel #1
0
def q4_make_goods(rbuf):
    overview = Overview(teamAname = 'Strogg', teamBname = 'Marines', teamAcolor = 0xffc37d, teamBcolor = 0x82ff8b)

    rules = []
    rbuf = rbuf.split('\x00') 
    if len(rbuf) % 2:
        rbuf.append('xxx')
    plusinfoitms = ('.players_strogg', '.players_marine', '.players_active', '.score_strogg', '.score_marine', '.score')   
    plusinfo = {}
    for item in plusinfoitms:
        plusinfo[item[1:]] = []

    for i in xrange(0, len(rbuf), 2):
        k = rbuf[i]
        v = rbuf[i+1]
        rules.append(Rule(k, v))

        k = k.lower()
        if k == 'si_name':
            overview.hostname = v
        elif k == 'si_gametype':
            overview.type = v
            v = v.lower()
            if v in ('team dm', 'ctf'):
                overview.mode = 'team'
            elif v in ('tourney', 'duel'):
                overview.mode = '1v1'
        elif k == 'si_maxplayers':
            overview.maxplayers = int(v)
        elif k == 'si_map':
            overview.map = v
        elif k == 'si_version':
            overview.version = v
        elif k == 'si_usepass':
            overview.password = int(v)
        elif k == 'gamename':
            overview.mod = v
        elif k in plusinfoitms:
            list = Plusinfo.make_list(v)
            plusinfo[k[1:]] = list
        elif k == '.score_time':
            overview.time = v

    #q4max stores the team score as the first item in the list, followed by the player ids
    if plusinfo['score_strogg']:
        overview.teamAscore = plusinfo['score_strogg'][0]
    if plusinfo['score_marine']:
        overview.teamBscore = plusinfo['score_marine'][0]

    pi = Plusinfo()
    pi.add_map(0, plusinfo['players_strogg'], plusinfo['score_strogg'][1:])
    pi.add_map(1, plusinfo['players_marine'], plusinfo['score_marine'][1:])
    pi.add_map(0, plusinfo['players_active'], plusinfo['score'])

    return pi, rules, overview 
Beispiel #2
0
        elif k == 'mapname':
            overview.map = v
        elif k == 'version':
            overview.version = v
        elif k == 'g_needpass':
            overview.password = v
        elif k == 'gameversion':
            overview.mod = v
        elif k == 'gamename' and not overview.mod:
            overview.mod = v
        elif k == 'players_red':
            pi.add_map(0, v)
        elif k == 'players_blue':
            pi.add_map(1, v)
        elif k == 'players_active':
            activels = Plusinfo.make_list(v)
        elif k == 'score_time':
            overview.time = v
        elif k == 'score_red':
            overview.teamAscore = v
        elif k == 'score_blue':
            overview.teamBscore = v

        headers.append(r)

    #if there's two active players in duel mode, assume that they are dueling
    if overview.mode == '1v1' and len(activels) == 2:
        pi.add_map(0, activels[0:1])
        pi.add_map(1, activels[1:2])
    else:
        pi.add_map(0, activels)