wizardwerdna-pokerstats 1.0.14 → 1.0.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,93 +1,95 @@
1
- class CashStatistics < HandStatistics::Plugin
2
- def initialize handstatistics
3
- super handstatistics
4
- @posted = {}
5
- @paid = {}
6
- @paid_this_round = {}
7
- @won = {}
8
- @cards = {}
9
- @stats = {:posted => @posted, :paid => @paid, :won => @won, :cards => @cards}
10
- end
1
+ module Pokerstats
2
+ class CashStatistics < HandStatistics::Plugin
3
+ def initialize handstatistics
4
+ super handstatistics
5
+ @posted = {}
6
+ @paid = {}
7
+ @paid_this_round = {}
8
+ @won = {}
9
+ @cards = {}
10
+ @stats = {:posted => @posted, :paid => @paid, :won => @won, :cards => @cards}
11
+ end
11
12
 
12
- def posted(player)
13
- @posted[player]
14
- end
13
+ def posted(player)
14
+ @posted[player]
15
+ end
15
16
 
16
- def paid(player)
17
- @paid[player]
18
- end
17
+ def paid(player)
18
+ @paid[player]
19
+ end
19
20
 
20
- def paid_this_round(player)
21
- @paid_this_round[player]
22
- end
21
+ def paid_this_round(player)
22
+ @paid_this_round[player]
23
+ end
23
24
 
24
- def won(player)
25
- @won[player]
26
- end
25
+ def won(player)
26
+ @won[player]
27
+ end
27
28
 
28
- def cards(player)
29
- @cards[player]
30
- end
29
+ def cards(player)
30
+ @cards[player]
31
+ end
31
32
 
32
- def self.report_specification
33
- [
34
- # [key, sql_type, function]
35
- [:posted, 'decimal', :posted],
36
- [:paid, 'decimal', :paid],
37
- [:won, 'decimal', :won],
38
- [:cards, 'string', :cards]
39
- ]
40
- end
33
+ def self.report_specification
34
+ [
35
+ # [key, sql_type, function]
36
+ [:posted, 'decimal', :posted],
37
+ [:paid, 'decimal', :paid],
38
+ [:won, 'decimal', :won],
39
+ [:cards, 'string', :cards]
40
+ ]
41
+ end
41
42
 
42
- # def report(screen_name)
43
- # {
44
- # :posted => posted(screen_name),
45
- # :paid => paid(screen_name),
46
- # :won => won(screen_name),
47
- # :cards => cards(screen_name)
48
- # }
49
- # end
43
+ # def report(screen_name)
44
+ # {
45
+ # :posted => posted(screen_name),
46
+ # :paid => paid(screen_name),
47
+ # :won => won(screen_name),
48
+ # :cards => cards(screen_name)
49
+ # }
50
+ # end
50
51
 
51
- def stats(player=nil)
52
- return @stats unless player
53
- # @stats.inject({}){|last, pair| last.merge(pair[0] => pair[1][player])}
54
- end
52
+ def stats(player=nil)
53
+ return @stats unless player
54
+ # @stats.inject({}){|last, pair| last.merge(pair[0] => pair[1][player])}
55
+ end
55
56
 
56
- def register_player(screen_name, street)
57
- @posted[screen_name] = 0
58
- @paid[screen_name] = 0
59
- @won[screen_name] = 0
60
- end
57
+ def register_player(screen_name, street)
58
+ @posted[screen_name] = 0
59
+ @paid[screen_name] = 0
60
+ @won[screen_name] = 0
61
+ end
61
62
 
62
- def street_transition_for_player street, player
63
- @paid_this_round[player] = 0 unless street == :preflop
64
- end
63
+ def street_transition_for_player street, player
64
+ @paid_this_round[player] = 0 unless street == :preflop
65
+ end
65
66
 
