class Bridge::Player
Public Class Methods
new(game)
click to toggle source
# File lib/bridge/player.rb, line 3 def initialize(game) @game = game # Access to game is private to this object. end
Public Instance Methods
get_hand()
click to toggle source
# File lib/bridge/player.rb, line 7 def get_hand position = game.players[self] return game.get_hand(position) end
Also aliased as: hand
make_call(call)
click to toggle source
# File lib/bridge/player.rb, line 13 def make_call(call) begin return game.make_call(call, player = self) rescue Exception => e if Bridge::DEBUG puts e.backtrace.first(8).join("\n").red puts "\n" end raise GameError, e.message end end
play_card(card)
click to toggle source
# File lib/bridge/player.rb, line 25 def play_card(card) begin return self.game.play_card(card, self) rescue Exception => e if Bridge::DEBUG puts e.backtrace.first(8).join("\n").red puts "\n" end raise GameError, e.message end end
start_next_game()
click to toggle source
# File lib/bridge/player.rb, line 37 def start_next_game raise GameError, "Not ready to start game" unless game.next_game_ready? game.start! end
Protected Instance Methods
game()
click to toggle source
# File lib/bridge/player.rb, line 43 def game @game end