Class: JbcdenTtt::GameState
- Inherits:
-
Object
- Object
- JbcdenTtt::GameState
- Defined in:
- lib/jbcden_ttt/game_state.rb
Instance Attribute Summary collapse
-
#board ⇒ Object
readonly
Returns the value of attribute board.
-
#current_player ⇒ Object
readonly
Returns the value of attribute current_player.
-
#turn_num ⇒ Object
readonly
Returns the value of attribute turn_num.
Instance Method Summary collapse
- #end_state? ⇒ Boolean
-
#initialize(board, turn_num, current_player) ⇒ GameState
constructor
A new instance of GameState.
Constructor Details
#initialize(board, turn_num, current_player) ⇒ GameState
Returns a new instance of GameState.
4 5 6 7 8 |
# File 'lib/jbcden_ttt/game_state.rb', line 4 def initialize(board, turn_num, current_player) @board = board @turn_num = turn_num @player = current_player end |
Instance Attribute Details
#board ⇒ Object (readonly)
Returns the value of attribute board.
3 4 5 |
# File 'lib/jbcden_ttt/game_state.rb', line 3 def board @board end |
#current_player ⇒ Object (readonly)
Returns the value of attribute current_player.
3 4 5 |
# File 'lib/jbcden_ttt/game_state.rb', line 3 def current_player @current_player end |
#turn_num ⇒ Object (readonly)
Returns the value of attribute turn_num.
3 4 5 |
# File 'lib/jbcden_ttt/game_state.rb', line 3 def turn_num @turn_num end |
Instance Method Details
#end_state? ⇒ Boolean
10 11 12 13 14 15 16 |
# File 'lib/jbcden_ttt/game_state.rb', line 10 def end_state? if turn_num >= min_turns row_win(board) || column_win(board) || diagonal_win(board) || full_board(board) else false end end |