I’m trying to make a card game with Ruby. I created a hash of cards and
numeric values which works fine on its own:
example:
deck = Hash.new
deck[“Ah”] = 1
deck[“1h”] = 1
deck[“2h”] = 2
deck[“3h”] = 3
deck[“4h”] = 4
deck[“5h”] = 5
where:
puts deck[“3h”]
properly returns 3.
I wrote some code to output the hash into an array and then shuffle it
which also works. I have code to deal out the cards into new arrays for
each player which works as well. My issue is when I try to call things
like:
puts player1.first
it will give the appropriate first card in the hand but:
puts deck[player1.first]
does not return the value of the card. I’ve also tried created place
holder variables without avail:
x = player1.first
puts x
gives the proper output of the card in hand but:
puts deck[x]
comes up a blank line.
Any thoughts?