Class: AcpcPokerTypes::PokerAction
- Inherits:
-
Object
- Object
- 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
- #==(other_action) ⇒ Object
-
#has_modifier? ⇒ Boolean
true
if this action has a modifier,false
otherwise. -
#initialize(action, modifier: nil, cost: AcpcPokerTypes::ChipStack.new(0)) ⇒ PokerAction
constructor
A new instance of PokerAction.
-
#to_s(pot_gained_chips: true, player_sees_wager: pot_gained_chips) ⇒ String
(also: #to_acpc)
String representation of this action.
Constructor Details
#initialize(action, modifier: nil, cost: AcpcPokerTypes::ChipStack.new(0)) ⇒ PokerAction
Returns a new instance of PokerAction.
70 71 72 73 |
# File 'lib/acpc_poker_types/poker_action.rb', line 70 def initialize(action, modifier: nil, cost: AcpcPokerTypes::ChipStack.new(0)) validate_action!(action, modifier.strip) @cost = cost end |
Instance Attribute Details
#action ⇒ String (readonly) Also known as: to_acpc_character
Returns Action character.
60 61 62 |
# File 'lib/acpc_poker_types/poker_action.rb', line 60 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.
54 55 56 |
# File 'lib/acpc_poker_types/poker_action.rb', line 54 def cost @cost end |
#modifier ⇒ String (readonly)
Returns A modifier for the action (i.e. a bet or raise size).
57 58 59 |
# File 'lib/acpc_poker_types/poker_action.rb', line 57 def modifier @modifier end |
#pot_gained_chips ⇒ Boolean (readonly)
Returns Whether or not the pot has been added to this round before this action.
64 65 66 |
# File 'lib/acpc_poker_types/poker_action.rb', line 64 def pot_gained_chips @pot_gained_chips end |
Instance Method Details
#==(other_action) ⇒ Object
75 76 77 |
# File 'lib/acpc_poker_types/poker_action.rb', line 75 def ==(other_action) to_s == other_action.to_s end |
#has_modifier? ⇒ Boolean
Returns true
if this action has a modifier, false
otherwise.
98 99 100 |
# File 'lib/acpc_poker_types/poker_action.rb', line 98 def has_modifier? !@modifier.blank? end |
#to_s(pot_gained_chips: true, player_sees_wager: pot_gained_chips) ⇒ String Also known as: to_acpc
Returns String representation of this action.
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/acpc_poker_types/poker_action.rb', line 83 def to_s(pot_gained_chips: true, player_sees_wager: pot_gained_chips) 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 |