class Battleships::Player

Attributes

board[RW]
name[RW]
opponent[RW]

Public Instance Methods

all_ships_sunk?() click to toggle source
# File lib/battleships/player.rb, line 24
def all_ships_sunk?
  fail 'Player has no board' unless board
  board.all_ships_sunk?
end
place_ship(ship, coordinates, orientation = :horizontally) click to toggle source
# File lib/battleships/player.rb, line 5
def place_ship ship, coordinates, orientation = :horizontally
  board.place_ship ship, coordinates, orientation
end
receive_shot(coordinates) click to toggle source
# File lib/battleships/player.rb, line 9
def receive_shot coordinates
  fail 'Player has no board' unless board
  board.receive_shot coordinates
end
shoot(coordinates) click to toggle source
# File lib/battleships/player.rb, line 14
def shoot coordinates
  fail 'Player has no opponent' unless opponent
  opponent.receive_shot coordinates
end
winner?() click to toggle source
# File lib/battleships/player.rb, line 19
def winner?
  fail 'Player has no opponent' unless opponent
  opponent.all_ships_sunk?
end