class AcpcTableManager::ExhibitionConfig
Attributes
file[R]
Public Class Methods
new( file_path, interpolation_hash, logger = Logger.new(STDOUT) )
click to toggle source
# File lib/acpc_table_manager/config.rb, line 60 def initialize( file_path, interpolation_hash, logger = Logger.new(STDOUT) ) @logger = logger @file = file_path JSON.parse(File.read(file_path)).each do |constant, val| interpolated_val = ::AcpcTableManager.interpolate_all_strings(val, interpolation_hash) log(__method__, {adding: {method: constant, value: interpolated_val}}) instance_variable_set("@#{constant}".to_sym, interpolated_val) define_singleton_method(constant.to_sym) do instance_variable_get("@#{constant}".to_sym) end end unless special_ports_to_dealer @special_ports_to_dealer = [] log(__method__, {adding: {method: 'special_ports_to_dealer', value: @special_ports_to_dealer}}) define_singleton_method(:special_ports_to_dealer) do instance_variable_get(:@special_ports_to_dealer) end end end
Public Instance Methods
bots(game_def_key, *player_names)
click to toggle source
@return [Array<Class>] Returns only the names that correspond to bot runner
classes as those classes.
# File lib/acpc_table_manager/config.rb, line 87 def bots(game_def_key, *player_names) game_def_key = game_def_key.to_s if @games[game_def_key] if @games[game_def_key]['opponents'] player_names.reduce({}) do |bot_map, name| bot_map[name] = @games[game_def_key]['opponents'][name] if @games[game_def_key]['opponents'][name] bot_map end else log( __method__, {warning: "Game '#{game_def_key}' has no opponents."}, Logger::Severity::WARN ) {} end else log( __method__, {warning: "Unrecognized game, '#{game_def_key}'."}, Logger::Severity::WARN ) {} end end