-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathgame.rb
More file actions
37 lines (30 loc) · 682 Bytes
/
game.rb
File metadata and controls
37 lines (30 loc) · 682 Bytes
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
33
34
35
36
37
# frozen_string_literal: true
require './text_instructions'
require './text_content'
require './display'
# main class that starts the game
class Game
include TextInstructions
include TextContent
include Display
def play
puts instructions
game_mode = mode_selection
code_maker if game_mode == '1'
code_breaker if game_mode == '2'
end
def mode_selection
input = gets.chomp
return input if input.match(/^[1-2]$/)
puts warning_message('answer_error')
mode_selection
end
def code_maker
maker = ComputerSolver.new
maker.computer_start
end
def code_breaker
breaker = HumanSolver.new
breaker.player_turns
end
end