Class: TicTacToe::Game
- Inherits:
-
Object
- Object
- TicTacToe::Game
- Defined in:
- lib/tic_tac_toe/game.rb
Instance Attribute Summary collapse
-
#board ⇒ Object
readonly
Returns the value of attribute board.
-
#computer_player ⇒ Object
readonly
Returns the value of attribute computer_player.
Instance Method Summary collapse
- #get_mark_at(position) ⇒ Object
- #in_progress? ⇒ Boolean
-
#initialize ⇒ Game
constructor
A new instance of Game.
- #move(position) ⇒ Object
- #tie ⇒ Object
- #winner ⇒ Object
Constructor Details
Instance Attribute Details
#board ⇒ Object (readonly)
Returns the value of attribute board.
5 6 7 |
# File 'lib/tic_tac_toe/game.rb', line 5 def board @board end |
#computer_player ⇒ Object (readonly)
Returns the value of attribute computer_player.
5 6 7 |
# File 'lib/tic_tac_toe/game.rb', line 5 def computer_player @computer_player end |
Instance Method Details
#get_mark_at(position) ⇒ Object
24 25 26 |
# File 'lib/tic_tac_toe/game.rb', line 24 def get_mark_at(position) @board.get_mark_at(position) end |
#in_progress? ⇒ Boolean
14 15 16 17 |
# File 'lib/tic_tac_toe/game.rb', line 14 def in_progress? return false if winner || tie return true end |
#move(position) ⇒ Object
19 20 21 22 |
# File 'lib/tic_tac_toe/game.rb', line 19 def move(position) @board.set_mark(current_mark, position) change_current_mark end |
#tie ⇒ Object
32 33 34 |
# File 'lib/tic_tac_toe/game.rb', line 32 def tie @rules.tie end |
#winner ⇒ Object
28 29 30 |
# File 'lib/tic_tac_toe/game.rb', line 28 def winner @rules.winner end |