Exemplo n.º 1
0
Arquivo: q3.py Projeto: cdrttn/fragmon
def q3_make_goods(rules):
    headers = []
    overview = Overview(teamAname='Red', teamBname='Blue', teamAcolor=0xffb1b1, teamBcolor=0xa6acff)
    activels = []
    pi = Plusinfo()

    #From Commander keen's q3 console page:
    #0 - Free For All  	1 - Tournament  	2 - Single Player
    #3 - Team Deathmatch 	4 - Capture the Flag
    #5 - One Flag CTF  	6 - Overload  	7 - Harvester (Team Arena only)
    #XXX: 5 is CA in osp
    #make the headers and overview
    splited = rules.split('\\')[1:]
    for i in range(0, len(splited), 2):
        r = Rule(key=splited[i], value=splited[i+1])
        k = r.key
        v = r.value

        types = ['FFA', '1v1', 'Single player', 'TDM', 'CTF', 'CA', 'Overload', 'Harvester']
        k = k.lower()
        if k == 'sv_hostname':
            overview.hostname = v
        elif k == 'g_gametype':
            overview.type = v
            try:
                overview.type = types[int(v)]
            except KeyError,ValueError:
                pass
            if overview.type in ('CTF', 'TDM', 'CA'):
                overview.mode = 'team'
            elif overview.type == '1v1':
                overview.mode = '1v1'

        elif k == 'sv_maxclients':
            overview.maxplayers = v
Exemplo n.º 2
0
Arquivo: q4.py Projeto: cdrttn/fragmon
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