Hi, i’m a beginner in Ruby and i’m doing a really easy “game”.
My problem is that i want to test if the user press 1 then roll some
dices but i can’t use my method ><’
I join you the code and thank you for hepling
tot = 0
def rollDice
tot = 0
puts “You roll the dices”
d1 = rand(1…6)
puts “Dice 1: #{d1}”
d2 = rand(1…6)
puts “Dice 2: #{d2}”
d3 = rand(1…6)
puts “Dice #{d3}”
tot = d1 + d2 + d3
puts “Your score is #{tot}”
return tot
end
[some puts but not important for the coding ]
puts “Press 1 to play or 2 to leave”
value = gets.chomp
if value == “1”
s1 = self.rollDice
puts “Why it doesnt work :C #{s1}”
[i have a player class but its not important for the moment]
#player1 = Joueur.new(j1)
#player2 = Joueur.new(j2)
#player1.score
#player2.score
elsif value== "2"
exit
end