Class: Display

Inherits:
Object
  • Object
show all
Defined in:
lib/ttt_malisa/display.rb

Instance Method Summary collapse

Constructor Details

#initialize(console, board) ⇒ Display

Returns a new instance of Display.



2
3
4
5
# File 'lib/ttt_malisa/display.rb', line 2

def initialize(console, board)
  @console = console
  @board = board
end

Instance Method Details

#alert_current_player(current_player) ⇒ Object



19
20
21
# File 'lib/ttt_malisa/display.rb', line 19

def alert_current_player(current_player)
  @console.print_message("It is #{current_player.mark}\'s turn")
end

#boardObject



35
36
37
# File 'lib/ttt_malisa/display.rb', line 35

def board
  @console.print_message(@board.display)
end

#computer_move(move) ⇒ Object



53
54
55
# File 'lib/ttt_malisa/display.rb', line 53

def computer_move(move)
  @console.print_message(move)
end

#computer_thinkingObject



57
58
59
# File 'lib/ttt_malisa/display.rb', line 57

def computer_thinking
  @console.print_message('.....thinking 🤔')
end

#draw_messageObject



31
32
33
# File 'lib/ttt_malisa/display.rb', line 31

def draw_message
  @console.print_message('Draw!')
end

#invalid_mark_messageObject



39
40
41
# File 'lib/ttt_malisa/display.rb', line 39

def invalid_mark_message
  @console.print_message('Please enter a single character that is unique')
end

#invalid_player_choiceObject



43
44
45
# File 'lib/ttt_malisa/display.rb', line 43

def invalid_player_choice
  @console.print_message('That is not a valid choice. Please try again')
end

#make_move_message(mark) ⇒ Object



11
12
13
# File 'lib/ttt_malisa/display.rb', line 11

def make_move_message(mark)
  @console.print_message("Player #{mark}, please enter a position 1-9 that is not already marked")
end

#player_choiceObject



47
48
49
50
51
# File 'lib/ttt_malisa/display.rb', line 47

def player_choice
  @console.print_message('Please choose a player type')
  @console.print_message('1: Human Player')
  @console.print_message('2: Computer Player')
end

#retrieve_user_inputObject



15
16
17
# File 'lib/ttt_malisa/display.rb', line 15

def retrieve_user_input
  @console.retrieve_user_input
end

#setup_mark_messageObject



23
24
25
# File 'lib/ttt_malisa/display.rb', line 23

def setup_mark_message
  @console.print_message('Please enter a single character to use as your game piece')
end

#welcomeObject



7
8
9
# File 'lib/ttt_malisa/display.rb', line 7

def welcome
  @console.print_message('Welcome to Tic Tac Toe')
end

#winner_message(mark) ⇒ Object



27
28
29
# File 'lib/ttt_malisa/display.rb', line 27

def winner_message(mark)
  @console.print_message("Congratulations #{mark}!")
end