Module: Pc::Tournament
- Includes:
- Loop
- Defined in:
- lib/pc/tournament.rb
Instance Method Summary
collapse
Methods included from Loop
#exit, #goodbye, included, #run, #say
Instance Method Details
#loaded_games ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/pc/tournament.rb', line 15
def loaded_games
Dir[File.dirname(__FILE__) + '/games/*.rb'].each {|file| require file }
{exit: -> {goodbye}}.tap do |games|
ObjectSpace.each_object(Game) do |game|
unless game == Pc::Game
games[game.to_s] = ->{play game}
end
end
end
end
|
#play(game) ⇒ Object
27
28
29
30
|
# File 'lib/pc/tournament.rb', line 27
def play(game)
game.run @interface, @options
say %{Get ready for the next one}, next: ->{select_game}
end
|
#select_game ⇒ Object
11
12
13
|
# File 'lib/pc/tournament.rb', line 11
def select_game
ask %{Pick a game}, loaded_games
end
|
#welcome ⇒ Object
7
8
9
|
# File 'lib/pc/tournament.rb', line 7
def welcome
say %{Welcome}, next: ->{select_game}
end
|