class SplendorGame::Player

Attributes

name[R]
nobles[R]
tableau[R]
turn_order[R]

Public Class Methods

new(name, turn_order, token_limit) click to toggle source
# File lib/splendor_game/player.rb, line 7
def initialize(name, turn_order, token_limit)
  @name = name
  @turn_order = turn_order
  @tableau = Tableau.new(token_limit)
  @nobles = Array.new()
end

Public Instance Methods

can_afford_noble?(noble) click to toggle source
# File lib/splendor_game/player.rb, line 19
def can_afford_noble?(noble)
  noble.cost.each do |k, v|
    return false if @tableau.colours_on_cards(k) < v 
  end
  true
end
claim_noble(noble) click to toggle source
# File lib/splendor_game/player.rb, line 26
def claim_noble(noble)
  return false if !can_afford_noble?(noble)
  @nobles << noble
  true
end
points() click to toggle source
# File lib/splendor_game/player.rb, line 14
def points
  card_points = @tableau.cards.inject(0) { |sum,c| sum + c.points }
  card_points + @nobles.inject(0) { |sum,c| sum + c.points }
end