Module: AcpcPokerTypes
- Defined in:
- lib/acpc_poker_types/board_cards.rb,
lib/acpc_poker_types.rb,
lib/acpc_poker_types/card.rb,
lib/acpc_poker_types/hand.rb,
lib/acpc_poker_types/rank.rb,
lib/acpc_poker_types/seat.rb,
lib/acpc_poker_types/suit.rb,
lib/acpc_poker_types/player.rb,
lib/acpc_poker_types/version.rb,
lib/acpc_poker_types/chip_stack.rb,
lib/acpc_poker_types/hand_player.rb,
lib/acpc_poker_types/match_state.rb,
lib/acpc_poker_types/match_state.rb,
lib/acpc_poker_types/poker_action.rb,
lib/acpc_poker_types/pile_of_cards.rb,
lib/acpc_poker_types/game_definition.rb,
lib/acpc_poker_types/hand_player_group.rb,
lib/acpc_poker_types/players_at_the_table.rb,
lib/acpc_poker_types/players_at_the_table.rb,
lib/acpc_poker_types/dealer_data/poker_match_data.rb
Overview
Model to parse and manage information from a given match state string.
Defined Under Namespace
Modules: DealerData, Indices, MapWithIndex
Classes: BoardCards, Card, ChipStack, GameDefinition, Hand, HandPlayer, HandPlayerGroup, MatchState, NilHandPlayer, PileOfCards, Player, PlayersAtTheTable, PokerAction, Rank, Seat, Suit
Constant Summary
collapse
- VERSION =
'7.8.3'
Instance Method Summary
collapse
-
#bet_description(player, poker_action) ⇒ Object
-
#big_blind_payer_index(hand_number, game_def) ⇒ Object
-
#call_description(player, poker_action) ⇒ Object
-
#check_description(player) ⇒ Object
-
#dealer_index(hand_number, game_def) ⇒ Object
from AcpcPokerTypes::PlayersAtTheTable.
-
#fold_description(player) ⇒ Object
-
#hand_dealt_description(players, hand_number, game_def, number_of_hands) ⇒ Object
-
#hand_win_description(player, amount_won, current_balance) ⇒ Object
-
#limit_raise_description(player, poker_action, num_wagers_so_far, max_num_wagers) ⇒ Object
-
#no_limit_raise_description(player, poker_action, amount_to_call) ⇒ Object
-
#small_blind_payer_index(hand_number, game_def) ⇒ Object
-
#split_pot_description(players, amount) ⇒ Object
Instance Method Details
#bet_description(player, poker_action) ⇒ Object
35
36
37
38
39
40
41
42
|
# File 'lib/acpc_poker_types.rb', line 35
def bet_description(player, poker_action)
d = "#{player} bets"
if poker_action.modifier
d + " by #{poker_action.cost.to_i} to #{poker_action.modifier}"
else
d
end
end
|
#big_blind_payer_index(hand_number, game_def) ⇒ Object
22
23
24
|
# File 'lib/acpc_poker_types.rb', line 22
def big_blind_payer_index(hand_number, game_def)
(hand_number + game_def.blinds.index(game_def.blinds.max) - 1) % game_def.number_of_players
end
|
#call_description(player, poker_action) ⇒ Object
32
33
34
|
# File 'lib/acpc_poker_types.rb', line 32
def call_description(player, poker_action)
"#{player} calls (#{poker_action.cost.to_i})"
end
|
#check_description(player) ⇒ Object
29
30
31
|
# File 'lib/acpc_poker_types.rb', line 29
def check_description(player)
"#{player} checks"
end
|
#dealer_index(hand_number, game_def) ⇒ Object
TODO:
Functionality (but not implementation) duplicated
from AcpcPokerTypes::PlayersAtTheTable
19
20
21
|
# File 'lib/acpc_poker_types.rb', line 19
def dealer_index(hand_number, game_def)
hand_number % game_def.number_of_players
end
|
#fold_description(player) ⇒ Object
54
55
56
|
# File 'lib/acpc_poker_types.rb', line 54
def fold_description(player)
"#{player} folds"
end
|
#hand_dealt_description(players, hand_number, game_def, number_of_hands) ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/acpc_poker_types.rb', line 57
def hand_dealt_description(players, hand_number, game_def, number_of_hands)
raise unless players.length == game_def.number_of_players
big_blind_payer = players[big_blind_payer_index(
hand_number,
game_def
)]
small_blind_payer = players[small_blind_payer_index(
hand_number,
game_def
)]
dealer_player = players[dealer_index(
hand_number,
game_def
)]
"hand ##{hand_number} of #{number_of_hands} dealt by #{dealer_player}, #{small_blind_payer} pays SB (#{game_def.blinds.min}), #{big_blind_payer} pays BB (#{game_def.blinds.max})"
end
|
#hand_win_description(player, amount_won, current_balance) ⇒ Object
73
74
75
|
# File 'lib/acpc_poker_types.rb', line 73
def hand_win_description(player, amount_won, current_balance)
"#{player} wins #{amount_won}, bringing their balance to #{current_balance + amount_won}"
end
|
#limit_raise_description(player, poker_action, num_wagers_so_far, max_num_wagers) ⇒ Object
43
44
45
46
47
48
49
50
|
# File 'lib/acpc_poker_types.rb', line 43
def limit_raise_description(
player,
poker_action,
num_wagers_so_far,
max_num_wagers
)
"#{player} calls and raises (##{num_wagers_so_far+1} of #{max_num_wagers})"
end
|
#no_limit_raise_description(player, poker_action, amount_to_call) ⇒ Object
51
52
53
|
# File 'lib/acpc_poker_types.rb', line 51
def no_limit_raise_description(player, poker_action, amount_to_call)
"#{player} calls (#{amount_to_call}) and raises by #{poker_action.cost.to_i} to #{poker_action.modifier}"
end
|
#small_blind_payer_index(hand_number, game_def) ⇒ Object
25
26
27
|
# File 'lib/acpc_poker_types.rb', line 25
def small_blind_payer_index(hand_number, game_def)
(hand_number + game_def.blinds.index(game_def.blinds.min) - 1) % game_def.number_of_players
end
|
#split_pot_description(players, amount) ⇒ Object
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/acpc_poker_types.rb', line 76
def split_pot_description(players, amount)
a = if players.length > 2
players[0..-2].join(', ') + ", and #{players.last}"
else
"#{players[0]} and #{players[1]}"
end
split_amount = (amount / players.length.to_r).round(2)
"#{a} split the pot, each winning " + if split_amount == split_amount.to_i
split_amount.to_i.to_s
else
sprintf("%0.2f", split_amount.to_f)
end
end
|