Class: TTT::GameHistory

Inherits:
Object
  • Object
show all
Defined in:
lib/ttt/game_history.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGameHistory

Returns a new instance of GameHistory.



7
8
9
10
# File 'lib/ttt/game_history.rb', line 7

def initialize
  self.history         = []
  self.move_traverser  = MoveTraverser.new(self)
end

Instance Attribute Details

#historyObject

Returns the value of attribute history.



6
7
8
# File 'lib/ttt/game_history.rb', line 6

def history
  @history
end

#move_traverserObject

Returns the value of attribute move_traverser.



6
7
8
# File 'lib/ttt/game_history.rb', line 6

def move_traverser
  @move_traverser
end

Instance Method Details

#adjust_move_index(index_diff) ⇒ Object



25
26
27
# File 'lib/ttt/game_history.rb', line 25

def adjust_move_index(index_diff)
  move_traverser.adjust_move_index(index_diff)
end

#get_history_board(board, move_number_limit = move_traverser.move_index) ⇒ Object



29
30
31
# File 'lib/ttt/game_history.rb', line 29

def get_history_board(board, move_number_limit = move_traverser.move_index)
  move_traverser.history_board_builder(board, move_number_limit)
end

#inc_move_indexObject



17
18
19
# File 'lib/ttt/game_history.rb', line 17

def inc_move_index
  self.move_traverser.move_index = history.length
end

#initialize_historyObject



33
34
35
# File 'lib/ttt/game_history.rb', line 33

def initialize_history
  move_traverser.initialize_history
end

#record_move(cell, side) ⇒ Object



12
13
14
15
# File 'lib/ttt/game_history.rb', line 12

def record_move(cell, side)
  self.history << MoveHistory.new(:move => cell, :side => side)
  inc_move_index
end

#showObject



21
22
23
# File 'lib/ttt/game_history.rb', line 21

def show
  self.history
end