Class: Pokerstats::PreflopRaiseStatistics

Inherits:
HandStatistics::Plugin
  • Object
show all
Defined in:
lib/pokerstats/plugins/preflop_raise_statistics.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(handstatistics) ⇒ PreflopRaiseStatistics

Returns a new instance of PreflopRaiseStatistics.



4
5
6
7
8
9
# File 'lib/pokerstats/plugins/preflop_raise_statistics.rb', line 4

def initialize handstatistics
  super handstatistics
  @pfr_opportunity = {}
  @pfr_opportunity_taken = {}
  @pfr_size_in_bb = {}
end

Class Method Details

.report_specificationObject



19
20
21
22
23
24
25
# File 'lib/pokerstats/plugins/preflop_raise_statistics.rb', line 19

def self.report_specification
  [
    # [key,                     sql_type,   function]
    [:is_pfr_opportunity,       'integer',  :pfr_opportunity?],
    [:is_pfr_opportunity_taken, 'integer',  :pfr_opportunity_taken?]
  ]
end

Instance Method Details

#apply_action(action, street) ⇒ Object

def report screen_name

{
  :is_pfr_opportunity => pfr_opportunity?(screen_name),
  :is_pfr_opportunity_taken => pfr_opportunity_taken?(screen_name)
}

end



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/pokerstats/plugins/preflop_raise_statistics.rb', line 34

def apply_action action, street
  # puts "pfr: apply_action #{street}, #{action.inspect}"
  result = action[:result]
  player = action[:screen_name]
  if street == :preflop and [:pay, :pay_to, :neutral].member?(result) and @pfr_opportunity[player].nil?
    case result
    when :pay, :neutral
      @pfr_opportunity[player] = true
      @pfr_opportunity_taken[player] = false
    when :pay_to
      @hand_statistics.players.each {|each_player| @pfr_opportunity[each_player] ||= (each_player == player)}
      @pfr_opportunity_taken[player] = true
    end
  end
end

#pfr_opportunity?(screen_name) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/pokerstats/plugins/preflop_raise_statistics.rb', line 11

def pfr_opportunity?(screen_name)
  @pfr_opportunity[screen_name]
end

#pfr_opportunity_taken?(screen_name) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/pokerstats/plugins/preflop_raise_statistics.rb', line 15

def pfr_opportunity_taken?(screen_name)
  @pfr_opportunity[screen_name] && @pfr_opportunity_taken[screen_name]
end