Class: Mjai::Archive

Inherits:
Game
  • Object
show all
Defined in:
lib/mjai/archive.rb

Direct Known Subclasses

MjsonArchive, TenhouArchive

Instance Attribute Summary

Attributes inherited from Game

#all_pais, #bakaze, #current_action, #dora_markers, #honba, #last, #num_pipais, #oya, #players, #previous_action

Class Method Summary collapse

Instance Method Summary collapse

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

#initializeArchive

Returns a new instance of Archive.



22
23
24
25
# File 'lib/mjai/archive.rb', line 22

def initialize()
  super((0...4).map(){ PuppetPlayer.new() })
  @actions = nil
end

Class Method Details

.load(path) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/mjai/archive.rb', line 11

def self.load(path)
  case File.extname(path)
    when ".mjlog"
      return TenhouArchive.new(path)
    when ".mjson"
      return MjsonArchive.new(path)
    else
      raise("unknown format")
  end
end

Instance Method Details

#actionsObject



36
37
38
# File 'lib/mjai/archive.rb', line 36

def actions
  return @actions ||= self.each_action.to_a()
end

#each_action(&block) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/mjai/archive.rb', line 27

def each_action(&block)
  if block
    on_action(&block)
    play()
  else
    return enum_for(:each_action)
  end
end

#expect_response_from?(player) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/mjai/archive.rb', line 40

def expect_response_from?(player)
  return false
end

#inspectObject



44
45
46
# File 'lib/mjai/archive.rb', line 44

def inspect
  return '#<%p:path=%p>' % [self.class, self.path]
end