Skip to content

Instantly share code, notes, and snippets.

@Juice10
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Juice10/348481f88fb20b393b77 to your computer and use it in GitHub Desktop.
Save Juice10/348481f88fb20b393b77 to your computer and use it in GitHub Desktop.
very impressive card game
# 52 cards print them line by line
def setup_players
players = []
playersNumber = (2..10).to_a.sample
playersNumber.times do |player|
players << []
end
players
end
def populate_deck
family = ['hearts', 'spades', 'clubs', 'dimonds']
facecards = %w{jack queen king ace}
numbers = 2..10
all_cards = family.map do |dec|
(numbers.to_a + facecards).map do |card|
"#{dec} #{card}"
end
end
all_cards.flatten.shuffle
end
def deal(players, deck)
max_cards = 2
max_cards.times do
players.map do |player|
card = deck.pop
player << card
end
end
players
end
deck = populate_deck
rivals = setup_players
puts deal(rivals, deck).inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment