Class: Tundengine::Stages::Match
- Defined in:
- lib/tundengine/stages/match.rb
Constant Summary collapse
- SETTINGS_KEYS =
%i(max_points tute_value losing_position)
Instance Attribute Summary collapse
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
Attributes inherited from Base
#child_in_play, #children, #parent
Instance Method Summary collapse
-
#initialize(tournament, players, settings) ⇒ Match
constructor
A new instance of Match.
- #on_complete_child!(result) ⇒ Object
- #on_completed! ⇒ Object
- #summary ⇒ Object
Methods inherited from Base
#as_hash, #declare!, #fast_forward!, #lock!, #play!, #rewind!
Constructor Details
#initialize(tournament, players, settings) ⇒ Match
Returns a new instance of Match.
9 10 11 12 13 14 15 |
# File 'lib/tundengine/stages/match.rb', line 9 def initialize(tournament, players, settings) @players = players @settings = settings @trumps = Deck::SUITS.dup @result = @players.each_with_object({}) { |k, h| h[k] = 0 } super(tournament) end |
Instance Attribute Details
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
7 8 9 |
# File 'lib/tundengine/stages/match.rb', line 7 def settings @settings end |
Instance Method Details
#on_complete_child!(result) ⇒ Object
27 28 29 30 31 |
# File 'lib/tundengine/stages/match.rb', line 27 def on_complete_child!(result) update_result!(result) rotate_trumps_and_players! super() end |
#on_completed! ⇒ Object
33 34 35 |
# File 'lib/tundengine/stages/match.rb', line 33 def on_completed! tournament.on_complete_child!(@result) end |
#summary ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/tundengine/stages/match.rb', line 37 def summary { settings: settings.each_with_object({}) { |(k,v),h| h[k.to_s] = v.to_s }, players: @players.map(&:name), result: @result.each_with_object({}) { |(k,v),h| h[k.to_s] = v } } end |