Last active
August 29, 2015 14:23
-
-
Save Juice10/348481f88fb20b393b77 to your computer and use it in GitHub Desktop.
very impressive card game
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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