Esempio n. 1
0
def get_match_info(data):
    try:
        # some files seems broken for this library when using the `Summary`.
        m = parse_match(data)
        players = [dict(name=p.name, user_id=p.profile_id, number=p.number, civilization=p.civilization) for p in m.players]

        return dict(
            map_name=m.map.name,
            game_version=f"{m.version.name} {m.version.value}",
            game_map_type=m.type,
            players=players,
            teams=m.teams,
            completed=False,
            start_time_seconds=str(m.actions[0].timestamp.seconds),
            duration_seconds=m.duration.seconds,
        )
    except RuntimeError:
        # the `parse_match` method doesn't work for restored recordings, thus, let's try with the `Summary`.
        s = Summary(data)

        return dict(
            map_name=s.get_map()['name'],
            game_version=" ".join(str(x) for x in s.get_version()),
            game_map_type=s.get_settings()['type'][1],
            players=s.get_players(),
            teams=s.get_teams(),
            completed=s.get_completed(),
            start_time_seconds=int(s.get_start_time()/1000),
            duration_seconds=int(s.get_duration()/1000),
        )
Esempio n. 2
0
async def play_rec(playback, path):
    """Play a recorded game."""
    with open(path, 'rb') as handle:
        summary = Summary(handle)
        client = await Client.create(playback, path, summary.get_start_time(),
                                     summary.get_duration())
        async for _, _, _ in progress_bar(client.sync(), client.duration):
            pass
Esempio n. 3
0
async def play_rec(playback, path):
    """Play a recorded game."""
    if not playback:
        raise RuntimeError('playback not supported')
    from mgz.playback import Client, progress_bar
    with open(path, 'rb') as handle:
        summary = Summary(handle)
        client = await Client.create(playback, path, summary.get_start_time(),
                                     summary.get_duration())
        async for _, _, _ in progress_bar(client.sync(), client.duration):
            pass