Class: AcpcPokerTypes::PokerAction
- Inherits:
-
String
- Object
- String
- AcpcPokerTypes::PokerAction
- Defined in:
- lib/acpc_poker_types/poker_action.rb
Constant Summary collapse
- BET =
'b'
- CALL =
'c'
- CHECK =
'k'
- FOLD =
'f'
- RAISE =
'r'
- ACTIONS =
Set.new [BET, CALL, CHECK, FOLD, RAISE]
- CANONICAL_ACTIONS =
Returns The set of legal ACPC action characters.
Set.new [CALL, FOLD, RAISE]
- MODIFIABLE_ACTIONS =
Set.new [BET, RAISE]
- CONCATONATED_ACTIONS =
ACTIONS.to_a.join
Instance Attribute Summary collapse
-
#action ⇒ String
(also: #to_acpc_character)
readonly
Action character.
-
#cost ⇒ Rational
readonly
The amount that the player taking this action needs to put in the pot.
-
#modifier ⇒ String
readonly
A modifier for the action (i.e. a bet or raise size).
-
#pot_gained_chips ⇒ Boolean
readonly
Whether or not the pot has been added to this round before this action.
Instance Method Summary collapse
-
#has_modifier? ⇒ Boolean
true
if this action has a modifier,false
otherwise. -
#initialize(action, modifier: nil, cost: 0) ⇒ PokerAction
constructor
A new instance of PokerAction.
-
#to_s(pot_gained_chips: pot_gained_chips?, , player_sees_wager: player_sees_wager?) ) ⇒ String
(also: #to_acpc)
Defaults to
pot_gained_chips?
.
Constructor Details
#initialize(action, modifier: nil, cost: 0) ⇒ PokerAction
Returns a new instance of PokerAction.
73 74 75 76 77 78 79 |
# File 'lib/acpc_poker_types/poker_action.rb', line 73 def initialize(action, modifier: nil, cost: 0) @modifier = nil validate_action!(action, modifier.strip) @cost = cost.to_f super to_s end |
Instance Attribute Details
#action ⇒ String (readonly) Also known as: to_acpc_character
Returns Action character.
63 64 65 |
# File 'lib/acpc_poker_types/poker_action.rb', line 63 def action @action end |
#cost ⇒ Rational (readonly)
Returns The amount that the player taking this action needs to put in the pot. Could be negative to imply the acting player takes chips from the pot.
57 58 59 |
# File 'lib/acpc_poker_types/poker_action.rb', line 57 def cost @cost end |
#modifier ⇒ String (readonly)
Returns A modifier for the action (i.e. a bet or raise size).
60 61 62 |
# File 'lib/acpc_poker_types/poker_action.rb', line 60 def modifier @modifier end |
#pot_gained_chips ⇒ Boolean (readonly)
Returns Whether or not the pot has been added to this round before this action.
67 68 69 |
# File 'lib/acpc_poker_types/poker_action.rb', line 67 def pot_gained_chips @pot_gained_chips end |
Instance Method Details
#has_modifier? ⇒ Boolean
Returns true
if this action has a modifier, false
otherwise.
101 102 103 |
# File 'lib/acpc_poker_types/poker_action.rb', line 101 def has_modifier? @modifier && !@modifier.blank? end |
#to_s(pot_gained_chips: pot_gained_chips?, , player_sees_wager: player_sees_wager?) ) ⇒ String Also known as: to_acpc
Defaults to pot_gained_chips?
. Defaults to the value of player_sees_wager?
.
86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/acpc_poker_types/poker_action.rb', line 86 def to_s(pot_gained_chips: pot_gained_chips?, player_sees_wager: player_sees_wager?) combine_action_and_modifier( if @action == FOLD @action elsif @action == BET || @action == RAISE if pot_gained_chips then RAISE else BET end elsif @action == CALL || @action == CHECK if player_sees_wager then CALL else CHECK end end ) end |