I don't really understand what you're trying to do, but i can see one
problem.
roll_1 = rand(6) happens inside the if block, right? (if (input !=
"pass"))
So it will be done if the if test is true. And if the first if test is
true, then the elsif will never be tested - when it finishes the if
block then it will exit the whole if/elsif section.
Without getting into any other details, and just addressing the if/else
stuff, this might be better - it uses a nested if instead of an elsif
which i think is what you wanted to do.
score = 0
turns = 0
faces = [one, two, three, four, five, six]
answered = false
while (answered == false) do
puts "Would you like to Roll or Pass?"
input = gets().chomp().downcase()
if (input == "pass")
puts "\nFinal Score is: " + score.to_s()
(answered = true)
else
roll_1 = rand(6)
roll_2 = rand(6)
puts faces[roll_1] + faces[roll_2]
score = score + (roll_1 + 1) + (roll_2 +1)
turns = turns + 1
puts "Current Score is: " + score.to_s()
if (roll_1 == 0 || roll_2 == 0)
puts "You lose!\nFinal Score is: 0"
answered = true
end
end
end
puts "Turns taken: " + turns.to_s()
--
Posted via http://www.ruby-forum.com/.