예제 #1
0
def main():
    autoenv.init('Client')

    parser = argparse.ArgumentParser('log2thbrep')
    parser.add_argument('replay_file', help='Server side replay')
    parser.add_argument('client_version',
                        help='Desired client version (git commit)')
    parser.add_argument('--freeplay',
                        action='store_true',
                        help='Use freeplay account module?')
    options = parser.parse_args()

    if options.replay_file.endswith('.gz'):
        data = gzip.open(options.replay_file, 'r').read()
    else:
        data = open(options.replay_file, 'r').read()

    data = data.decode('utf-8').split('\n')
    names = data.pop(0)[2:].split(', ')  # Names
    data.pop(0)  # Ver
    gid = int(data.pop(0).split()[-1])  # GameId
    data.pop(0)  # Time

    game_mode, game_params, game_items, rnd_seed, usergdhist, gdhist = data
    gdhist = json.loads(gdhist)
    game_params = json.loads(game_params)

    rep = Replay()
    rep.client_version = options.client_version
    rep.game_mode = game_mode
    rep.game_params = game_params
    rep.game_items = json.loads(game_items)
    rep.users = [gen_fake_account(i, options.freeplay) for i in names]

    assert len(names) == len(gdhist), [names, len(gdhist)]

    for i, gd in enumerate(gdhist):
        fn = '%s_%s.thbrep' % (gid, i)
        with open(fn, 'w') as f:
            print 'Writing %s...' % fn
            rep.me_index = i
            rep.gamedata = gd
            f.write(rep.dumps())
예제 #2
0
        def end_game(self, data):
            g = self.game
            self.event_cb('end_game', g)
            log.info('=======GAME ENDED=======')
            self.last_game = g

            rep = Replay()
            rep.client_version = Executive.get_current_version()
            rep.game_mode = g.__class__.__name__
            params, items, i, pldata = self.last_game_info
            rep.game_params = params
            rep.game_items = items
            rep.me_index = i
            rep.users = pldata
            rep.gamedata = Executive.server.gamedata.history
            rep.track_info = {
                'server': Executive.gamemgr.server_name,
                'gameid': g.gameid,
            }
            self.last_replay = rep
예제 #3
0
        def end_game(self, data):
            g = self.game
            self.event_cb('end_game', g)
            log.info('=======GAME ENDED=======')
            self.last_game = g

            rep = Replay()
            rep.client_version = Executive.get_current_version()
            rep.game_mode = g.__class__.__name__
            params, items, i, pldata = self.last_game_info
            rep.game_params = params
            rep.game_items = items
            rep.me_index = i
            rep.users = pldata
            rep.gamedata = Executive.server.gamedata.history
            rep.track_info = {
                'server': Executive.gamemgr.server_name,
                'gameid': g.gameid,
            }
            self.last_replay = rep
예제 #4
0
def main():
    autoenv.init('Client')

    parser = argparse.ArgumentParser('log2thbrep')
    parser.add_argument('replay_file', help='Server side replay')
    parser.add_argument('client_version', help='Desired client version (git commit)')
    parser.add_argument('--freeplay', action='store_true', help='Use freeplay account module?')
    options = parser.parse_args()

    if options.replay_file.endswith('.gz'):
        data = gzip.open(options.replay_file, 'r').read()
    else:
        data = open(options.replay_file, 'r').read()

    data = data.decode('utf-8').split('\n')
    names = data.pop(0)[2:].split(', ')  # Names
    data.pop(0)  # Ver
    gid = int(data.pop(0).split()[-1])  # GameId
    data.pop(0)  # Time

    game_mode, game_params, game_items, rnd_seed, usergdhist, gdhist = data
    gdhist = json.loads(gdhist)
    game_params = json.loads(game_params)

    rep = Replay()
    rep.client_version = options.client_version
    rep.game_mode = game_mode
    rep.game_params = game_params
    rep.game_items = json.loads(game_items)
    rep.users = [gen_fake_account(i, options.freeplay) for i in names]

    assert len(names) == len(gdhist), [names, len(gdhist)]

    for i, gd in enumerate(gdhist):
        fn = '%s_%s.thbrep' % (gid, i)
        with open(fn, 'w') as f:
            print 'Writing %s...' % fn
            rep.me_index = i
            rep.gamedata = gd
            f.write(rep.dumps())