Class: Tundengine::Stages::Tournament

Inherits:
Base
  • Object
show all
Defined in:
lib/tundengine/stages/tournament.rb

Constant Summary collapse

SETTINGS_KEYS =
%i(max_matches match_settings)

Instance Attribute Summary collapse

Attributes inherited from Base

#child_in_play, #children, #parent

Instance Method Summary collapse

Methods inherited from Base

#as_hash, #declare!, #fast_forward!, #lock!, #play!, #rewind!

Constructor Details

#initialize(players, settings) ⇒ Tournament

Returns a new instance of Tournament.



10
11
12
13
14
15
# File 'lib/tundengine/stages/tournament.rb', line 10

def initialize(players, settings)
  @players  = players
  @settings = settings
  @result   = initial_result
  super()
end

Instance Attribute Details

#playersObject (readonly)

TODO: Add a setting to run matches on multiple threads.



8
9
10
# File 'lib/tundengine/stages/tournament.rb', line 8

def players
  @players
end

#settingsObject (readonly)

TODO: Add a setting to run matches on multiple threads.



8
9
10
# File 'lib/tundengine/stages/tournament.rb', line 8

def settings
  @settings
end

Instance Method Details

#on_complete_child!(result) ⇒ Object



26
27
28
29
# File 'lib/tundengine/stages/tournament.rb', line 26

def on_complete_child!(result)
  update_result!(result)
  super()
end

#summaryObject



31
32
33
34
35
36
# File 'lib/tundengine/stages/tournament.rb', line 31

def summary
  {
    players: players.map(&:name),
    result: @result.each_with_object({}) { |(k,v),h| h[k.to_s] = v }
  }
end