-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
executable file
·66 lines (44 loc) · 1.68 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python
import argparse
from sc2replaylib.replay import Replay, Team, Player
from pprint import pprint
from sc2replaylib.replay import Replay, Team, Player
parser = argparse.ArgumentParser(
description='This is a console adapter to work with SC2Replaylib library.')
parser.add_argument('replayFile', type=file)
args = parser.parse_args()
# some example usages----
# basic replay here
replay = Replay(args.replayFile)
# the version of starcraft that this replay was recorded on
print 'This replay is version ' + '.'.join([str(n) for n in replay.version()])
print 'The revision number is ' + str(replay.revision())
#raw data on the replay file-----
pprint(replay.parsers[replay.FILES['details']].parse())
pprint(replay.parsers[replay.FILES['attributes']].parse())
#-------
# run output of game_speed through human readable list of values
print replay.game_speed()
# raw output of game_teams attribute (could be ugly-ish)
print replay.game_teams(True)
# running output through another included list
print replay.game_matching()
# datetime object returned with date match was played
print replay.timestamp()
# timezone offset as integer
print replay.timezone_offset()
#-------
#pull team information
print "there are %d teams" % len(replay.teams)
# pull team win/loss info
print "Team 1 %s" % replay.teams[0].outcome()
print "Team 2 %s" % replay.teams[1].outcome()
#-------
print "There are %d players on team 1" % len(replay.teams[0].players)
player = replay.teams[0].players[0]
print "%s the %s %s playing as the %s %s" % (
player.handle(),
player.type(),
player.outcome(),
player.color_name(),
player.race())