Sha256: 89f460e4b83d3e6859fc4bd86dba211e8bbd6f2c19b065dbbe31d15a38163bcf
Contents?: true
Size: 725 Bytes
Versions: 2
Compression:
Stored size: 725 Bytes
Contents
module SplendorGame class Player attr_reader :name, :turn_order, :tableau, :nobles def initialize(name, turn_order, token_limit) @name = name @turn_order = turn_order @tableau = Tableau.new(token_limit) @nobles = Array.new() end def points card_points = @tableau.cards.inject(0) { |sum,c| sum + c.points } card_points + @nobles.inject(0) { |sum,c| sum + c.points } end def can_afford_noble?(noble) noble.cost.each do |k, v| return false if @tableau.colours_on_cards(k) < v end true end def claim_noble(noble) return false if !can_afford_noble?(noble) @nobles << noble true end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
splendor_game-0.1.1 | lib/splendor_game/player.rb |
splendor_game-0.1.0 | lib/splendor_game/player.rb |