Class: AcpcDealerData::MatchDefinition
- Inherits:
-
Object
- Object
- AcpcDealerData::MatchDefinition
- Defined in:
- lib/acpc_dealer_data/match_definition.rb
Instance Attribute Summary collapse
-
#game_def ⇒ Object
readonly
Returns the value of attribute game_def.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#number_of_hands ⇒ Object
readonly
Returns the value of attribute number_of_hands.
-
#player_names ⇒ Object
readonly
Returns the value of attribute player_names.
-
#random_seed ⇒ Object
readonly
Returns the value of attribute random_seed.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(name, game_def, number_of_hands, random_seed, player_names) ⇒ MatchDefinition
constructor
A new instance of MatchDefinition.
Constructor Details
#initialize(name, game_def, number_of_hands, random_seed, player_names) ⇒ MatchDefinition
Returns a new instance of MatchDefinition.
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/acpc_dealer_data/match_definition.rb', line 31 def initialize(name, game_def, number_of_hands, random_seed, player_names) if game_def.number_of_players != player_names.length raise IncorrectNumberOfPlayerNames, "number of players: #{game_def.number_of_players}, number of names: #{player_names.length}" end @name = name.to_s @game_def = game_def @number_of_hands = number_of_hands.to_i @random_seed = random_seed.to_i @player_names = player_names end |
Instance Attribute Details
#game_def ⇒ Object (readonly)
Returns the value of attribute game_def.
12 13 14 |
# File 'lib/acpc_dealer_data/match_definition.rb', line 12 def game_def @game_def end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/acpc_dealer_data/match_definition.rb', line 12 def name @name end |
#number_of_hands ⇒ Object (readonly)
Returns the value of attribute number_of_hands.
12 13 14 |
# File 'lib/acpc_dealer_data/match_definition.rb', line 12 def number_of_hands @number_of_hands end |
#player_names ⇒ Object (readonly)
Returns the value of attribute player_names.
12 13 14 |
# File 'lib/acpc_dealer_data/match_definition.rb', line 12 def player_names @player_names end |
#random_seed ⇒ Object (readonly)
Returns the value of attribute random_seed.
12 13 14 |
# File 'lib/acpc_dealer_data/match_definition.rb', line 12 def random_seed @random_seed end |
Class Method Details
.parse(acpc_log_string, player_names, game_def_directory) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/acpc_dealer_data/match_definition.rb', line 14 def self.parse(acpc_log_string, player_names, game_def_directory) if acpc_log_string.strip.match( '^\s*#\s*name/game/hands/seed\s+(\S+)\s+(\S+)\s+(\d+)\s+(\d+)\s*$' ) name = $1 game_def = GameDefinition.parse_file( File.join(game_def_directory, File.basename($2)) ) number_of_hands = $3 random_seed = $4 new(name, game_def, number_of_hands, random_seed, player_names) else nil end end |
Instance Method Details
#==(other) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/acpc_dealer_data/match_definition.rb', line 43 def ==(other) ( @name == other.name && Set.new(@game_def.to_a) == Set.new(other.game_def.to_a) && @number_of_hands == other.number_of_hands && @random_seed == other.random_seed && @player_names == other.player_names ) end |