36 lines
724 B
Ruby

module Models
module PlayHelpers
def create_hand(count, type)
cards = []
count.times do
cards << PlayerCard.new
end
case type
when /single/
cards[0].rank = Card::RANKS[0]
cards[0].suit = Card::SUITS[0]
when /run/
cards.each.with_index(3) do |c, i|
# double
if type.include? 'double'
c.rank = Card::RANKS[i % (cards.count/2)]
else
c.rank = Card::RANKS[i % 13]
end
# suited
if type.include? 'suited'
c.suit = Card::SUITS[0]
else
c.suit = Card::SUITS[i % 4]
end
end
end
return cards
end
end
end