My problem is that chips
is not saving as a global variable for the argument it is passed. I am passing $h1c
(which is the number of total chips player's first hand has). So if he wins or loses, chips
should then be set equal to chips
+
or -
betamount
.
The problem is that it's not being saved as the global variable. If I were to write $h1c = 150_000
, then it would equal that. If later on I write $h1c = 150_000 + 50_000
, then 200_000 would be the new value of $h1c.
For some reason this isn't working when I declare chips = chips + betamount
, which is the same as saying $h1c = $h1c + $h1bet
.
def review(hand, chips, betamount)
abc = valueofcards(hand) #player's hand value
klm = valueofcards($handD) #dealer's hand value
if abc == klm and abc < 19
puts "You tied"
chips = chips
elsif abc > 18
puts "You lost"
chips = chips - betamount
elsif abc < 19 and klm > 18
puts "You won"
chips = chips + betamount
elsif abc < 19 and abc > klm
puts "You won"
chips = chips + betamount
elsif abc < 19 and klm < 19 and klm > abc
puts "You lost"
chips = chips - betamount
end
end
This is the where I pass the arguments to review:
def pre_review(num)
puts "Recap of that round"
puts "First Hand:"
review($hand1, $h1c, $h1bet)
muckcards(num)
end
If need be, here is the link to the full code/game to test the problem out http://labs.codecademy.com/Bmvl#:workspace Note: That I'm currently just trying to get this portion to work for $hand1, so you would select 1 for number of hands to play to reproduce this problem.