66
- def apply_action action, street
67
- player = action[:screen_name]
68
- description = action[:description]
69
- result = action[:result]
70
- amount = action[:amount]
71
- data = action[:data]
72
- case result
73
- when :post
74
- @posted[player] += amount
75
- @paid_this_round[player] += amount unless description == "antes"
76
- when :pay
77
- @paid[player] ||= 0
78
- @paid[player] += amount
79
- @paid_this_round[player] += amount
80
- when :pay_to
81
- net_amount_paid = amount - @paid_this_round[player]
82
- action[:net_amount_paid] = net_amount_paid
83
- @paid[player] += net_amount_paid
84
- @paid_this_round[player] += net_amount_paid
85
- when :win
86
- @won[player] += amount
87
- when :neutral
88
- when :cards
89
- @cards[player] = data
90
- else raise "invalid action result: #{result.inspect}"
67
+ def apply_action action, street
68
+ player = action[:screen_name]
69
+ description = action[:description]
70
+ result = action[:result]
71
+ amount = action[:amount]
72
+ data = action[:data]
73
+ case result
74
+ when :post
75
+ @posted[player] += amount
76
+ @paid_this_round[player] += amount unless description == "antes"
77
+ when :pay
78
+ @paid[player] ||= 0
79
+ @paid[player] += amount
80
+ @paid_this_round[player] += amount
81
+ when :pay_to
82
+ net_amount_paid = amount - @paid_this_round[player]
83
+ action[:net_amount_paid] = net_amount_paid
84
+ @paid[player] += net_amount_paid
85
+ @paid_this_round[player] += net_amount_paid
86
+ when :win
87
+ @won[player] += amount
88
+ when :neutral
89
+ when :cards
90
+ @cards[player] = data
91
+ else raise "invalid action result: #{result.inspect}"
92
+ end
91
93
  end
92
94
  end
93
- end
95
+ end
@@ -1,65 +1,67 @@
1
- class ContinuationBetStatistics < HandStatistics::Plugin
2
- def initialize handstatistics
3
- super(handstatistics)
4
- @last_preflop_raiser = nil
5
- @number_preflop_raises = 0
6
- @first_aggressor = {}
7
- @first_aggression_opportunity = {}
8
- @first_aggression_opportunity_taken = {}
9
- end
10
-
11
- def cbet_opportunity?(screen_name, street = :flop)
12
- # puts "cbet_opportunity?(#{screen_name}, #{street})"
13
- # puts @first_aggression_opportunity.inspect
14
- @number_preflop_raises==1 && @last_preflop_raiser==screen_name && @first_aggression_opportunity[street] && @first_aggression_opportunity[street][screen_name]
15
- end
1
+ module Pokerstats
2
+ class ContinuationBetStatistics < HandStatistics::Plugin
3
+ def initialize handstatistics
4
+ super(handstatistics)
5
+ @last_preflop_raiser = nil
6
+ @number_preflop_raises = 0
7
+ @first_aggressor = {}
8
+ @first_aggression_opportunity = {}
9
+ @first_aggression_opportunity_taken = {}
10
+ end
16
11
 
17
- def cbet_opportunity_taken?(screen_name, street = :flop)
18
- cbet_opportunity?(screen_name) && @first_aggression_opportunity_taken[street][screen_name]
19
- end
12
+ def cbet_opportunity?(screen_name, street = :flop)
13
+ # puts "cbet_opportunity?(#{screen_name}, #{street})"
14
+ # puts @first_aggression_opportunity.inspect
15
+ @number_preflop_raises==1 && @last_preflop_raiser==screen_name && @first_aggression_opportunity[street] && @first_aggression_opportunity[street][screen_name]
16
+ end
20
17
 
21
- def self.report_specification
22
- [
23
- # [key, sql_type, function]
24
- [:is_cbet_opportunity, 'integer', :cbet_opportunity?],
25
- [:is_cbet_opportunity_taken, 'integer', :cbet_opportunity_taken?]
26
- ]
27
- end
18
+ def cbet_opportunity_taken?(screen_name, street = :flop)
19
+ cbet_opportunity?(screen_name) && @first_aggression_opportunity_taken[street][screen_name]
20
+ end
28
21
 
29
- #
30
- # def report(screen_name)
31
- # {
32
- # :is_cbet_opportunity => cbet_opportunity?(screen_name),
33
- # :is_cbet_opportunity_taken => cbet_opportunity_taken?(screen_name)
34
- # }
35
- # end
22
+ def self.report_specification
23
+ [
24
+ # [key, sql_type, function]
25
+ [:is_cbet_opportunity, 'integer', :cbet_opportunity?],
26
+ [:is_cbet_opportunity_taken, 'integer', :cbet_opportunity_taken?]
27
+ ]
28
+ end
36
29
 
37
- def street_transition street
38
- @first_aggressor[street] = nil
39
- @first_aggression_opportunity[street] = {}
40
- @first_aggression_opportunity_taken[street] = {}
41
- super(street)
42
- end
30
+ #
31
+ # def report(screen_name)
32
+ # {
33
+ # :is_cbet_opportunity => cbet_opportunity?(screen_name),
34
+ # :is_cbet_opportunity_taken => cbet_opportunity_taken?(screen_name)
35
+ # }
36
+ # end
43
37
 
