Created
          January 5, 2014 02:18 
        
      - 
      
- 
        Save chadjemmett/8263456 to your computer and use it in GitHub Desktop. 
    Added/changed features to a fortune telling program
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | #fake animated status bar. | |
| def sleep_dots(seconds) | |
| seconds.times do | |
| print "." | |
| sleep(1) | |
| end | |
| return " " | |
| end | |
| #the response arrays. | |
| lucky_response = ['...Tomorrow is your lucky day!', '... You should buy a lotto ticket', '..I see love in your future'] | |
| bad_response = ['... You are the most unlucky person I know', '...BEGONE FROM ME DEVIL!', '...Let me give you the suicide prevention hotline number'] | |
| middle_response = ['..Dark days ahead', '..My crystal ball is a little hazy, let me clean it and get back to you', '...uhhh', '..maybe you should have said no'] | |
| puts 'I am a fortune-teller. Tell me your name:' | |
| name = gets.chomp | |
| #you can add +1 to your random number. To avoid zero. | |
| dice = (rand(100) + 1) | |
| puts 'Hi ' + name + ' Your lucky number is ' + dice.to_s + ' ' | |
| loop do | |
| #you have to press ctrl + c to break out of the loop. | |
| puts 'Would you like me to read your fortune?' | |
| user_response = gets.chomp.downcase | |
| case user_response | |
| when "yes" | |
| puts 'Based on your lucky number' | |
| if dice >= 70 | |
| sleep_dots(10) | |
| puts lucky_response.sample | |
| elsif dice <= 15 | |
| sleep_dots(3) | |
| puts bad_response.sample | |
| else | |
| sleep_dots(6) | |
| puts middle_response.sample | |
| end | |
| when "no" | |
| puts "Why did you come to a fortune teller?" | |
| else | |
| puts "I don't understand your voo doo language!" | |
| end | |
| end | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment