pokerstats 2.0.12 → 2.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/pokerstats/hand_classification.rb +78 -0
- data/lib/pokerstats/hand_constants.rb +3 -1
- data/lib/pokerstats/plugins/cash_statistics.rb +42 -15
- data/lib/pokerstats/stat_aggregator.rb +2 -2
- data/pokerstats.gemspec +6 -3
- data/spec/hand_classification_spec.rb +136 -0
- data/spec/hand_statistics_spec.rb +36 -22
- data/spec/hand_statistics_spec_helper.rb +1 -1
- data/spec/stat_aggregator_spec.rb +3 -3
- metadata +5 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.
|
1
|
+
2.0.13
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/hand_constants")
|
2
|
+
module Pokerstats
|
3
|
+
|
4
|
+
def class_index_from_hand_string(hand_string)
|
5
|
+
return class_index_from_hand_string!(hand_string)
|
6
|
+
rescue ArgumentError
|
7
|
+
nil
|
8
|
+
end
|
9
|
+
|
10
|
+
def class_index_from_hand_string!(hand_string)
|
11
|
+
class_index_from_class_string(class_string_from_hand_string(hand_string))
|
12
|
+
end
|
13
|
+
|
14
|
+
def class_string_from_hand_string(hand_string)
|
15
|
+
raise ArgumentError, "hand_string '#{hand_string}' must be a String" unless hand_string.kind_of?(String)
|
16
|
+
hand_string = hand_string.gsub(/ /,'')
|
17
|
+
hand_string = hand_string.upcase
|
18
|
+
raise ArgumentError, "hand_string '#{hand_string}' must have 4 non-blank characters" unless hand_string.size==4
|
19
|
+
first_rank, first_suit, second_rank, secondSuit = *hand_string.split('')
|
20
|
+
raise ArgumentError, "hand_string #{hand_string.inspect} suit characters #{first_suit.inspect} and #{secondSuit.inspect} must be from CDHS" unless "CDHS".include?(first_suit) && "CDHS".include?(secondSuit)
|
21
|
+
first_rank_index, second_rank_index = Pokerstats::HandConstants::CARDS.index(first_rank), Pokerstats::HandConstants::CARDS.index(second_rank)
|
22
|
+
raise ArgumentError, "hand_string '#{hand_string}' rank characters must be from AKQJT98765432" if first_rank_index.nil? || second_rank_index.nil?
|
23
|
+
if first_rank==second_rank
|
24
|
+
raise ArgumentError, "hand_string '#{hand_string}' cards must be different" if first_suit == secondSuit || !"CDHS".include?(first_suit)
|
25
|
+
first_rank*2
|
26
|
+
else
|
27
|
+
if first_rank_index > second_rank_index
|
28
|
+
result = first_rank + second_rank
|
29
|
+
else
|
30
|
+
result = second_rank + first_rank
|
31
|
+
end
|
32
|
+
if first_suit == secondSuit
|
33
|
+
result += "s"
|
34
|
+
end
|
35
|
+
result
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def class_index_from_class_string(class_string)
|
40
|
+
raise ArgumentError, "class_string #{class_string.inspect} must be a String" unless class_string.kind_of?(String)
|
41
|
+
class_string.upcase!
|
42
|
+
first = Pokerstats::HandConstants::CARDS.index(class_string[0..0])
|
43
|
+
second = Pokerstats::HandConstants::CARDS.index(class_string[1..1])
|
44
|
+
first, second = second, first if first > second
|
45
|
+
raise ArgumentError, "class_string is malformed" if first.nil? || second.nil?
|
46
|
+
case class_string[2..2]
|
47
|
+
when "S","P"
|
48
|
+
13*first+second
|
49
|
+
when "O",""
|
50
|
+
13*second+first
|
51
|
+
else raise ArgumentError, "class_string is malformed"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def class_string_from_class_index(classIndex)
|
56
|
+
row, col = row_from_class_index(classIndex), col_from_class_index(classIndex)
|
57
|
+
case row <=> col
|
58
|
+
when 1
|
59
|
+
Pokerstats::HandConstants::CARDS[col..col] + Pokerstats::HandConstants::CARDS[row..row] + "o"
|
60
|
+
when 0
|
61
|
+
Pokerstats::HandConstants::CARDS[row..row]*2
|
62
|
+
when -1
|
63
|
+
Pokerstats::HandConstants::CARDS[row..row] + Pokerstats::HandConstants::CARDS[col..col] + "s"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def row_from_class_index(classIndex)
|
68
|
+
classIndex / 13
|
69
|
+
end
|
70
|
+
|
71
|
+
def col_from_class_index(classIndex)
|
72
|
+
classIndex % 13
|
73
|
+
end
|
74
|
+
|
75
|
+
def class_index_from_row_and_col(row, col)
|
76
|
+
row*13 + col
|
77
|
+
end
|
78
|
+
end
|
@@ -10,7 +10,7 @@ module Pokerstats
|
|
10
10
|
[:bb, 'decimal'],
|
11
11
|
[:board, 'string'],
|
12
12
|
[:total_pot, 'decimal'],
|
13
|
-
[:rake, 'decimal'],
|
13
|
+
[:rake, 'decimal'],
|
14
14
|
[:played_at, 'datetime'],
|
15
15
|
[:tournament, 'string']
|
16
16
|
]
|
@@ -23,5 +23,7 @@ module Pokerstats
|
|
23
23
|
PLAYER_RECORDS_OUT_OF_BALANCE = "hand record is out of balance"
|
24
24
|
|
25
25
|
MAX_SEATS = 12
|
26
|
+
|
27
|
+
CARDS = "AKQJT98765432"
|
26
28
|
end
|
27
29
|
end
|
@@ -9,7 +9,12 @@ module Pokerstats
|
|
9
9
|
@cards = {}
|
10
10
|
@stats = {:posted => @posted, :paid => @paid, :won => @won, :cards => @cards}
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
|
+
def profit(player)
|
14
|
+
return nil unless won(player) && posted(player) && paid(player)
|
15
|
+
won(player) - posted(player) - paid(player)
|
16
|
+
end
|
17
|
+
|
13
18
|
def posted(player)
|
14
19
|
@posted[player]
|
15
20
|
end
|
@@ -25,33 +30,55 @@ module Pokerstats
|
|
25
30
|
def won(player)
|
26
31
|
@won[player]
|
27
32
|
end
|
33
|
+
|
34
|
+
def divided_by_bb(value)
|
35
|
+
bb = @hand_statistics.report_hand_information[:bb]
|
36
|
+
return nil if bb.nil? || bb.zero?
|
37
|
+
value / bb
|
38
|
+
end
|
39
|
+
|
40
|
+
def profit_in_bb(player)
|
41
|
+
divided_by_bb(profit(player))
|
42
|
+
end
|
43
|
+
|
44
|
+
def posted_in_bb(player)
|
45
|
+
divided_by_bb(posted(player))
|
46
|
+
end
|
47
|
+
|
48
|
+
def paid_in_bb(player)
|
49
|
+
divided_by_bb(paid(player))
|
50
|
+
end
|
51
|
+
|
52
|
+
def won_in_bb(player)
|
53
|
+
divided_by_bb(won(player))
|
54
|
+
end
|
28
55
|
|
29
56
|
def cards(player)
|
30
57
|
@cards[player]
|
31
58
|
end
|
59
|
+
|
60
|
+
def card_category_index(player)
|
61
|
+
Pokerstats::class_index_from_hand_string(cards(player))
|
62
|
+
end
|
32
63
|
|
33
64
|
def self.report_specification
|
34
65
|
[
|
35
66
|
# [key, sql_type, function]
|
36
|
-
[:posted,
|
37
|
-
[:paid,
|
38
|
-
[:won,
|
39
|
-
[:
|
67
|
+
[:posted, 'decimal', :posted],
|
68
|
+
[:paid, 'decimal', :paid],
|
69
|
+
[:won, 'decimal', :won],
|
70
|
+
[:profit, 'decimal', :profit],
|
71
|
+
[:posted_in_bb, 'string', :posted_in_bb],
|
72
|
+
[:paid_in_bb, 'string', :paid_in_bb],
|
73
|
+
[:won_in_bb, 'string', :won_in_bb],
|
74
|
+
[:profit_in_bb, 'string', :profit_in_bb],
|
75
|
+
[:cards, 'string', :cards],
|
76
|
+
[:card_category_index, 'integer', :card_category_index]
|
40
77
|
]
|
41
78
|
end
|
42
79
|
|
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
|
51
|
-
|
52
80
|
def stats(player=nil)
|
53
81
|
return @stats unless player
|
54
|
-
# @stats.inject({}){|last, pair| last.merge(pair[0] => pair[1][player])}
|
55
82
|
end
|
56
83
|
|
57
84
|
def register_player(screen_name, street)
|
@@ -15,7 +15,7 @@ module Pokerstats
|
|
15
15
|
|
16
16
|
def apply hash
|
17
17
|
@specification.each do |key, value|
|
18
|
-
puts "applying specification #{key.inspect} with value specification #{value.inspect}"
|
18
|
+
# puts "applying specification #{key.inspect} with value specification #{value.inspect}"
|
19
19
|
# determine datum value from specification
|
20
20
|
datum = case value
|
21
21
|
when Symbol
|
@@ -26,7 +26,7 @@ module Pokerstats
|
|
26
26
|
raise RuntimeError, "there is no valid specification for datum #{key.inspect}"
|
27
27
|
end
|
28
28
|
|
29
|
-
puts "... resulting in datum #{datum.inspect}"
|
29
|
+
# puts "... resulting in datum #{datum.inspect}"
|
30
30
|
# apply datum value to aggregated data
|
31
31
|
unless datum.nil?
|
32
32
|
@data[key].items+=1
|
data/pokerstats.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{pokerstats}
|
8
|
-
s.version = "2.0.
|
8
|
+
s.version = "2.0.13"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Andrew C. Greenberg"]
|
12
|
-
s.date = %q{2009-11-
|
12
|
+
s.date = %q{2009-11-09}
|
13
13
|
s.default_executable = %q{checkps}
|
14
14
|
s.description = %q{a library for extracting, computing and reporting statistics of poker hands parsed from hand history files}
|
15
15
|
s.email = %q{wizardwerdna@gmail.com}
|
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
|
|
31
31
|
"generators/pokerstats/templates/create_pokerstats.rhtml",
|
32
32
|
"lib/pokerstats.rb",
|
33
33
|
"lib/pokerstats/.gitignore",
|
34
|
+
"lib/pokerstats/hand_classification.rb",
|
34
35
|
"lib/pokerstats/hand_constants.rb",
|
35
36
|
"lib/pokerstats/hand_history.rb",
|
36
37
|
"lib/pokerstats/hand_statistics.rb",
|
@@ -49,6 +50,7 @@ Gem::Specification.new do |s|
|
|
49
50
|
"spec/file_empty.txt",
|
50
51
|
"spec/file_many_hands.txt",
|
51
52
|
"spec/file_one_hand.txt",
|
53
|
+
"spec/hand_classification_spec.rb",
|
52
54
|
"spec/hand_statistics_spec.rb",
|
53
55
|
"spec/hand_statistics_spec_helper.rb",
|
54
56
|
"spec/player_statistics_spec.rb",
|
@@ -64,7 +66,8 @@ Gem::Specification.new do |s|
|
|
64
66
|
s.rubygems_version = %q{1.3.5}
|
65
67
|
s.summary = %q{poker hand history statistics library}
|
66
68
|
s.test_files = [
|
67
|
-
"spec/
|
69
|
+
"spec/hand_classification_spec.rb",
|
70
|
+
"spec/hand_statistics_spec.rb",
|
68
71
|
"spec/hand_statistics_spec_helper.rb",
|
69
72
|
"spec/player_statistics_spec.rb",
|
70
73
|
"spec/pokerstars_file_spec.rb",
|
@@ -0,0 +1,136 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/pokerstats/hand_classification')
|
3
|
+
|
4
|
+
include Pokerstats
|
5
|
+
describe "class_index_from_hand_string" do
|
6
|
+
it "should recognize pairs" do
|
7
|
+
Pokerstats::class_index_from_hand_string("AS AH").should == 0
|
8
|
+
Pokerstats::class_index_from_hand_string("kd kc").should == 14
|
9
|
+
Pokerstats::class_index_from_hand_string("2H 2D").should == 168
|
10
|
+
Pokerstats::class_index_from_hand_string("KdkC").should == 14
|
11
|
+
Pokerstats::class_index_from_hand_string(" Kd kC").should == 14
|
12
|
+
Pokerstats::class_index_from_hand_string(" Kd kC ").should == 14
|
13
|
+
end
|
14
|
+
it "should recognize suited hands" do
|
15
|
+
Pokerstats::class_index_from_hand_string("AS KS").should == 1
|
16
|
+
Pokerstats::class_index_from_hand_string("AS 2S").should == 12
|
17
|
+
Pokerstats::class_index_from_hand_string("3S 2S").should == 155
|
18
|
+
Pokerstats::class_index_from_hand_string("AS 2s").should == 12
|
19
|
+
Pokerstats::class_index_from_hand_string("aS 2S").should == 12
|
20
|
+
Pokerstats::class_index_from_hand_string("As 2s").should == 12
|
21
|
+
end
|
22
|
+
it "should recognize unsuited hands" do
|
23
|
+
Pokerstats::class_index_from_hand_string("AS Kh").should == 13
|
24
|
+
Pokerstats::class_index_from_hand_string("Ad 2c").should == 156
|
25
|
+
Pokerstats::class_index_from_hand_string("3c 2S").should == 167
|
26
|
+
Pokerstats::class_index_from_hand_string("AS 2h").should == 156
|
27
|
+
Pokerstats::class_index_from_hand_string("aS 2d").should == 156
|
28
|
+
Pokerstats::class_index_from_hand_string("As 2c").should == 156
|
29
|
+
end
|
30
|
+
it "should not recognize malformed hands" do
|
31
|
+
Pokerstats::class_index_from_hand_string("AS AS").should be_nil
|
32
|
+
Pokerstats::class_index_from_hand_string("XS AH").should be_nil
|
33
|
+
Pokerstats::class_index_from_hand_string("AS XH").should be_nil
|
34
|
+
Pokerstats::class_index_from_hand_string("AX AS").should be_nil
|
35
|
+
Pokerstats::class_index_from_hand_string("AX AX").should be_nil
|
36
|
+
lambda{Pokerstats::class_index_from_hand_string!("AS AS")}.should raise_error(ArgumentError)
|
37
|
+
lambda{Pokerstats::class_index_from_hand_string!("XS AH")}.should raise_error(ArgumentError)
|
38
|
+
lambda{Pokerstats::class_index_from_hand_string!("AS XH")}.should raise_error(ArgumentError)
|
39
|
+
lambda{Pokerstats::class_index_from_hand_string!("AX AS")}.should raise_error(ArgumentError)
|
40
|
+
lambda{Pokerstats::class_index_from_hand_string!("AX AX")}.should raise_error(ArgumentError)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
describe "class_index_from_class_string" do
|
44
|
+
it "should recognize pairs" do
|
45
|
+
Pokerstats::class_index_from_class_string("AA").should == 0
|
46
|
+
Pokerstats::class_index_from_class_string("KK").should == 14
|
47
|
+
Pokerstats::class_index_from_class_string("22").should == 168
|
48
|
+
Pokerstats::class_index_from_class_string("KKp").should == 14
|
49
|
+
Pokerstats::class_index_from_class_string("KKP").should == 14
|
50
|
+
end
|
51
|
+
it "should recognize suited hands" do
|
52
|
+
Pokerstats::class_index_from_class_string("AKs").should == 1
|
53
|
+
Pokerstats::class_index_from_class_string("A2s").should == 12
|
54
|
+
Pokerstats::class_index_from_class_string("32s").should == 155
|
55
|
+
Pokerstats::class_index_from_class_string("A2S").should == 12
|
56
|
+
Pokerstats::class_index_from_class_string("2As").should == 12
|
57
|
+
end
|
58
|
+
it "should recognize unsuited hands" do
|
59
|
+
Pokerstats::class_index_from_class_string("AKo").should == 13
|
60
|
+
Pokerstats::class_index_from_class_string("A2o").should == 156
|
61
|
+
Pokerstats::class_index_from_class_string("32o").should == 167
|
62
|
+
Pokerstats::class_index_from_class_string("A2O").should == 156
|
63
|
+
Pokerstats::class_index_from_class_string("A2").should == 156
|
64
|
+
Pokerstats::class_index_from_class_string("2AO").should == 156
|
65
|
+
end
|
66
|
+
end
|
67
|
+
describe "class_string_from_class_index" do
|
68
|
+
it "should recognize pairs" do
|
69
|
+
Pokerstats::class_string_from_class_index(0).should == "AA"
|
70
|
+
Pokerstats::class_string_from_class_index(14).should == "KK"
|
71
|
+
Pokerstats::class_string_from_class_index(168).should == "22"
|
72
|
+
end
|
73
|
+
it "should recognize suited hands" do
|
74
|
+
Pokerstats::class_string_from_class_index(1).should == "AKs"
|
75
|
+
Pokerstats::class_string_from_class_index(12).should == "A2s"
|
76
|
+
Pokerstats::class_string_from_class_index(155).should == "32s"
|
77
|
+
end
|
78
|
+
it "should recognize unsuited hands" do
|
79
|
+
Pokerstats::class_string_from_class_index(13).should == "AKo"
|
80
|
+
Pokerstats::class_string_from_class_index(156).should == "A2o"
|
81
|
+
Pokerstats::class_string_from_class_index(167).should == "32o"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
describe "row_from_class_index" do
|
85
|
+
it "should recognize first row indices" do
|
86
|
+
Pokerstats::row_from_class_index(0).should == 0
|
87
|
+
Pokerstats::row_from_class_index(7).should == 0
|
88
|
+
Pokerstats::row_from_class_index(12).should == 0
|
89
|
+
end
|
90
|
+
it "should recognize middle row indices" do
|
91
|
+
Pokerstats::row_from_class_index(78).should == 6
|
92
|
+
Pokerstats::row_from_class_index(88).should == 6
|
93
|
+
Pokerstats::row_from_class_index(90).should == 6
|
94
|
+
end
|
95
|
+
it "should recognize last row indices" do
|
96
|
+
Pokerstats::row_from_class_index(156).should == 12
|
97
|
+
Pokerstats::row_from_class_index(165).should == 12
|
98
|
+
Pokerstats::row_from_class_index(168).should == 12
|
99
|
+
end
|
100
|
+
end
|
101
|
+
describe "col_from_class_index" do
|
102
|
+
it "should recognize first col indices" do
|
103
|
+
Pokerstats::col_from_class_index(0).should == 0
|
104
|
+
Pokerstats::col_from_class_index(78).should == 0
|
105
|
+
Pokerstats::col_from_class_index(156).should == 0
|
106
|
+
|
107
|
+
end
|
108
|
+
it "should recognize middle col indices" do
|
109
|
+
Pokerstats::col_from_class_index(7).should == 7
|
110
|
+
Pokerstats::col_from_class_index(85).should == 7
|
111
|
+
Pokerstats::col_from_class_index(163).should == 7
|
112
|
+
|
113
|
+
end
|
114
|
+
it "should recognize last col indices" do
|
115
|
+
Pokerstats::col_from_class_index(12).should == 12
|
116
|
+
Pokerstats::col_from_class_index(90).should == 12
|
117
|
+
Pokerstats::col_from_class_index(168).should == 12
|
118
|
+
end
|
119
|
+
end
|
120
|
+
describe "class_index_from_row_and_col" do
|
121
|
+
it "should recognize top row" do
|
122
|
+
Pokerstats::class_index_from_row_and_col(0,0) == 0
|
123
|
+
Pokerstats::class_index_from_row_and_col(0,7) == 7
|
124
|
+
Pokerstats::class_index_from_row_and_col(0,12) == 12
|
125
|
+
end
|
126
|
+
it "should recognize middle row pairs" do
|
127
|
+
Pokerstats::class_index_from_row_and_col(7,0) == 84
|
128
|
+
Pokerstats::class_index_from_row_and_col(7,7) == 91
|
129
|
+
Pokerstats::class_index_from_row_and_col(7,12) == 96
|
130
|
+
end
|
131
|
+
it "should recognize last row pairs" do
|
132
|
+
Pokerstats::class_index_from_row_and_col(12,0) == 156
|
133
|
+
Pokerstats::class_index_from_row_and_col(12,7) == 163
|
134
|
+
Pokerstats::class_index_from_row_and_col(12,12) == 168
|
135
|
+
end
|
136
|
+
end
|
@@ -2,11 +2,11 @@ require 'rubygems'
|
|
2
2
|
require 'activesupport'
|
3
3
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
4
4
|
require File.expand_path(File.dirname(__FILE__) + '/../lib/pokerstats/hand_statistics')
|
5
|
-
|
5
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/pokerstats/hand_classification')
|
6
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/pokerstats/pokerstars_hand_history_parser')
|
6
7
|
include Pokerstats
|
7
8
|
require File.expand_path(File.dirname(__FILE__) + '/hand_statistics_spec_helper')
|
8
9
|
|
9
|
-
|
10
10
|
Spec::Matchers.define :have_all_and_only_keys do |keylist|
|
11
11
|
match do |hash|
|
12
12
|
hashkeys = hash.keys
|
@@ -27,6 +27,7 @@ describe HandStatistics, "when created" do
|
|
27
27
|
before(:each) do
|
28
28
|
@stats = HandStatistics.new
|
29
29
|
end
|
30
|
+
|
30
31
|
it "should return an empty player list" do
|
31
32
|
@stats.should have(0).players
|
32
33
|
end
|
@@ -239,27 +240,43 @@ describe HandStatistics, "when registering standard actions" do
|
|
239
240
|
end
|
240
241
|
|
241
242
|
it "should post correctly" do
|
242
|
-
lambda{
|
243
|
-
|
244
|
-
|
243
|
+
post_action = lambda{register_post(sample_player, "5".to_d)}
|
244
|
+
post_action.should change{@stats.posted(sample_player[:screen_name])}.by("5".to_d)
|
245
|
+
post_action.should change{@stats.profit(sample_player[:screen_name])}.by("5".to_d * -1)
|
246
|
+
post_action.should change{@stats.posted_in_bb(sample_player[:screen_name])}.by("2.5".to_d)
|
247
|
+
post_action.should change{@stats.profit_in_bb(sample_player[:screen_name])}.by("2.5".to_d * -1)
|
248
|
+
post_action.should_not change{@stats.paid(sample_player[:screen_name])}
|
249
|
+
post_action.should_not change{@stats.won(sample_player[:screen_name])}
|
245
250
|
end
|
246
251
|
|
247
252
|
it "should ante correctly" do
|
248
|
-
lambda{
|
249
|
-
|
250
|
-
|
253
|
+
ante_action = lambda{register_ante(sample_player, "5".to_d)}
|
254
|
+
ante_action.should change{@stats.posted(sample_player[:screen_name])}.by("5".to_d)
|
255
|
+
ante_action.should change{@stats.profit(sample_player[:screen_name])}.by("5".to_d * -1)
|
256
|
+
ante_action.should change{@stats.posted_in_bb(sample_player[:screen_name])}.by("2.5".to_d)
|
257
|
+
ante_action.should change{@stats.profit_in_bb(sample_player[:screen_name])}.by("2.5".to_d * -1)
|
258
|
+
ante_action.should_not change{@stats.paid(sample_player[:screen_name])}
|
259
|
+
ante_action.should_not change{@stats.won(sample_player[:screen_name])}
|
251
260
|
end
|
252
261
|
|
253
262
|
it "should pay correctly" do
|
254
|
-
lambda{
|
255
|
-
|
256
|
-
|
263
|
+
pay_action = lambda{register_bet(sample_player, "5".to_d)}
|
264
|
+
pay_action.should change{@stats.paid(sample_player[:screen_name])}.by("5".to_d)
|
265
|
+
pay_action.should change{@stats.profit(sample_player[:screen_name])}.by("5".to_d * -1)
|
266
|
+
pay_action.should change{@stats.paid_in_bb(sample_player[:screen_name])}.by("2.5".to_d)
|
267
|
+
pay_action.should change{@stats.profit_in_bb(sample_player[:screen_name])}.by("2.5".to_d * -1)
|
268
|
+
pay_action.should_not change{@stats.posted(sample_player[:screen_name])}
|
269
|
+
pay_action.should_not change{@stats.won(sample_player[:screen_name])}
|
257
270
|
end
|
258
271
|
|
259
272
|
it "should win correctly" do
|
260
|
-
lambda{
|
261
|
-
|
262
|
-
|
273
|
+
win_action = lambda{register_win(sample_player, "5".to_d)}
|
274
|
+
win_action.should change{@stats.won(sample_player[:screen_name])}.by("5".to_d)
|
275
|
+
win_action.should change{@stats.profit(sample_player[:screen_name])}.by("5".to_d)
|
276
|
+
win_action.should change{@stats.won_in_bb(sample_player[:screen_name])}.by("2.5".to_d)
|
277
|
+
win_action.should change{@stats.profit_in_bb(sample_player[:screen_name])}.by("2.5".to_d)
|
278
|
+
win_action.should_not change{@stats.paid(sample_player[:screen_name])}
|
279
|
+
win_action.should_not change{@stats.posted(sample_player[:screen_name])}
|
263
280
|
end
|
264
281
|
|
265
282
|
it "should check correctly" do
|
@@ -277,6 +294,8 @@ describe HandStatistics, "when registering standard actions" do
|
|
277
294
|
it "should show cards correctly" do
|
278
295
|
register_cards(sample_player, "AH KH")
|
279
296
|
@stats.cards(sample_player[:screen_name]).should == "AH KH"
|
297
|
+
puts "<<#{@stats.card_category_index(sample_player[:screen_name])}>>"
|
298
|
+
@stats.card_category_index(sample_player[:screen_name]).should == Pokerstats::class_index_from_hand_string("AH KH")
|
280
299
|
end
|
281
300
|
end
|
282
301
|
|
@@ -813,15 +832,10 @@ describe HandStatistics, "when reporting statistics" do
|
|
813
832
|
end
|
814
833
|
|
815
834
|
it "should report cash statistics for each player" do
|
816
|
-
|
817
|
-
@cash_plugin.should_receive(
|
818
|
-
@cash_plugin.should_receive(:won).exactly(@stats.players.size)
|
819
|
-
@cash_plugin.should_receive(:cards).exactly(@stats.players.size)
|
835
|
+
report_items = [:cards, :card_category_index, :posted, :paid, :won, :profit, :posted_in_bb, :paid_in_bb, :won_in_bb, :profit_in_bb]
|
836
|
+
report_items.each{|report_item| @cash_plugin.should_receive(report_item).exactly(@stats.players.size)}
|
820
837
|
@reports = @stats.reports
|
821
|
-
|
822
|
-
@stats.players.each{|each| @reports[each].should include(:paid)}
|
823
|
-
@stats.players.each{|each| @reports[each].should include(:won)}
|
824
|
-
@stats.players.each{|each| @reports[each].should include(:cards)}
|
838
|
+
report_items.each{|report_item|@stats.players.each{|each| @reports[each].should include(report_item)}}
|
825
839
|
end
|
826
840
|
|
827
841
|
it "should report aggression statistics for each player" do
|
@@ -89,9 +89,9 @@ describe Pokerstats::StatAggregator do
|
|
89
89
|
ALL_DATA_ITEMS.each{|item| @stat_aggregator.apply item}
|
90
90
|
end
|
91
91
|
it "generates data with the correct applied values with a numeric and a boolean true result" do
|
92
|
-
puts ALL_DATA_ITEMS.to_yaml
|
93
|
-
puts EXPECTED_AGGREGATION_REPORT.to_yaml
|
94
|
-
puts @stat_aggregator.data.to_yaml
|
92
|
+
# puts ALL_DATA_ITEMS.to_yaml
|
93
|
+
# puts EXPECTED_AGGREGATION_REPORT.to_yaml
|
94
|
+
# puts @stat_aggregator.data.to_yaml
|
95
95
|
@stat_aggregator.data.should == EXPECTED_AGGREGATION_REPORT
|
96
96
|
end
|
97
97
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pokerstats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew C. Greenberg
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-09 00:00:00 -08:00
|
13
13
|
default_executable: checkps
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -64,6 +64,7 @@ files:
|
|
64
64
|
- generators/pokerstats/templates/create_pokerstats.rhtml
|
65
65
|
- lib/pokerstats.rb
|
66
66
|
- lib/pokerstats/.gitignore
|
67
|
+
- lib/pokerstats/hand_classification.rb
|
67
68
|
- lib/pokerstats/hand_constants.rb
|
68
69
|
- lib/pokerstats/hand_history.rb
|
69
70
|
- lib/pokerstats/hand_statistics.rb
|
@@ -82,6 +83,7 @@ files:
|
|
82
83
|
- spec/file_empty.txt
|
83
84
|
- spec/file_many_hands.txt
|
84
85
|
- spec/file_one_hand.txt
|
86
|
+
- spec/hand_classification_spec.rb
|
85
87
|
- spec/hand_statistics_spec.rb
|
86
88
|
- spec/hand_statistics_spec_helper.rb
|
87
89
|
- spec/player_statistics_spec.rb
|
@@ -119,6 +121,7 @@ signing_key:
|
|
119
121
|
specification_version: 3
|
120
122
|
summary: poker hand history statistics library
|
121
123
|
test_files:
|
124
|
+
- spec/hand_classification_spec.rb
|
122
125
|
- spec/hand_statistics_spec.rb
|
123
126
|
- spec/hand_statistics_spec_helper.rb
|
124
127
|
- spec/player_statistics_spec.rb
|