44
- def street_transition_for_player street, player
45
- @first_aggression_opportunity[street][player] = nil
46
- @first_aggression_opportunity_taken[street][player] = false
47
- end
38
+ def street_transition street
39
+ @first_aggressor[street] = nil
40
+ @first_aggression_opportunity[street] = {}
41
+ @first_aggression_opportunity_taken[street] = {}
42
+ super(street)
43
+ end
48
44
 
49
- def apply_action action, street
50
- player = action[:screen_name]
51
- aggression = action[:aggression]
52
- result = action[:result]
53
- if street == :preflop and result == :pay_to
54
- @number_preflop_raises += 1
55
- @last_preflop_raiser = player
45
+ def street_transition_for_player street, player
46
+ @first_aggression_opportunity[street][player] = nil
47
+ @first_aggression_opportunity_taken[street][player] = false
56
48
  end
57
- if aggression != :neutral && @first_aggressor[street].nil? && @first_aggression_opportunity[street][player].nil?
58
- @first_aggression_opportunity[street][player] = true
59
- if aggression == :aggressive
60
- @first_aggressor[street] = player
61
- @first_aggression_opportunity_taken[street][player] = true
62
- @hand_statistics.players.each {|player| @first_aggression_opportunity[street][player] ||= false}
49
+
50
+ def apply_action action, street
51
+ player = action[:screen_name]
52
+ aggression = action[:aggression]
53
+ result = action[:result]
54
+ if street == :preflop and result == :pay_to
55
+ @number_preflop_raises += 1
56
+ @last_preflop_raiser = player
57
+ end
58
+ if aggression != :neutral && @first_aggressor[street].nil? && @first_aggression_opportunity[street][player].nil?
59
+ @first_aggression_opportunity[street][player] = true
60
+ if aggression == :aggressive
61
+ @first_aggressor[street] = player
62
+ @first_aggression_opportunity_taken[street][player] = true
63
+ @hand_statistics.players.each {|player| @first_aggression_opportunity[street][player] ||= false}
64
+ end
63
65
  end
64
66
  end
65
67
  end
@@ -1,47 +1,49 @@
1
- class PreflopRaiseStatistics < HandStatistics::Plugin
1
+ module Pokerstats
2
+ class PreflopRaiseStatistics < HandStatistics::Plugin
2
3
 
3
- def initialize handstatistics
4
- super handstatistics
5
- @pfr_opportunity = {}
6
- @pfr_opportunity_taken = {}
7
- @pfr_size_in_bb = {}
8
- end
4
+ def initialize handstatistics
5
+ super handstatistics
6
+ @pfr_opportunity = {}
7
+ @pfr_opportunity_taken = {}
8
+ @pfr_size_in_bb = {}
9
+ end
9
10
 
10
- def pfr_opportunity?(screen_name)
11
- @pfr_opportunity[screen_name]
12
- end
11
+ def pfr_opportunity?(screen_name)
12
+ @pfr_opportunity[screen_name]
13
+ end
13
14
 
14
- def pfr_opportunity_taken?(screen_name)
15
- @pfr_opportunity[screen_name] && @pfr_opportunity_taken[screen_name]
16
- end
15
+ def pfr_opportunity_taken?(screen_name)
16
+ @pfr_opportunity[screen_name] && @pfr_opportunity_taken[screen_name]
17
+ end
17
18
 
18
- def self.report_specification
19
- [
20
- # [key, sql_type, function]
21
- [:is_pfr_opportunity, 'integer', :pfr_opportunity?],
22
- [:is_pfr_opportunity_taken, 'integer', :pfr_opportunity_taken?]
23
- ]
24
- end
19
+ def self.report_specification
20
+ [
21
+ # [key, sql_type, function]
22
+ [:is_pfr_opportunity, 'integer', :pfr_opportunity?],
23
+ [:is_pfr_opportunity_taken, 'integer', :pfr_opportunity_taken?]
24
+ ]
25
+ end
25
26
 
26
- # def report screen_name
27
- # {
28
- # :is_pfr_opportunity => pfr_opportunity?(screen_name),
29
- # :is_pfr_opportunity_taken => pfr_opportunity_taken?(screen_name)
30
- # }
31
- # end
27
+ # def report screen_name
28
+ # {
29
+ # :is_pfr_opportunity => pfr_opportunity?(screen_name),
30
+ # :is_pfr_opportunity_taken => pfr_opportunity_taken?(screen_name)
31
+ # }
32
+ # end
32
33
 
