Skip to content

Instantly share code, notes, and snippets.

@TraceyK14
Created August 12, 2015 04:00
Show Gist options
  • Save TraceyK14/721bbb07b851512cdfa4 to your computer and use it in GitHub Desktop.
Save TraceyK14/721bbb07b851512cdfa4 to your computer and use it in GitHub Desktop.
def hit(all_cards)
card_array = ["third", "fouth", "fifth"]
card_array.each do |element|
element_card = draw
if player == "player1"
puts "\nPlayer 1's #{element} card is #{element_card}"
else
puts "\nPlayer 2's #{element} card is #{element_card}"
end
if element_card == "A"
puts "Would you like for your Ace to be a 1 or 11?"
element_card = gets.chomp.to_i
end
all_cards.push(element_card)
if all_cards.inject(:+) > 21
puts "Busted"
return all_cards.inject(:+)
elsif all_cards.inject(:+) == 21
puts "You have 21"
return all_cards.inject(:+)
end
puts "Would you like to hit? press y or n"
hit = gets.chomp.downcase
if hit == "n"
return all_cards.inject(:+)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment