Class: Display
- Inherits:
-
Object
- Object
- Display
- Defined in:
- lib/ttt_malisa/display.rb
Instance Method Summary collapse
- #alert_current_player(current_player) ⇒ Object
- #board ⇒ Object
- #computer_move(move) ⇒ Object
- #computer_thinking ⇒ Object
- #draw_message ⇒ Object
-
#initialize(console, board) ⇒ Display
constructor
A new instance of Display.
- #invalid_mark_message ⇒ Object
- #invalid_player_choice ⇒ Object
- #make_move_message(mark) ⇒ Object
- #player_choice ⇒ Object
- #retrieve_user_input ⇒ Object
- #setup_mark_message ⇒ Object
- #welcome ⇒ Object
- #winner_message(mark) ⇒ Object
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.("It is #{current_player.mark}\'s turn") end |
#board ⇒ Object
35 36 37 |
# File 'lib/ttt_malisa/display.rb', line 35 def board @console.(@board.display) end |
#computer_move(move) ⇒ Object
53 54 55 |
# File 'lib/ttt_malisa/display.rb', line 53 def computer_move(move) @console.(move) end |
#computer_thinking ⇒ Object
57 58 59 |
# File 'lib/ttt_malisa/display.rb', line 57 def computer_thinking @console.('.....thinking 🤔') end |
#draw_message ⇒ Object
31 32 33 |
# File 'lib/ttt_malisa/display.rb', line 31 def @console.('Draw!') end |
#invalid_mark_message ⇒ Object
39 40 41 |
# File 'lib/ttt_malisa/display.rb', line 39 def @console.('Please enter a single character that is unique') end |
#invalid_player_choice ⇒ Object
43 44 45 |
# File 'lib/ttt_malisa/display.rb', line 43 def invalid_player_choice @console.('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 (mark) @console.("Player #{mark}, please enter a position 1-9 that is not already marked") end |
#player_choice ⇒ Object
47 48 49 50 51 |
# File 'lib/ttt_malisa/display.rb', line 47 def player_choice @console.('Please choose a player type') @console.('1: Human Player') @console.('2: Computer Player') end |
#retrieve_user_input ⇒ Object
15 16 17 |
# File 'lib/ttt_malisa/display.rb', line 15 def retrieve_user_input @console.retrieve_user_input end |
#setup_mark_message ⇒ Object
23 24 25 |
# File 'lib/ttt_malisa/display.rb', line 23 def @console.('Please enter a single character to use as your game piece') end |
#welcome ⇒ Object
7 8 9 |
# File 'lib/ttt_malisa/display.rb', line 7 def welcome @console.('Welcome to Tic Tac Toe') end |
#winner_message(mark) ⇒ Object
27 28 29 |
# File 'lib/ttt_malisa/display.rb', line 27 def (mark) @console.("Congratulations #{mark}!") end |