Skip to content

Commit

Permalink
bin/skadi reflects changes to demo class
Browse files Browse the repository at this point in the history
  • Loading branch information
onethirtyfive committed Aug 31, 2013
1 parent dd4073b commit 9510e5e
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions bin/skadi
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,38 @@ pwd = os.path.dirname(__file__)
root = os.path.abspath(os.path.join(pwd, '..'))
sys.path.append(root)

from skadi import *
from skadi import demo as d
from skadi.engine import world as w


option_parser = optparse.OptionParser()
(options, args) = option_parser.parse_args()

path = args[0]
for abspath in args:
print 'opening {0}...'.format(os.path.basename(abspath))

print '> opening {0}'.format(os.path.basename(path))
demo = d.construct(abspath)

with _io.open(path, 'r+b') as infile:
demo = d.construct(load(infile), infile)
file_info = demo.file_info
print 'playback info:'
print '- time: {}'.format(file_info.playback_time)
print '- ticks: {}'.format(file_info.playback_ticks)
print '- frames: {}'.format(file_info.playback_frames)

print 'player summary:'
for pi in file_info.game_info.dota.player_info:
print '- {} ({})'.format(pi.player_name, pi.hero_name)

for game in demo.stream(tick=5000):
tick, user_msgs, game_evts, world, modifiers = game

print tick
print 't {}'.format(tick)

# Print all active modifiers at every tick.
for ehandle, m_list in modifiers:
try:
# Unfortunately, the modifiers data is kind of messy.
# Sometimes there are modifiers for entities that don't exist.
# This is probably something the game client ignores.
if ehandle in world.by_ehandle:
pretty = map(lambda (_, a): a['name'], m_list.items())
dt = world.fetch_recv_table(ehandle).dt
print ' {dt} (#{eh}): {attrs}'.format(dt=dt, eh=ehandle, attrs=pretty)
except KeyError:
# Unfortunately, the modifiers data is kind of messy.
# Sometimes there are modifiers for entities that don't exist.
# This is probably something the game client ignores.
# Working on it!
pass
print ' {dt} (#{eh}): {attrs}'.format(dt=dt, eh=ehandle, attrs=pretty)

0 comments on commit 9510e5e

Please sign in to comment.