Class: Gomoku::Player

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

Overview

Defines common functionality for all players

Direct Known Subclasses

Computer, Human

Instance Method Summary collapse

Constructor Details

#initialize(window, board, color) ⇒ Player

Returns a new instance of Player.



4
5
6
7
8
# File 'lib/gomoku/player.rb', line 4

def initialize(window, board, color)
  @window = window
  @board = board
  @color = color
end

Instance Method Details

#click(_click_r, _click_c) ⇒ Object



10
11
# File 'lib/gomoku/player.rb', line 10

def click(_click_r, _click_c)
end

#drawObject



19
20
21
22
23
24
25
# File 'lib/gomoku/player.rb', line 19

def draw
  return unless @hover_r && @hover_c
  return unless Utility.in_range?(@hover_r, @hover_c) &&
                @board.empty?(@hover_r, @hover_c)
  # Draw the hover for next piece
  @board.draw_hover(@color, @hover_r, @hover_c)
end

#pick_moveObject



16
17
# File 'lib/gomoku/player.rb', line 16

def pick_move
end

#updateObject



13
14
# File 'lib/gomoku/player.rb', line 13

def update
end