-
Notifications
You must be signed in to change notification settings - Fork 0
/
games.rb
32 lines (27 loc) · 806 Bytes
/
games.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require "byebug"
require_relative './utils/options.rb'
require_relative './chess/chess.rb'
require_relative './minesweeper/minesweeper.rb'
require_relative './battleship/battleship.rb'
require_relative './towers-of-hanoi/towers_of_hanoi.rb'
require_relative './hangman/hangman.rb'
def get_game
game_name = Options.new([
["Chess"],
["Mine Sweeper"],
["Battleship"],
["Towers Of Hanoi"],
["Hangman"],
], "Select a game:").get_option
system("clear")
Object.const_get(game_name.gsub(" ", ""))::Game
end
def args(game)
game.options.zip(game.prompts).map { |options, prompt| Options.new(options, prompt).get_option }
end
if __FILE__ == $PROGRAM_NAME
game = get_game
args = args(game)
puts args
game.init_with_options(*args)
end