Class: PokerAction
- Inherits:
-
Object
- Object
- PokerAction
- Defined in:
- lib/acpc_poker_types/poker_action.rb
Constant Summary collapse
- LEGAL_ACTIONS =
Returns Representations of legal actions.
{bet: 'b', call: 'c', check: 'k', fold: 'f', raise: 'r'}
- LEGAL_SYMBOLS =
Returns The set of legal action symbols.
Set.new LEGAL_ACTIONS.keys
- LEGAL_STRINGS =
Returns The set of legal action strings.
Set.new LEGAL_ACTIONS.keys.map { |action| action.to_s }
- LEGAL_ACPC_CHARACTERS =
Returns The set of legal ACPC action characters.
Set.new LEGAL_ACTIONS.values
- MODIFIABLE_ACTIONS =
Returns Representations of the legal ACPC action characters that may be accompanied by a modifier.
LEGAL_ACTIONS.select { |sym, char| 'r' == char || 'b' == char }
- HIGH_RESOLUTION_ACTION_CONVERSION =
Returns Map of general actions to more specific actions (e.g. call to check and raise to bet).
{call: :check, raise: :bet, fold: :fold, check: :check, bet: :bet}
Instance Attribute Summary collapse
-
#amount_to_put_in_pot ⇒ Object
readonly
The amount that the player taking this action needs to put in the pot.
-
#modifier ⇒ Object
readonly
A modifier for the action (i.e. a bet or raise size).
Instance Method Summary collapse
- #==(other_action) ⇒ Object
-
#has_modifier? ⇒ Boolean
true
if this action has a modifier,false
otherwise. -
#initialize(action, context = {}) ⇒ PokerAction
constructor
A new instance of PokerAction.
-
#to_acpc ⇒ String
Full ACPC representation of this action.
-
#to_acpc_character ⇒ String
ACPC character representation of this action.
-
#to_s ⇒ String
String representation of this action.
- #to_sym ⇒ Symbol
Constructor Details
#initialize(action, context = {}) ⇒ PokerAction
Returns a new instance of PokerAction.
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/acpc_poker_types/poker_action.rb', line 40 def initialize(action, context={}) (@symbol, @modifier) = validate_action( action, context[:modifier], if context[:acting_player_sees_wager].nil? true else context[:acting_player_sees_wager] end ) @amount_to_put_in_pot = context[:amount_to_put_in_pot].to_i end |
Instance Attribute Details
#amount_to_put_in_pot ⇒ Object (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.
13 14 15 |
# File 'lib/acpc_poker_types/poker_action.rb', line 13 def amount_to_put_in_pot @amount_to_put_in_pot end |
#modifier ⇒ Object (readonly)
Returns A modifier for the action (i.e. a bet or raise size).
16 17 18 |
# File 'lib/acpc_poker_types/poker_action.rb', line 16 def modifier @modifier end |
Instance Method Details
#==(other_action) ⇒ Object
53 54 55 |
# File 'lib/acpc_poker_types/poker_action.rb', line 53 def ==(other_action) to_sym == other_action.to_sym && to_s == other_action.to_s && to_acpc == other_action.to_acpc && @modifier == other_action.modifier end |
#has_modifier? ⇒ Boolean
Returns true
if this action has a modifier, false
otherwise.
58 59 60 |
# File 'lib/acpc_poker_types/poker_action.rb', line 58 def has_modifier? !@modifier.nil? end |
#to_acpc ⇒ String
Returns Full ACPC representation of this action.
73 74 75 |
# File 'lib/acpc_poker_types/poker_action.rb', line 73 def to_acpc LEGAL_ACTIONS[@symbol] + @modifier.to_s end |
#to_acpc_character ⇒ String
Returns ACPC character representation of this action.
78 79 80 |
# File 'lib/acpc_poker_types/poker_action.rb', line 78 def to_acpc_character LEGAL_ACTIONS[@symbol] end |
#to_s ⇒ String
Returns String representation of this action.
68 69 70 |
# File 'lib/acpc_poker_types/poker_action.rb', line 68 def to_s @symbol.to_s + @modifier.to_s end |
#to_sym ⇒ Symbol
63 64 65 |
# File 'lib/acpc_poker_types/poker_action.rb', line 63 def to_sym @symbol end |