Class: Pokerstats::PlayerStatistics

Inherits:
Object
  • Object
show all
Defined in:
lib/pokerstats/player_statistics.rb

Instance Method Summary collapse

Constructor Details

#initializePlayerStatistics

Returns a new instance of PlayerStatistics.



4
5
6
# File 'lib/pokerstats/player_statistics.rb', line 4

def initialize
  @aggregate_statistics = {}
end

Instance Method Details

#aggregate_boolean_statistic(each_player, reports, aggregate_stat, hand_stat) ⇒ Object



17
18
19
20
# File 'lib/pokerstats/player_statistics.rb', line 17

def aggregate_boolean_statistic each_player, reports, aggregate_stat, hand_stat
  @aggregate_statistics[each_player][aggregate_stat] ||= 0
  @aggregate_statistics[each_player][aggregate_stat] += 1 if reports[each_player][hand_stat]
end

#aggregate_numeric_statistic(each_player, reports, aggregate_stat, hand_stat) ⇒ Object



12
13
14
15
# File 'lib/pokerstats/player_statistics.rb', line 12

def aggregate_numeric_statistic each_player, reports, aggregate_stat, hand_stat
  @aggregate_statistics[each_player][aggregate_stat] ||= 0
  @aggregate_statistics[each_player][aggregate_stat] += reports[each_player][hand_stat]
end

#aggregate_statistic(each_player, reports, aggregate_stat, hand_stat) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/pokerstats/player_statistics.rb', line 22

def aggregate_statistic each_player, reports, aggregate_stat, hand_stat
  @aggregate_statistics[each_player][aggregate_stat] ||= 0
  if /^is_/ =~ hand_stat.to_s
    @aggregate_statistics[each_player][aggregate_stat] += 1 if reports[each_player][hand_stat]
  else
    @aggregate_statistics[each_player][aggregate_stat] += reports[each_player][hand_stat]
  end
end

#record(hand_statistics) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/pokerstats/player_statistics.rb', line 31

def record hand_statistics
  reports = hand_statistics.reports
  reports.keys.each do |each_player|
    @aggregate_statistics[each_player] ||= {}
  
    @aggregate_statistics[each_player][:t_hands] ||= 0
     @aggregate_statistics[each_player][:t_hands] += 1
     @aggregate_statistics[each_player][:t_vpip] ||= 0
     @aggregate_statistics[each_player][:t_vpip] += 1 unless reports[each_player][:paid].zero?
     aggregate_numeric_statistic each_player, reports, :t_posted, :posted
    aggregate_numeric_statistic each_player, reports, :t_paid, :paid
    aggregate_numeric_statistic each_player, reports, :t_won, :won
    aggregate_numeric_statistic each_player, reports, :t_preflop_passive, :preflop_passive
    aggregate_numeric_statistic each_player, reports, :t_preflop_aggressive, :preflop_aggressive
    aggregate_numeric_statistic each_player, reports, :t_postflop_passive, :postflop_passive
    aggregate_numeric_statistic each_player, reports, :t_postflop_aggressive, :postflop_aggressive
    aggregate_boolean_statistic each_player, reports, :t_blind_attack_opportunity, :is_blind_attack_opportunity
    aggregate_boolean_statistic each_player, reports, :t_blind_attack_opportunity_taken, :is_blind_attack_opportunity_taken
    aggregate_boolean_statistic each_player, reports, :t_blind_defense_opportunity, :is_blind_defense_opportunity
    aggregate_boolean_statistic each_player, reports, :t_blind_defense_opportunity_taken, :is_blind_defense_opportunity_taken
    aggregate_boolean_statistic each_player, reports, :t_pfr_opportunity, :is_pfr_opportunity
    aggregate_boolean_statistic each_player, reports, :t_pfr_opportunity_taken, :is_pfr_opportunity_taken
    aggregate_boolean_statistic each_player, reports, :t_cbet_opportunity, :is_cbet_opportunity
    aggregate_boolean_statistic each_player, reports, :t_cbet_opportunity_taken, :is_cbet_opportunity_taken
  end
end

#reportsObject



8
9
10
# File 'lib/pokerstats/player_statistics.rb', line 8

def reports
  @aggregate_statistics
end