Skip to content

Instantly share code, notes, and snippets.

@Wonderfall
Created June 15, 2014 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Wonderfall/d172c2a945ad68c7a017 to your computer and use it in GitHub Desktop.
Save Wonderfall/d172c2a945ad68c7a017 to your computer and use it in GitHub Desktop.
puts "Un simple pendu. On se passera de règles..."
points = 0
loop do
print "Saisissez un mot : "
motMystere = gets.chomp
cache = String.new
motMystere.length.times { cache += "_" }
30.times { puts }
loop do
puts cache
print "Proposez une lettre : "
proposition = gets.chomp
i = 0
motMystere.length.times do
if proposition == motMystere[i]
cache[i] = motMystere[i]
end
i += 1
end
if cache == motMystere
puts "Bien joué ! Le mot était #{motMystere} !"
points += 20
2.times { puts }
break
else
points -= 1
puts
end
end
print "Rejouer ? (o/n) "
if gets.chomp == 'n'
break
else
2.times { puts }
end
end
at_exit { puts "Votre score est : #{points}" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment