Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 73 lines (66 sloc) 1.961 kb
b509d21 @kastner Tori replayer parser
authored
1 #!/usr/bin/env ruby
2
3 @joint_list = {
4 0 => "Neck",
5 1 => "Chest",
6 2 => "Lumbar",
7 3 => "Abs",
8 4 => "Right pec",
9 5 => "Right shoulder",
10 6 => "Right elbow",
11 7 => "Left pec",
12 8 => "Left shoulder",
13 9 => "Left elbow",
14 10 => "Right wrist",
15 11 => "Left wrist",
16 12 => "Right glute",
17 13 => "Left glute",
18 14 => "Right hip",
19 15 => "Left hip",
20 16 => "Right knee",
21 17 => "Left knee",
22 18 => "Right ankle",
23 19 => "Left ankle"
24 }
25
26 @joint_states = {
27 1 => ["Extend", "Lower", "Right Rotate", "Right Bend"],
28 2 => ["Contract", "Raise", "Left Rotate", "Left Bend"],
29 3 => "Hold",
30 4 => "Relax"
31 }
32
33
34 def state_of_joint(state, joint)
35 return @joint_states[state] if state == 3 || state == 4
36
37 case joint
38 when 1: # rotate (neck)
39 return @joint_states[state][2]
40 when 2: # bend (lumbar)
41 return @joint_states[state][3]
42 when 5,8: # lower/raise (shoulder)
43 return @joint_states[state][1]
44 when 12,13,14,15: # extend/contract reversed
45 return @joint_states[((state == 1) ? 2 : 1)][0]
46 else
47 return @joint_states[state][0]
48 end
49 end
50
63963fe @kastner Adding Grab and player filtering
authored
51 raise "usage #{$0} <path to replay file> [<player to show>]" unless ARGV[0]
52 replay = open(ARGV[0]).read
ed456fc @kastner two bugs - chomp when empty and removed the name
authored
53 only_player = (ARGV[1] && ARGV[1].chomp)
b509d21 @kastner Tori replayer parser
authored
54
55 @players = {}
56 replay.each_line do |line|
57 case line
58 when /BOUT (\d+); (.+)$/
59 @players[$1.to_i] = $2
60 when /^FRAME (\d+)/:
63963fe @kastner Adding Grab and player filtering
authored
61 puts "\nFrame: #{$1.to_i}\n"
b509d21 @kastner Tori replayer parser
authored
62 when /^JOINT (0|1); (.*)$/
63963fe @kastner Adding Grab and player filtering
authored
63 next if only_player && only_player != @players[$1.to_i]
ed456fc @kastner two bugs - chomp when empty and removed the name
authored
64 puts "\n\tPlayer: #{@players[$1.to_i] || $1.to_i}"
b509d21 @kastner Tori replayer parser
authored
65 $2.scan(/\d+\s+\d+/).map {|p| p.split(/\s+/)}.each do |(joint, state)|
66 puts "\t\t#{state_of_joint(state.to_i, joint.to_i)} #{@joint_list[joint.to_i]}\n"
67 end
63963fe @kastner Adding Grab and player filtering
authored
68 when /^GRIP (0|1); (0|1) (0|1)/:
69 next if only_player && only_player != @players[$1.to_i]
70 puts "\t\t#{@players[$1.to_i]} left grip" if ($2 == "1")
71 puts "\t\t#{@players[$1.to_i]} right grip" if ($3 == "1")
b509d21 @kastner Tori replayer parser
authored
72 end
73 end
Something went wrong with that request. Please try again.