Method: Bcpm::Match.match_data
- Defined in:
- lib/bcpm/match.rb
.match_data(player1_name, player2_name, silence_b, map_name, run_live, bc_options = {}) ⇒ Object
Runs a match between two players and returns the log data.
Args:
player1_name:: name of locally installed player (A)
player2_name:: name of locally installed player (B)
silence_b:: if true, B is silenced; otherwise, A is silenced
map_name:: name of map .xml file (or full path for custom map)
run_live:: if true, tries to run the match using the live UI
bc_options:: hash of simulator settings to be added to bc.conf
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/bcpm/match.rb', line 48 def self.match_data(player1_name, player2_name, silence_b, map_name, run_live, = {}) uid = tempfile tempdir = File. File.join(Dir.tmpdir, 'bcpm', 'match_' + uid) FileUtils.mkdir_p tempdir binfile = File.join tempdir, 'match.rms' txtfile = File.join tempdir, 'match.txt' build_log = File.join tempdir, 'build.log' match_log = File.join tempdir, 'match.log' scribe_log = File.join tempdir, 'scribe.log' bc_config = simulator_config player1_name, player2_name, silence_b, map_name, binfile, txtfile bc_config.merge! conf_file = File.join tempdir, 'bc.conf' write_config conf_file, bc_config write_ui_config conf_file, true, bc_config if run_live build_file = File.join tempdir, 'build.xml' write_build build_file, conf_file if run_live run_build_script tempdir, build_file, match_log, 'run', 'Stop buffering match' else run_build_script tempdir, build_file, match_log, 'file' end run_build_script tempdir, build_file, scribe_log, 'transcribe' textlog = File.exist?(txtfile) ? File.open(txtfile, 'rb') { |f| f.read } : '' binlog = File.exist?(binfile) ? File.open(binfile, 'rb') { |f| f.read } : '' antlog = File.exist?(match_log) ? File.open(match_log, 'rb') { |f| f.read } : '' FileUtils.rm_rf tempdir { :ant => extract_ant_log(antlog), :rms => binlog, :script => textlog, :uid => uid } end |