Class: Mjai::TenhouArchive
- Includes:
- Util
- Defined in:
- lib/mjai/tenhou_archive.rb
Defined Under Namespace
Modules: Util Classes: TenhouFuro
Constant Summary
Constants included from Util
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#xml ⇒ Object
readonly
Returns the value of attribute xml.
Attributes inherited from Game
#all_pais, #bakaze, #current_action, #dora_markers, #honba, #last, #num_pipais, #oya, #players, #previous_action
Instance Method Summary collapse
-
#initialize(path) ⇒ TenhouArchive
constructor
A new instance of TenhouArchive.
- #play ⇒ Object
Methods included from Util
compose_pid, decompose_pid, #delete_tehai_by_pid, get_pai, #get_points_params, #on_tenhou_event, pid_to_pai, #verify_tenhou_tehais
Methods inherited from Archive
#actions, #each_action, #expect_response_from?, #inspect, load
Methods inherited from Game
#action_in_view, #can_kan?, #distance, #do_action, #doras, #dump_action, #first_turn?, #get_hora, #on_action, #on_responses, #ranked_players, #render_board, #update_state, #validate, #validate_fields_exist, #validate_response_content, #validate_response_type, #validate_responses
Constructor Details
#initialize(path) ⇒ TenhouArchive
Returns a new instance of TenhouArchive.
428 429 430 431 432 433 434 |
# File 'lib/mjai/tenhou_archive.rb', line 428 def initialize(path) super() @path = path Zlib::GzipReader.open(path) do |f| @xml = f.read().force_encoding("utf-8") end end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
436 437 438 |
# File 'lib/mjai/tenhou_archive.rb', line 436 def path @path end |
#xml ⇒ Object (readonly)
Returns the value of attribute xml.
437 438 439 |
# File 'lib/mjai/tenhou_archive.rb', line 437 def xml @xml end |
Instance Method Details
#play ⇒ Object
439 440 441 442 443 444 445 446 447 448 449 450 451 452 |
# File 'lib/mjai/tenhou_archive.rb', line 439 def play() @doc = Nokogiri.XML(@xml) elems = @doc.root.children elems.each_with_index() do |elem, j| begin if on_tenhou_event(elem, elems[j + 1]) == :broken break # Something is wrong. end rescue $stderr.puts("While interpreting element: %s" % elem) raise end end end |