public
Description: my random ruby scripts
Clone URL: git://github.com/kastner/ruby-junk.git
Click here to lend your support to: ruby-junk and make a donation at www.pledgie.com !
Adding Grab and player filtering
kastner (author)
Fri Jul 18 15:14:25 -0700 2008
commit  63963fea9d9e796928b258c5855835fbcd96fa91
tree    9efc21825e22136ac17ebc4ec84d2a6930d0f5ac
parent  b509d21e3d9cd1c275452d5113e6632bff85cffb
...
48
49
50
51
 
 
 
52
53
54
...
56
57
58
59
60
 
61
62
 
63
64
65
 
 
 
 
66
67
68
...
48
49
50
 
51
52
53
54
55
56
...
58
59
60
 
 
61
62
 
63
64
65
66
67
68
69
70
71
72
73
0
@@ -48,7 +48,9 @@ def state_of_joint(state, joint)
0
   end
0
 end
0
 
0
-replay = STDIN.read
0
+raise "usage #{$0} <path to replay file> [<player to show>]" unless ARGV[0]
0
+replay = open(ARGV[0]).read
0
+only_player = ARGV[1].chomp
0
 
0
 @players = {}
0
 replay.each_line do |line|
0
@@ -56,12 +58,15 @@ replay.each_line do |line|
0
   when /BOUT (\d+); (.+)$/
0
     @players[$1.to_i] = $2
0
   when /^FRAME (\d+)/:
0
- puts "Frame: #{$1.to_i}\n"
0
- when /^GRAB/
0
+ puts "\nFrame: #{$1.to_i}\n"
0
   when /^JOINT (0|1); (.*)$/
0
- puts "\tPlayer: #{@players[$1.to_i] || $1.to_i}"
0
+ next if only_player && only_player != @players[$1.to_i]
0
     $2.scan(/\d+\s+\d+/).map {|p| p.split(/\s+/)}.each do |(joint, state)|
0
       puts "\t\t#{state_of_joint(state.to_i, joint.to_i)} #{@joint_list[joint.to_i]}\n"
0
     end
0
+ when /^GRIP (0|1); (0|1) (0|1)/:
0
+ next if only_player && only_player != @players[$1.to_i]
0
+ puts "\t\t#{@players[$1.to_i]} left grip" if ($2 == "1")
0
+ puts "\t\t#{@players[$1.to_i]} right grip" if ($3 == "1")
0
   end
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.