Class: AcpcPokerTypes::DealerData::HandData

Inherits:
Object
  • Object
show all
Defined in:
lib/acpc_poker_types/dealer_data/hand_data.rb

Defined Under Namespace

Classes: Turn

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(match_def, action_data, result) ⇒ HandData

Returns a new instance of HandData.



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/acpc_poker_types/dealer_data/hand_data.rb', line 43

def initialize(match_def, action_data, result)
  @match_def = match_def

  set_chip_distribution! result

  set_data! action_data

  @turn_number = nil

  # Zero-indexed seat
  @seat = 0
end

Instance Attribute Details

#chip_distributionObject

Returns the value of attribute chip_distribution.



22
23
24
# File 'lib/acpc_poker_types/dealer_data/hand_data.rb', line 22

def chip_distribution
  @chip_distribution
end

#dataObject

Returns the value of attribute data.



22
23
24
# File 'lib/acpc_poker_types/dealer_data/hand_data.rb', line 22

def data
  @data
end

#match_defObject

Returns the value of attribute match_def.



22
23
24
# File 'lib/acpc_poker_types/dealer_data/hand_data.rb', line 22

def match_def
  @match_def
end

#seatObject

Returns the value of attribute seat.



22
23
24
# File 'lib/acpc_poker_types/dealer_data/hand_data.rb', line 22

def seat
  @seat
end

#turn_numberObject

Returns the value of attribute turn_number.



22
23
24
# File 'lib/acpc_poker_types/dealer_data/hand_data.rb', line 22

def turn_number
  @turn_number
end

Instance Method Details

#==(other) ⇒ Object



56
57
58
59
60
# File 'lib/acpc_poker_types/dealer_data/hand_data.rb', line 56

def ==(other)
  @match_def == other.match_def &&
  @chip_distribution == other.chip_distribution &&
  @data == other.data
end

#current_match_state(seat = @seat) ⇒ Object



86
87
88
89
90
91
92
# File 'lib/acpc_poker_types/dealer_data/hand_data.rb', line 86

def current_match_state(seat=@seat)
  if @turn_number
    @data[@turn_number].state_messages[seat]
  else
    nil
  end
end

#end_hand!Object



70
71
72
73
# File 'lib/acpc_poker_types/dealer_data/hand_data.rb', line 70

def end_hand!
  @turn_number = nil
  self
end

#final_turn?Boolean

Returns:

  • (Boolean)


119
120
121
122
123
124
125
# File 'lib/acpc_poker_types/dealer_data/hand_data.rb', line 119

def final_turn?
  if @turn_number
    @turn_number >= @data.length - 1
  else
    nil
  end
end

#for_every_turn!(seat = @seat) ⇒ Object



75
76
77
78
79
80
81
82
83
84
# File 'lib/acpc_poker_types/dealer_data/hand_data.rb', line 75

def for_every_turn!(seat=@seat)
  start_hand! seat

  while @turn_number.nil? || (@turn_number < @data.length - 1) do
    next_turn!
    yield @turn_number
  end

  end_hand!
end

#last_actionObject



111
112
113
114
115
116
117
# File 'lib/acpc_poker_types/dealer_data/hand_data.rb', line 111

def last_action
  if @turn_number && @turn_number != 0
    @data[@turn_number-1].action_message
  else
    nil
  end
end

#last_match_state(seat = @seat) ⇒ Object



103
104
105
106
107
108
109
# File 'lib/acpc_poker_types/dealer_data/hand_data.rb', line 103

def last_match_state(seat=@seat)
  if @turn_number && @turn_number != 0
    @data[@turn_number-1].state_messages[seat]
  else
    nil
  end
end

#next_actionActionMessage

Returns Next action in the hand to be taken in the current turn.

Returns:

  • (ActionMessage)

    Next action in the hand to be taken in the current turn.



95
96
97
98
99
100
101
# File 'lib/acpc_poker_types/dealer_data/hand_data.rb', line 95

def next_action
  if @turn_number
    @data[@turn_number].action_message
  else
    nil
  end
end

#next_turn!Object



66
67
68
# File 'lib/acpc_poker_types/dealer_data/hand_data.rb', line 66

def next_turn!
  init_or_increment_turn_num!
end

#start_hand!(seat = @seat) ⇒ Object



62
63
64
# File 'lib/acpc_poker_types/dealer_data/hand_data.rb', line 62

def start_hand!(seat=@seat)
  @seat = seat
end