Last active
August 29, 2015 14:02
-
-
Save Wonderfall/e0f41b1267ce6cb2a897 to your computer and use it in GitHub Desktop.
Shake some words!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyleft | |
# Thanks to Caletlog ! Shorter & Faster ! | |
# Good game ! | |
puts "You have to find a secret word, each player has 5 tries !" | |
score = 0 | |
loop do | |
print "Enter some word : " | |
secretWord = gets.chomp | |
30.times { puts } | |
shakedWord = secretWord.split(//).shuffle.join | |
(1..5).each do |i| | |
puts "--- #{6-i} tries/try left." | |
print "What's this word : #{shakedWord} ? " | |
if gets.chomp == secretWord | |
puts "Well played !" | |
score += 5 | |
puts | |
break | |
else | |
puts "Try again..." | |
score -= 1 | |
puts | |
end | |
end | |
print "The game is over. Play a new one ? (y/n)" | |
break if gets.chomp == 'n' | |
end | |
at_exit { puts "Your score is : #{score} !" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment