Class: SplendorGame::Noble

Inherits:
ColouredObject show all
Defined in:
lib/splendor_game/noble.rb

Overview

Players become eligible for Nobles when they have cards that meet the cost (NOT tokens)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cost, points = 0) ⇒ Noble

Returns a new instance of Noble.



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/splendor_game/noble.rb', line 7

def initialize(cost, points = 0)
  @points = points
  @cost, @cost_error = Hash.new(), Hash.new()
  # if the colour is valid, load it, if not, put it in an error hash
  cost.each do |key, value|
    new_key_name = validate_colour(key)
    if new_key_name==false
      @cost_error[key] = value
    else
      @cost[new_key_name] = value
    end
  end
end

Instance Attribute Details

#costObject (readonly)

Returns the value of attribute cost.



5
6
7
# File 'lib/splendor_game/noble.rb', line 5

def cost
  @cost
end

#pointsObject (readonly)

Returns the value of attribute points.



5
6
7
# File 'lib/splendor_game/noble.rb', line 5

def points
  @points
end