Class: Gato

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGato

Returns a new instance of Gato.



19
20
21
22
23
24
# File 'lib/Gato.rb', line 19

def initialize
  @board = [[EMPTY,EMPTY,EMPTY],[EMPTY, EMPTY, EMPTY],[EMPTY, EMPTY, EMPTY]]
  @currentPlayer = CROSS
  @isFinished = false
@quantity_of_moves = 0
end

Instance Attribute Details

#boardObject

Returns the value of attribute board.



12
13
14
# File 'lib/Gato.rb', line 12

def board
  @board
end

#currentPlayerObject

Returns the value of attribute currentPlayer.



12
13
14
# File 'lib/Gato.rb', line 12

def currentPlayer
  @currentPlayer
end

#isFinishedObject

Returns the value of attribute isFinished.



12
13
14
# File 'lib/Gato.rb', line 12

def isFinished
  @isFinished
end

Instance Method Details

#intended_move(row, column) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/Gato.rb', line 26

def intended_move(row, column)
	result_operation = 0
	if not is_in_bounderies?(row, column)
		result_operation = INVALID_POSITION
	elsif not is_empty?(row-1, column-1)
		result_operation = BOX_TAKEN
	else
		result_operation = update_game(row-1, column-1)
	end
result_operation
end