Class: AcpcPokerTypes::AcpcDealerData::ActionMessages
- Inherits:
-
Object
- Object
- AcpcPokerTypes::AcpcDealerData::ActionMessages
- Defined in:
- lib/acpc_poker_types/acpc_dealer_data/action_messages.rb
Defined Under Namespace
Classes: FromMessage, ToMessage
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#final_score ⇒ Object
readonly
Returns the value of attribute final_score.
-
#match_def ⇒ Object
readonly
Returns the value of attribute match_def.
Class Method Summary collapse
- .parse_file(acpc_log_file_path, player_names, game_def_directory, num_hands = nil) ⇒ Object
- .parse_from_message(from_message) ⇒ Object
- .parse_score(score_string) ⇒ Object
- .parse_to_message(to_message) ⇒ Object
- .parse_to_or_from_message(message) ⇒ Object
Instance Method Summary collapse
-
#initialize(acpc_log_statements, player_names, game_def_directory, num_hands = nil) ⇒ ActionMessages
constructor
A new instance of ActionMessages.
Constructor Details
#initialize(acpc_log_statements, player_names, game_def_directory, num_hands = nil) ⇒ ActionMessages
Returns a new instance of ActionMessages.
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/acpc_poker_types/acpc_dealer_data/action_messages.rb', line 98 def initialize( acpc_log_statements, player_names, game_def_directory, num_hands=nil ) @final_score = nil @match_def = nil @data = acpc_log_statements.inject([]) do |accumulating_data, log_line| if @match_def.nil? @match_def = AcpcPokerTypes::AcpcDealerData::MatchDefinition.parse(log_line, player_names, game_def_directory) else = AcpcPokerTypes::AcpcDealerData::ActionMessages.(log_line) if if ( accumulating_data.empty? || accumulating_data.last.first[:state].hand_number != [:state].hand_number ) break accumulating_data if accumulating_data.length == num_hands accumulating_data << [] end accumulating_data.last << else @final_score = AcpcPokerTypes::AcpcDealerData::ActionMessages.parse_score(log_line) unless @final_score end end accumulating_data end end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
10 11 12 |
# File 'lib/acpc_poker_types/acpc_dealer_data/action_messages.rb', line 10 def data @data end |
#final_score ⇒ Object (readonly)
Returns the value of attribute final_score.
10 11 12 |
# File 'lib/acpc_poker_types/acpc_dealer_data/action_messages.rb', line 10 def final_score @final_score end |
#match_def ⇒ Object (readonly)
Returns the value of attribute match_def.
10 11 12 |
# File 'lib/acpc_poker_types/acpc_dealer_data/action_messages.rb', line 10 def match_def @match_def end |
Class Method Details
.parse_file(acpc_log_file_path, player_names, game_def_directory, num_hands = nil) ⇒ Object
85 86 87 88 89 90 91 92 93 94 |
# File 'lib/acpc_poker_types/acpc_dealer_data/action_messages.rb', line 85 def self.parse_file( acpc_log_file_path, player_names, game_def_directory, num_hands=nil ) AcpcPokerTypes::AcpcDealerData::LogFile.open(acpc_log_file_path, 'r') do |file| AcpcPokerTypes::AcpcDealerData::ActionMessages.parse file, player_names, game_def_directory, num_hands end end |
.parse_from_message(from_message) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/acpc_poker_types/acpc_dealer_data/action_messages.rb', line 45 def self.() if .strip.match( /^FROM\s*(\d+)\s*at\s*[\d\.]+\s*(#{AcpcPokerTypes::MatchState::LABEL}\S+):([#{AcpcPokerTypes::PokerAction::CONCATONATED_ACTIONS}]\s*\d*)$/ ) FromMessage.new( $1.to_i - 1, AcpcPokerTypes::MatchState.parse($2), AcpcPokerTypes::PokerAction.new($3) ) else nil end end |
.parse_score(score_string) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/acpc_poker_types/acpc_dealer_data/action_messages.rb', line 59 def self.parse_score(score_string) if score_string.strip.match( /^SCORE:([\d\-\.|]+):([\w|]+)$/ ) stack_changes = $1.split '|' players = $2.split '|' players.each_index.inject({}) do |player_results, j| player_results[players[j].to_sym] = stack_changes[j].to_r player_results end else nil end end |
.parse_to_message(to_message) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/acpc_poker_types/acpc_dealer_data/action_messages.rb', line 31 def self.() if .strip.match( /^TO\s*(\d+)\s*at\s*[\d\.]+\s+(\S+)$/ ) ToMessage.new( $1.to_i - 1, AcpcPokerTypes::MatchState.parse($2) ) else nil end end |
.parse_to_or_from_message(message) ⇒ Object
76 77 78 79 80 81 82 83 |
# File 'lib/acpc_poker_types/acpc_dealer_data/action_messages.rb', line 76 def self.() = AcpcPokerTypes::AcpcDealerData::ActionMessages.() if .nil? AcpcPokerTypes::AcpcDealerData::ActionMessages.() else end end |