Class: Pokerstats::StreetStatistics

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(handstatistics) ⇒ StreetStatistics

Returns a new instance of StreetStatistics.



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

def initialize handstatistics
  super handstatistics
  @saw = {}
  @won = {}
end

Class Method Details

.report_specificationObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/pokerstats/plugins/street_statistics.rb', line 4

def self.report_specification
  [
    # [key,         sql_type,   function]
    [:saw_flop,     'boolean',  :saw_flop],
    [:saw_turn,     'boolean',  :saw_turn],
    [:saw_river,    'boolean',  :saw_river],
    [:saw_showdown, 'boolean',  :saw_showdown],
    [:won_preflop,  'boolean',  :won_preflop],
    [:won_flop,     'boolean',  :won_flop],
    [:won_turn,     'boolean',  :won_turn],
    [:won_river,    'boolean',  :won_river],
    [:won_showdown, 'boolean',  :won_showdown]
  ]
end

Instance Method Details

#apply_action(action, street) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/pokerstats/plugins/street_statistics.rb', line 72

def apply_action action, street
    # saw_* statistics for ftrs
    screen_name = action[:screen_name]
    if [:flop, :turn, :river, :showdown].include? street
        @saw[screen_name][street] = true
    end
    # won_* statistics for pftrs
    if [:preflop, :flop, :turn, :river, :showdown].include? street
        if action[:result] == :win
            @won[screen_name][street] = true
            if street == :showdown
                @won[screen_name][@hand_statistics.last_street] = true
            end
        elsif @won[screen_name][street].nil?
            @won[screen_name][street] = false
            if street == :showdown
                @won[screen_name][@hand_statistics.last_street] = false
            end
        end
    end
end

#register_player(screen_name, street, player) ⇒ Object



61
62
63
64
# File 'lib/pokerstats/plugins/street_statistics.rb', line 61

def register_player screen_name, street, player
    @saw[screen_name] = {}
    @won[screen_name] = {}
end

#saw_flop(player) ⇒ Object



25
26
27
# File 'lib/pokerstats/plugins/street_statistics.rb', line 25

def saw_flop player
    @saw[player] && @saw[player][:flop]
end

#saw_river(player) ⇒ Object



33
34
35
# File 'lib/pokerstats/plugins/street_statistics.rb', line 33

def saw_river player
    @saw[player] && @saw[player][:river]
end

#saw_showdown(player) ⇒ Object



37
38
39
# File 'lib/pokerstats/plugins/street_statistics.rb', line 37

def saw_showdown player
    @saw[player] && @saw[player][:showdown]
end

#saw_turn(player) ⇒ Object



29
30
31
# File 'lib/pokerstats/plugins/street_statistics.rb', line 29

def saw_turn player
    @saw[player] && @saw[player][:turn]
end

#street_transition(street) ⇒ Object



66
67
# File 'lib/pokerstats/plugins/street_statistics.rb', line 66

def street_transition street
end

#street_transition_for_player(street, player) ⇒ Object



69
70
# File 'lib/pokerstats/plugins/street_statistics.rb', line 69

def street_transition_for_player street, player
end

#won_flop(player) ⇒ Object



45
46
47
# File 'lib/pokerstats/plugins/street_statistics.rb', line 45

def won_flop player
    @won[player] && @won[player][:flop]
end

#won_preflop(player) ⇒ Object



41
42
43
# File 'lib/pokerstats/plugins/street_statistics.rb', line 41

def won_preflop player
    @won[player] && @won[player][:preflop]
end

#won_river(player) ⇒ Object



53
54
55
# File 'lib/pokerstats/plugins/street_statistics.rb', line 53

def won_river player
    @won[player] && @won[player][:river]
end

#won_showdown(player) ⇒ Object



57
58
59
# File 'lib/pokerstats/plugins/street_statistics.rb', line 57

def won_showdown player
    @won[player] && @won[player][:showdown]
end

#won_turn(player) ⇒ Object



49
50
51
# File 'lib/pokerstats/plugins/street_statistics.rb', line 49

def won_turn player
    @won[player] && @won[player][:turn]
end