class Mastermind::Console::View
Constants
- BLANK
- BL_CORNER
- BM_INTER
- BR_CORNER
- EXACT
- HORIZONTAL
- PARTIAL
- PIECE
- SIDE
- TL_CORNER
- TM_INTER
- TR_CORNER
Public Class Methods
attempt_line(turn, width: 4)
click to toggle source
# File lib/mastermind/console/view.rb, line 43 def self.attempt_line(turn, width: 4) "#{turn.number}:".ljust(4) + SIDE + guess_bar(turn.guess.sequence) + BLANK * (width - turn.guess.length) + SIDE + feedback_line(exact: turn.exact, partial: turn.partial, width: width) + SIDE end
bottom_border(width: 4)
click to toggle source
# File lib/mastermind/console/view.rb, line 39 def self.bottom_border(width: 4) " " + BL_CORNER + HORIZONTAL * width + BM_INTER + HORIZONTAL * width + BR_CORNER end
color_codes()
click to toggle source
# File lib/mastermind/console/view.rb, line 29 def self.color_codes Game::Piece::COLORS.map.with_index do |color, idx| "#{idx + 1}: #{piece_icon(color)}" end.join(" ") + " q: exit" end
feedback_line(exact: 0, partial: 0, width: 4)
click to toggle source
# File lib/mastermind/console/view.rb, line 49 def self.feedback_line(exact: 0, partial: 0, width: 4) EXACT * exact + PARTIAL * partial + BLANK * (width - exact - partial) end
grading_scheme()
click to toggle source
# File lib/mastermind/console/view.rb, line 25 def self.grading_scheme "#{EXACT}: Matched color and position #{PARTIAL}: Matched color" end
guess_bar(sequence)
click to toggle source
# File lib/mastermind/console/view.rb, line 57 def self.guess_bar(sequence) sequence.map { |piece| piece_icon(piece.color) }.join("") end
introduction()
click to toggle source
# File lib/mastermind/console/view.rb, line 19 def self.introduction "MASTERMIND\n" + "" + "\n" end
piece_icon(color)
click to toggle source
# File lib/mastermind/console/view.rb, line 53 def self.piece_icon(color) PIECE.colorize(color) end
top_border(width: 4)
click to toggle source
# File lib/mastermind/console/view.rb, line 35 def self.top_border(width: 4) " " + TL_CORNER + HORIZONTAL * width + TM_INTER + HORIZONTAL * width + TR_CORNER end