Class: SplendorGame::Card

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(level, colour, cost, points = 0) ⇒ Card

Returns a new instance of Card.



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

def initialize(level, colour, cost, points = 0)
  @level = level
  @points = points
  @colour = colour
  @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

#colourObject (readonly)

Returns the value of attribute colour.



4
5
6
# File 'lib/splendor_game/card.rb', line 4

def colour
  @colour
end

#costObject (readonly)

Returns the value of attribute cost.



4
5
6
# File 'lib/splendor_game/card.rb', line 4

def cost
  @cost
end

#levelObject (readonly)

Returns the value of attribute level.



4
5
6
# File 'lib/splendor_game/card.rb', line 4

def level
  @level
end

#pointsObject (readonly)

Returns the value of attribute points.



4
5
6
# File 'lib/splendor_game/card.rb', line 4

def points
  @points
end