-
Notifications
You must be signed in to change notification settings - Fork 0
/
game_interface.rb
33 lines (28 loc) · 1.06 KB
/
game_interface.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
33
# frozen_string_literal: true
# GameInterface contains the methods that generate
# what will be displayed in the terminal
#
# It does not actually output it to the terminal,
# instead these methods are used to add onto the DecodingBoard's
# rounds array, the class which outputs all rounds to the terminal
module GameInterface
private
def display_round_header(current_round)
<<-HEREDOC
--------------------------------------------------------------
ROUND #{current_round}
HEREDOC
end
def display_round(feedback, guess, current_round)
colors = pattern_to_colors(guess)
<<-HEREDOC
--------------------------------------------------------------
Key Pegs Guess ##{current_round}
Black: #{feedback[:black]} White: #{feedback[:white]} #{colors[0]} #{colors[1]} #{colors[2]} #{colors[3]}
--------------------------------------------------------------
HEREDOC
end
def pattern_to_colors(pattern)
pattern.map { |num| code_peg_colors[num - 1] }
end
end