33
- def apply_action action, street
34
- # puts "pfr: apply_action #{street}, #{action.inspect}"
35
- result = action[:result]
36
- player = action[:screen_name]
37
- if street == :preflop and [:pay, :pay_to, :neutral].member?(result) and @pfr_opportunity[player].nil?
38
- case result
39
- when :pay, :neutral
40
- @pfr_opportunity[player] = true
41
- @pfr_opportunity_taken[player] = false
42
- when :pay_to
43
- @hand_statistics.players.each {|each_player| @pfr_opportunity[each_player] ||= (each_player == player)}
44
- @pfr_opportunity_taken[player] = true
34
+ def apply_action action, street
35
+ # puts "pfr: apply_action #{street}, #{action.inspect}"
36
+ result = action[:result]
37
+ player = action[:screen_name]
38
+ if street == :preflop and [:pay, :pay_to, :neutral].member?(result) and @pfr_opportunity[player].nil?
39
+ case result
40
+ when :pay, :neutral
41
+ @pfr_opportunity[player] = true
42
+ @pfr_opportunity_taken[player] = false
43
+ when :pay_to
44
+ @hand_statistics.players.each {|each_player| @pfr_opportunity[each_player] ||= (each_player == player)}
45
+ @pfr_opportunity_taken[player] = true
46
+ end
45
47
  end
46
48
  end
47
49
  end
@@ -2,54 +2,56 @@ require 'rubygems'
2
2
  require 'hpricot'
3
3
  require 'open-uri'
4
4
 
5
- class PokerEdge
5
+ module Pokerstats
6
+ class PokerEdge
6
7
 
7
- def initialize screen_name
8
- @screen_name = URI.escape(screen_name)
9
- end
8
+ def initialize screen_name
9
+ @screen_name = URI.escape(screen_name)
10
+ end
10
11
 
11
- def get_response_from_internet
12
- url = "http://www.poker-edge.com/whoami.php?name=#{@screen_name}"
13
- puts url
14
- open(url) do |f|
15
- @response = f.read
12
+ def get_response_from_internet
13
+ url = "http://www.poker-edge.com/whoami.php?name=#{@screen_name}"
14
+ puts url
15
+ open(url) do |f|
16
+ @response = f.read
17
+ end
18
+ @response
16
19
  end
17
- @response
18
- end
19
20
 
20
- def response
21
- @response ||= get_response_from_internet
22
- end
21
+ def response
22
+ @response ||= get_response_from_internet
23
+ end
23
24
 
24
- def preflop_style
25
- if self.response =~ /(Pre-Flop Tend.*\n)/
26
- verbose = $1.gsub(/<\/?[^>]*>/, "")
27
- if verbose =~ /Pre-Flop Tendency: ([^-]*) -/
28
- preflop_style = $1
29
- else
30
- preflop_style = "N/A"
25
+ def preflop_style
26
+ if self.response =~ /(Pre-Flop Tend.*\n)/
27
+ verbose = $1.gsub(/<\/?[^>]*>/, "")
28
+ if verbose =~ /Pre-Flop Tendency: ([^-]*) -/
29
+ preflop_style = $1
30
+ else
31
+ preflop_style = "N/A"
32
+ end
31
33
  end
34
+ preflop_style
32
35
  end
33
- preflop_style
34
- end
35
36
 
36
- def player_type
37
- if response =~ /(Player Type.*\n)/
38
- verbose = $1.gsub(/<\/?[^>]*>/, "")
39
- if verbose =~ /[Yy]ou are a ([^(]* \(.*\))/
40
- player = $1
41
- else
42
- player = ""
37
+ def player_type
38
+ if response =~ /(Player Type.*\n)/
39
+ verbose = $1.gsub(/<\/?[^>]*>/, "")
40
+ if verbose =~ /[Yy]ou are a ([^(]* \(.*\))/
41
+ player = $1
42
+ else
43
+ player = ""
44
+ end
43
45
  end
46
+ player
44
47
  end
45
- player
46
- end
47
48
 
48
- def report format = "%20s -- %s -- %s\n"
49
- open("foo.html", "w+") do |file|
50
- file.write(response)
49
+ def report format = "%20s -- %s -- %s\n"
50
+ open("foo.html", "w+") do |file|
51
+ file.write(response)
52
+ end
53
+ `open foo.html`
54
+ printf(format, @screen_name, preflop_style, player_type)
51
55
  end
52
- `open foo.html`
53
- printf(format, @screen_name, preflop_style, player_type)
54
56
  end
55
57
  end