Created
July 4, 2013 01:35
-
-
Save bacalj/5924272 to your computer and use it in GitHub Desktop.
Doing this in a weird way. Face cards not calculating. Advice?
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
# this "works", but face cards don't calculate. | |
# this is not 'elegant' | |
suits = [' of Diamonds' , ' of Hearts', ' of Clubs', ' of Spades'] | |
values = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K' ] | |
deck = [] | |
deck = values.product(suits) | |
deck.shuffle! | |
player = [] | |
dealer = [] | |
puts '--- BLACKJACK ---'.center(30) | |
puts 'DEALER CARDS:' | |
#-----------------dealer calc------------------------------------- | |
dealer_total = 0 | |
2.times do | |
myCard = deck.pop | |
dealer.push myCard | |
puts myCard.join.to_s.center(30) | |
end | |
if dealer[0].at(0).to_s == 'A' | |
dealer[0].insert(0,11) | |
end | |
if dealer[0].at(0).to_s == 0 | |
dealer[0].insert(0, 10) | |
end | |
if dealer[1].at(0).to_s == 0 | |
dealer[1].insert(0, 10) | |
end | |
dealer_total = (dealer[0].at(0).to_i) + (dealer[1].at(0).to_i) | |
puts 'Dealer Total:' + dealer_total.to_s | |
puts ' ' | |
puts 'YOUR CARDS:' | |
#-----------------player calc------------------------------------- | |
2.times do | |
myCard = deck.pop | |
player.push myCard | |
puts myCard.join.to_s.center(30) | |
end | |
if player[0].at(0).to_s == 'A' | |
elsif player[0].at(0).to_s == 0 | |
player[0].insert(0, 10) | |
end | |
if player[1].at(0).to_s == 0 | |
player[1].insert(0, 10) | |
end | |
player_total = (player[0].at(0).to_i) + (player[1].at(0).to_i) | |
puts 'Your Total:' + player_total.to_s | |
puts ' ' | |
puts ' ' | |
puts '(H)IT or (S)TAY?' | |
puts ' ' |
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
#nothing here yet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment