lib/gloomhaven/deck.rb in gloomhaven-0.1.0 vs lib/gloomhaven/deck.rb in gloomhaven-1.0.0
- old
+ new
@@ -15,11 +15,11 @@
# Adds a card to the current deck.
# Useful for updating decks based on character-specific perks.
# Ex:
#
# deck = Deck.new
- # card = Card.find('Attack +3')
+ # card = Card.new('Attack +3')
# deck.add!(card)
def add!(card)
raise TypeError.new('Card must be a Gloomhaven::Card') unless card.is_a?(Gloomhaven::Card)
@cards << card
@@ -27,18 +27,18 @@
end
##
# Adds a bless card to the current deck, then soft shuffles
def bless!
- @cards << Card.find('Bless')
+ @cards << Card.new('Bless')
shuffle!(soft_shuffle: true)
end
##
# Adds a curse card to the current deck, then soft shuffles
def curse!
- @cards << Card.find('Curse')
+ @cards << Card.new('Curse')
shuffle!(soft_shuffle: true)
end
##
# Removes the top card from the deck, adds it to the @drawn_cards array (unless it's a bless/curse)
@@ -55,11 +55,11 @@
# Removes a card from the current deck.
# Useful for updating decks based on character-specific perks.
# Ex:
#
# deck = Deck.new
- # card = Card.find('Attack -1')
+ # card = Card.new('Attack -1')
# deck.remove!(card)
def remove!(card)
raise TypeError.new('Card must be a Gloomhaven::Card') unless card.is_a?(Gloomhaven::Card)
index = cards.index { |c| c.name == card.name }
@@ -74,11 +74,11 @@
# By default, will shuffle all cards together.
#
# Can override with `options = { soft_shuffle: true }` to
# only shuffle cards not yet drawn (useful for blesses/curses)
def shuffle!(options = {})
- options[:soft_shuffle] ||= false
+ options[:soft_shuffle] ||= false
return @cards.shuffle! if options[:soft_shuffle]
@cards = (@cards + @drawn_cards).shuffle
@drawn_cards = []
@cards
@@ -86,11 +86,11 @@
private
def build_base_deck!
CARDS.each do |card|
- id, attributes = card
- attributes['starting_count'].times { cards << Card.new(id) }
+ number = card['starting_count'] || 0
+ number.times { cards << Card.new(card['name']) }
end
end
end
end
\ No newline at end of file