Class: Pokerstats::CashStatistics
- Inherits:
-
HandStatistics::Plugin
- Object
- HandStatistics::Plugin
- Pokerstats::CashStatistics
- Defined in:
- lib/pokerstats/plugins/cash_statistics.rb
Class Method Summary collapse
Instance Method Summary collapse
- #apply_action(action, street) ⇒ Object
- #card_category_index(player) ⇒ Object
- #cards(player) ⇒ Object
- #divided_by_bb(value) ⇒ Object
-
#initialize(handstatistics) ⇒ CashStatistics
constructor
A new instance of CashStatistics.
- #paid(player) ⇒ Object
- #paid_in_bb(player) ⇒ Object
- #paid_this_round(player) ⇒ Object
- #position(player) ⇒ Object
- #posted(player) ⇒ Object
- #posted_in_bb(player) ⇒ Object
- #profit(player) ⇒ Object
- #profit_in_bb(player) ⇒ Object
- #register_player(screen_name, street, player_hash) ⇒ Object
- #seat(player) ⇒ Object
- #starting_pot ⇒ Object
- #starting_stack(player) ⇒ Object
- #starting_stack_as_M(player) ⇒ Object
- #starting_stack_as_M_class(player) ⇒ Object
- #starting_stack_in_bb(player) ⇒ Object
- #stats(player = nil) ⇒ Object
- #street_transition_for_player(street, player) ⇒ Object
- #won(player) ⇒ Object
- #won_in_bb(player) ⇒ Object
Constructor Details
#initialize(handstatistics) ⇒ CashStatistics
Returns a new instance of CashStatistics.
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/pokerstats/plugins/cash_statistics.rb', line 4 def initialize handstatistics super handstatistics @seat = {} @posted = {} @paid = {} @paid_this_round = {} @won = {} @cards = {} @starting_stack = {} @stats = {:posted => @posted, :paid => @paid, :won => @won, :cards => @cards} end |
Class Method Details
.report_specification ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/pokerstats/plugins/cash_statistics.rb', line 114 def self.report_specification [ # [key, sql_type, function] [:seat, 'integer', :seat], [:position, 'integer', :position], [:posted, 'decimal', :posted], [:paid, 'decimal', :paid], [:won, 'decimal', :won], [:profit, 'decimal', :profit], [:posted_in_bb, 'decimal', :posted_in_bb], [:paid_in_bb, 'decimal', :paid_in_bb], [:won_in_bb, 'decimal', :won_in_bb], [:profit_in_bb, 'decimal', :profit_in_bb], [:cards, 'string', :cards], [:card_category_index, 'integer', :card_category_index], [:starting_stack, 'decimal', :starting_stack], [:starting_stack_in_bb, 'decimal', :starting_stack_in_bb], [:starting_stack_as_M, 'decimal', :starting_stack_as_M], [:starting_stack_as_M_class, 'decimal', :starting_stack_as_M_class] ] end |
Instance Method Details
#apply_action(action, street) ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/pokerstats/plugins/cash_statistics.rb', line 153 def apply_action action, street player = action[:screen_name] description = action[:description] result = action[:result] amount = action[:amount] data = action[:data] case result when :post @posted[player] += amount @paid_this_round[player] += amount unless description == "antes" when :pay @paid[player] ||= 0 @paid[player] += amount @paid_this_round[player] += amount when :pay_to net_amount_paid = amount - @paid_this_round[player] action[:net_amount_paid] = net_amount_paid @paid[player] += net_amount_paid @paid_this_round[player] += net_amount_paid when :win @won[player] += amount when :neutral when :cards @cards[player] = data else raise "invalid action result: #{result.inspect}" end end |
#card_category_index(player) ⇒ Object
110 111 112 |
# File 'lib/pokerstats/plugins/cash_statistics.rb', line 110 def card_category_index(player) Pokerstats::HandClass.class_index_from_hand_string(cards(player)) end |
#cards(player) ⇒ Object
68 69 70 |
# File 'lib/pokerstats/plugins/cash_statistics.rb', line 68 def cards(player) @cards[player] end |
#divided_by_bb(value) ⇒ Object
46 47 48 49 50 |
# File 'lib/pokerstats/plugins/cash_statistics.rb', line 46 def divided_by_bb(value) bb = @hand_statistics.report_hand_information[:bb] return nil if bb.nil? || bb.zero? value / (2 * bb) end |
#paid(player) ⇒ Object
34 35 36 |
# File 'lib/pokerstats/plugins/cash_statistics.rb', line 34 def paid(player) @paid[player] end |
#paid_in_bb(player) ⇒ Object
60 61 62 |
# File 'lib/pokerstats/plugins/cash_statistics.rb', line 60 def paid_in_bb(player) divided_by_bb(paid(player)) end |
#paid_this_round(player) ⇒ Object
38 39 40 |
# File 'lib/pokerstats/plugins/cash_statistics.rb', line 38 def paid_this_round(player) @paid_this_round[player] end |
#position(player) ⇒ Object
17 18 19 |
# File 'lib/pokerstats/plugins/cash_statistics.rb', line 17 def position(player) @hand_statistics.position player end |
#posted(player) ⇒ Object
30 31 32 |
# File 'lib/pokerstats/plugins/cash_statistics.rb', line 30 def posted(player) @posted[player] end |
#posted_in_bb(player) ⇒ Object
56 57 58 |
# File 'lib/pokerstats/plugins/cash_statistics.rb', line 56 def posted_in_bb(player) divided_by_bb(posted(player)) end |
#profit(player) ⇒ Object
25 26 27 28 |
# File 'lib/pokerstats/plugins/cash_statistics.rb', line 25 def profit(player) return nil unless won(player) && posted(player) && paid(player) won(player) - posted(player) - paid(player) end |
#profit_in_bb(player) ⇒ Object
52 53 54 |
# File 'lib/pokerstats/plugins/cash_statistics.rb', line 52 def profit_in_bb(player) divided_by_bb(profit(player)) end |
#register_player(screen_name, street, player_hash) ⇒ Object
140 141 142 143 144 145 146 147 |
# File 'lib/pokerstats/plugins/cash_statistics.rb', line 140 def register_player(screen_name, street, player_hash) # puts "register_player(#{screen_name.inspect}, #{street.inspect}, #{player_hash.inspect})" @posted[screen_name] = 0 @paid[screen_name] = 0 @won[screen_name] = 0 @starting_stack[screen_name] = player_hash[:starting_stack] @seat[screen_name] = player_hash[:seat] end |
#seat(player) ⇒ Object
21 22 23 |
# File 'lib/pokerstats/plugins/cash_statistics.rb', line 21 def seat(player) @seat[player] end |
#starting_pot ⇒ Object
80 81 82 83 84 85 86 87 |
# File 'lib/pokerstats/plugins/cash_statistics.rb', line 80 def starting_pot sb = @hand_statistics.report_hand_information[:sb] bb = @hand_statistics.report_hand_information[:bb] ante = @hand_statistics.report_hand_information[:ante] number_players = @hand_statistics.report_hand_information[:number_players] sb && bb && ante && number_players && (sb + bb + ante * number_players) end |
#starting_stack(player) ⇒ Object
72 73 74 |
# File 'lib/pokerstats/plugins/cash_statistics.rb', line 72 def starting_stack(player) @starting_stack[player] end |
#starting_stack_as_M(player) ⇒ Object
89 90 91 92 |
# File 'lib/pokerstats/plugins/cash_statistics.rb', line 89 def starting_stack_as_M(player) starting_stack(player) && starting_pot && (starting_pot > 0) && ("1.0".to_d * starting_stack(player) / starting_pot) end |
#starting_stack_as_M_class(player) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/pokerstats/plugins/cash_statistics.rb', line 94 def starting_stack_as_M_class(player) starting_stack_as_M(player) && case starting_stack_as_M(player) when 0 .. 2.99 "darkred" when 2.99 .. 5.99 "red" when 5.99 .. 9.99 "orange" when 9.99 .. 19.99 "yellow" else "green" end end |
#starting_stack_in_bb(player) ⇒ Object
76 77 78 |
# File 'lib/pokerstats/plugins/cash_statistics.rb', line 76 def starting_stack_in_bb(player) divided_by_bb(starting_stack(player)) end |
#stats(player = nil) ⇒ Object
136 137 138 |
# File 'lib/pokerstats/plugins/cash_statistics.rb', line 136 def stats(player=nil) return @stats unless player end |
#street_transition_for_player(street, player) ⇒ Object
149 150 151 |
# File 'lib/pokerstats/plugins/cash_statistics.rb', line 149 def street_transition_for_player street, player @paid_this_round[player] = 0 unless street == :preflop end |
#won(player) ⇒ Object
42 43 44 |
# File 'lib/pokerstats/plugins/cash_statistics.rb', line 42 def won(player) @won[player] end |
#won_in_bb(player) ⇒ Object
64 65 66 |
# File 'lib/pokerstats/plugins/cash_statistics.rb', line 64 def won_in_bb(player) divided_by_bb(won(player)) end |